diff --git a/src/app/interfaces/certificate.interface.ts b/src/app/interfaces/certificate.interface.ts index ffa2f15f052..ea0de57f58e 100644 --- a/src/app/interfaces/certificate.interface.ts +++ b/src/app/interfaces/certificate.interface.ts @@ -38,6 +38,7 @@ export interface Certificate { key_type: CertificateKeyType; lifetime: number; name: string; + add_to_trusted_store: boolean; organization: string; organizational_unit: string; parsed: boolean; diff --git a/src/app/pages/credentials/certificates-dash/certificate-authority-add/steps/ca-identifier-and-type/ca-identifier-and-type.component.html b/src/app/pages/credentials/certificates-dash/certificate-authority-add/steps/ca-identifier-and-type/ca-identifier-and-type.component.html index af9e3267aa4..d44bb15b584 100644 --- a/src/app/pages/credentials/certificates-dash/certificate-authority-add/steps/ca-identifier-and-type/ca-identifier-and-type.component.html +++ b/src/app/pages/credentials/certificates-dash/certificate-authority-add/steps/ca-identifier-and-type/ca-identifier-and-type.component.html @@ -29,6 +29,8 @@ class="add-to-trusted-store" [label]="'Add To Trusted Store' | translate" > + +
} diff --git a/src/app/pages/credentials/certificates-dash/certificate-authority-add/steps/ca-identifier-and-type/ca-identifier-and-type.component.scss b/src/app/pages/credentials/certificates-dash/certificate-authority-add/steps/ca-identifier-and-type/ca-identifier-and-type.component.scss deleted file mode 100644 index 16d5ef72314..00000000000 --- a/src/app/pages/credentials/certificates-dash/certificate-authority-add/steps/ca-identifier-and-type/ca-identifier-and-type.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.add-to-trusted-store { - margin-bottom: 16px; -} diff --git a/src/app/pages/credentials/certificates-dash/certificate-authority-add/steps/ca-identifier-and-type/ca-identifier-and-type.component.ts b/src/app/pages/credentials/certificates-dash/certificate-authority-add/steps/ca-identifier-and-type/ca-identifier-and-type.component.ts index f9ab89927d4..6c07cb39c58 100644 --- a/src/app/pages/credentials/certificates-dash/certificate-authority-add/steps/ca-identifier-and-type/ca-identifier-and-type.component.ts +++ b/src/app/pages/credentials/certificates-dash/certificate-authority-add/steps/ca-identifier-and-type/ca-identifier-and-type.component.ts @@ -11,7 +11,6 @@ import { mapToOptions } from 'app/helpers/options.helper'; import { helptextSystemCa } from 'app/helptext/system/ca'; import { CertificateProfile, CertificateProfiles } from 'app/interfaces/certificate.interface'; import { Option } from 'app/interfaces/option.interface'; -import { DialogService } from 'app/modules/dialog/dialog.service'; import { IxValidatorsService } from 'app/modules/forms/ix-forms/services/ix-validators.service'; import { SummaryProvider, SummarySection } from 'app/modules/summary/summary.interface'; import { ErrorHandlerService } from 'app/services/error-handler.service'; @@ -20,7 +19,6 @@ import { WebSocketService } from 'app/services/ws.service'; @UntilDestroy() @Component({ selector: 'ix-ca-identifier-and-type', - styleUrls: ['./ca-identifier-and-type.component.scss'], templateUrl: './ca-identifier-and-type.component.html', changeDetection: ChangeDetectionStrategy.OnPush, }) @@ -57,7 +55,6 @@ export class CaIdentifierAndTypeComponent implements OnInit, SummaryProvider { private translate: TranslateService, private errorHandler: ErrorHandlerService, private ws: WebSocketService, - private dialogService: DialogService, private cdr: ChangeDetectorRef, private validators: IxValidatorsService, ) {} diff --git a/src/app/pages/credentials/certificates-dash/certificate-authority-edit/certificate-authority-edit.component.html b/src/app/pages/credentials/certificates-dash/certificate-authority-edit/certificate-authority-edit.component.html index 77ee5d643d2..65737e6997e 100644 --- a/src/app/pages/credentials/certificates-dash/certificate-authority-edit/certificate-authority-edit.component.html +++ b/src/app/pages/credentials/certificates-dash/certificate-authority-edit/certificate-authority-edit.component.html @@ -19,6 +19,13 @@ + + + + @if (certificateAuthority) { diff --git a/src/app/pages/credentials/certificates-dash/certificate-authority-edit/certificate-authority-edit.component.spec.ts b/src/app/pages/credentials/certificates-dash/certificate-authority-edit/certificate-authority-edit.component.spec.ts index 31d9902ed6a..27b945e526c 100644 --- a/src/app/pages/credentials/certificates-dash/certificate-authority-edit/certificate-authority-edit.component.spec.ts +++ b/src/app/pages/credentials/certificates-dash/certificate-authority-edit/certificate-authority-edit.component.spec.ts @@ -9,6 +9,7 @@ import { mockAuth } from 'app/core/testing/utils/mock-auth.utils'; import { mockCall, mockWebSocket } from 'app/core/testing/utils/mock-websocket.utils'; import { CertificateAuthority } from 'app/interfaces/certificate-authority.interface'; import { DialogService } from 'app/modules/dialog/dialog.service'; +import { IxCheckboxHarness } from 'app/modules/forms/ix-forms/components/ix-checkbox/ix-checkbox.harness'; import { IxInputHarness } from 'app/modules/forms/ix-forms/components/ix-input/ix-input.harness'; import { IxSlideInRef } from 'app/modules/forms/ix-forms/components/ix-slide-in/ix-slide-in-ref'; import { SLIDE_IN_DATA } from 'app/modules/forms/ix-forms/components/ix-slide-in/ix-slide-in.token'; @@ -78,10 +79,15 @@ describe('CertificateAuthorityEditComponent', () => { const nameInput = await loader.getHarness(IxInputHarness.with({ label: 'Identifier' })); await nameInput.setValue('New Name'); + const addToTrustedStoreCheckbox = await loader.getHarness(IxCheckboxHarness.with({ label: 'Add to trusted store' })); + await addToTrustedStoreCheckbox.setValue(true); + const saveButton = await loader.getHarness(MatButtonHarness.with({ text: 'Save' })); await saveButton.click(); - expect(spectator.inject(WebSocketService).call).toHaveBeenCalledWith('certificateauthority.update', [1, { name: 'New Name' }]); + expect(spectator.inject(WebSocketService).call).toHaveBeenCalledWith('certificateauthority.update', [1, + { name: 'New Name', add_to_trusted_store: true }, + ]); expect(spectator.inject(IxSlideInRef).close).toHaveBeenCalled(); }); diff --git a/src/app/pages/credentials/certificates-dash/certificate-authority-edit/certificate-authority-edit.component.ts b/src/app/pages/credentials/certificates-dash/certificate-authority-edit/certificate-authority-edit.component.ts index 7b0bca00e43..d9893a11d08 100644 --- a/src/app/pages/credentials/certificates-dash/certificate-authority-edit/certificate-authority-edit.component.ts +++ b/src/app/pages/credentials/certificates-dash/certificate-authority-edit/certificate-authority-edit.component.ts @@ -32,6 +32,7 @@ export class CertificateAuthorityEditComponent implements OnInit { form = this.formBuilder.group({ name: ['', Validators.required], + add_to_trusted_store: [false], }); certificateAuthority: CertificateAuthority; diff --git a/src/app/pages/credentials/certificates-dash/certificate-edit/certificate-edit.component.html b/src/app/pages/credentials/certificates-dash/certificate-edit/certificate-edit.component.html index 8d1b03f6f1f..d81c8ffe1a0 100644 --- a/src/app/pages/credentials/certificates-dash/certificate-edit/certificate-edit.component.html +++ b/src/app/pages/credentials/certificates-dash/certificate-edit/certificate-edit.component.html @@ -16,6 +16,7 @@ [required]="true" [tooltip]="helptext.edit.name.tooltip | translate" > + @if (form.controls.renew_days) { + + + + @if (certificate) { { const nameInput = await loader.getHarness(IxInputHarness.with({ label: 'Identifier' })); await nameInput.setValue('New Name'); + const addToTrustedStoreCheckbox = await loader.getHarness(IxCheckboxHarness.with({ label: 'Add to trusted store' })); + await addToTrustedStoreCheckbox.setValue(true); + const saveButton = await loader.getHarness(MatButtonHarness.with({ text: 'Save' })); await saveButton.click(); - expect(spectator.inject(WebSocketService).job).toHaveBeenCalledWith('certificate.update', [1, { name: 'New Name' }]); + expect(spectator.inject(WebSocketService).job).toHaveBeenCalledWith('certificate.update', [1, + { name: 'New Name', add_to_trusted_store: true }, + ]); expect(spectator.inject(IxSlideInRef).close).toHaveBeenCalled(); }); diff --git a/src/app/pages/credentials/certificates-dash/certificate-edit/certificate-edit.component.ts b/src/app/pages/credentials/certificates-dash/certificate-edit/certificate-edit.component.ts index 65bb2cb588d..28e4b3a7e1b 100644 --- a/src/app/pages/credentials/certificates-dash/certificate-edit/certificate-edit.component.ts +++ b/src/app/pages/credentials/certificates-dash/certificate-edit/certificate-edit.component.ts @@ -39,8 +39,10 @@ export class CertificateEditComponent implements OnInit { form = this.formBuilder.group({ name: ['', Validators.required], + add_to_trusted_store: [false], }) as FormGroup<{ name: FormControl; + add_to_trusted_store: FormControl; renew_days?: FormControl; }>; diff --git a/src/app/pages/credentials/certificates-dash/forms/certificate-add/certificate-add.component.spec.ts b/src/app/pages/credentials/certificates-dash/forms/certificate-add/certificate-add.component.spec.ts index abedb08ec91..b2a3c94bad8 100644 --- a/src/app/pages/credentials/certificates-dash/forms/certificate-add/certificate-add.component.spec.ts +++ b/src/app/pages/credentials/certificates-dash/forms/certificate-add/certificate-add.component.spec.ts @@ -178,6 +178,7 @@ describe('CertificateAddComponent', () => { organization: 'Umbrella Corp', organizational_unit: 'Virus Research Dept', email: 'no-reply@umbrella.com', + add_to_trusted_store: false, san: ['jobs.umbrella.com'], cert_extensions: { BasicConstraints: { @@ -232,6 +233,7 @@ describe('CertificateAddComponent', () => { certificate: '-----BEGIN CERTIFICATE-----', passphrase: '1234567890', privatekey: '-----BEGIN PRIVATE-----', + add_to_trusted_store: false, }]); }); diff --git a/src/app/pages/credentials/certificates-dash/forms/certificate-add/steps/certificate-identifier-and-type/certificate-identifier-and-type.component.html b/src/app/pages/credentials/certificates-dash/forms/certificate-add/steps/certificate-identifier-and-type/certificate-identifier-and-type.component.html index e49db2845d4..c0f8d092621 100644 --- a/src/app/pages/credentials/certificates-dash/forms/certificate-add/steps/certificate-identifier-and-type/certificate-identifier-and-type.component.html +++ b/src/app/pages/credentials/certificates-dash/forms/certificate-add/steps/certificate-identifier-and-type/certificate-identifier-and-type.component.html @@ -23,6 +23,14 @@ > } + + +
+