Skip to content

Commit

Permalink
NAS-131032 / 25.04 / Expose add to trusted store for certs in UI (#10638
Browse files Browse the repository at this point in the history
)

* NAS-131032: Expose add to trusted store for certs in UI

* NAS-131032: Expose add to trusted store for certs in UI

* NAS-131032: PR update
  • Loading branch information
AlexKarpov98 authored Sep 10, 2024
1 parent 4efc5ea commit 6b663d5
Show file tree
Hide file tree
Showing 103 changed files with 147 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/app/interfaces/certificate.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
class="add-to-trusted-store"
[label]="'Add To Trusted Store' | translate"
></ix-checkbox>

<br>
}

<ix-form-actions>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
})
Expand Down Expand Up @@ -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,
) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
</div>
</ix-fieldset>

<ix-fieldset>
<ix-checkbox
formControlName="add_to_trusted_store"
[label]="'Add to trusted store' | translate"
></ix-checkbox>
</ix-fieldset>

@if (certificateAuthority) {
<ix-fieldset [title]="'Subject' | translate">
<ix-certificate-details [certificate]="certificateAuthority"></ix-certificate-details>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class CertificateAuthorityEditComponent implements OnInit {

form = this.formBuilder.group({
name: ['', Validators.required],
add_to_trusted_store: [false],
});

certificateAuthority: CertificateAuthority;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
[required]="true"
[tooltip]="helptext.edit.name.tooltip | translate"
></ix-input>

@if (form.controls.renew_days) {
<ix-input
class="column"
Expand All @@ -29,6 +30,13 @@
</div>
</ix-fieldset>

<ix-fieldset>
<ix-checkbox
formControlName="add_to_trusted_store"
[label]="'Add to trusted store' | translate"
></ix-checkbox>
</ix-fieldset>

@if (certificate) {
<ix-fieldset [title]="'Subject' | translate">
<ix-certificate-details
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.columns {
column-gap: 10px;
display: flex;
flex-wrap: wrap;

.column {
flex: 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { mockAuth } from 'app/core/testing/utils/mock-auth.utils';
import { mockJob, mockWebSocket } from 'app/core/testing/utils/mock-websocket.utils';
import { Certificate } from 'app/interfaces/certificate.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';
Expand Down Expand Up @@ -101,10 +102,15 @@ describe('CertificateEditComponent', () => {
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();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<string | null>;
add_to_trusted_store: FormControl<boolean>;
renew_days?: FormControl<number | null>;
}>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ describe('CertificateAddComponent', () => {
organization: 'Umbrella Corp',
organizational_unit: 'Virus Research Dept',
email: '[email protected]',
add_to_trusted_store: false,
san: ['jobs.umbrella.com'],
cert_extensions: {
BasicConstraints: {
Expand Down Expand Up @@ -232,6 +233,7 @@ describe('CertificateAddComponent', () => {
certificate: '-----BEGIN CERTIFICATE-----',
passphrase: '1234567890',
privatekey: '-----BEGIN PRIVATE-----',
add_to_trusted_store: false,
}]);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
></ix-select>
}

<ix-checkbox
formControlName="add_to_trusted_store"
class="add-to-trusted-store"
[label]="'Add To Trusted Store' | translate"
></ix-checkbox>

<br>

<ix-form-actions>
<button
mat-button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ describe('CertificateIdentifierAndTypeComponent', () => {
Name: 'New Certificate',
Type: 'Internal Certificate',
Profile: 'Openvpn Client Certificate',
'Add To Trusted Store': true,
});
});

it('returns name and type when getPayload is called', () => {
expect(spectator.component.getPayload()).toEqual({
name: 'New Certificate',
create_type: CertificateCreateType.CreateInternal,
add_to_trusted_store: true,
});
});

Expand All @@ -76,6 +78,10 @@ describe('CertificateIdentifierAndTypeComponent', () => {
label: 'Profile',
value: 'Openvpn Client Certificate',
},
{
label: 'Add To Trusted Store',
value: 'Yes',
},
]);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class CertificateIdentifierAndTypeComponent implements OnInit, SummaryPro
]],
create_type: [CertificateCreateType.CreateInternal],
profile: [''],
add_to_trusted_store: [false],
});

profiles: CertificateProfiles;
Expand Down Expand Up @@ -91,11 +92,15 @@ export class CertificateIdentifierAndTypeComponent implements OnInit, SummaryPro
summary.push({ label: this.translate.instant('Profile'), value: values.profile });
}

if (values.add_to_trusted_store) {
summary.push({ label: this.translate.instant('Add To Trusted Store'), value: this.translate.instant('Yes') });
}

return summary;
}

getPayload(): Pick<CertificateIdentifierAndTypeComponent['form']['value'], 'name' | 'create_type'> {
return _.pick(this.form.value, ['name', 'create_type']);
getPayload(): Pick<CertificateIdentifierAndTypeComponent['form']['value'], 'name' | 'create_type' | 'add_to_trusted_store'> {
return _.pick(this.form.value, ['name', 'create_type', 'add_to_trusted_store']);
}

private emitEventOnProfileChange(): void {
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/af.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
"Add new": "",
"Add the required no. of disks to get a vdev size estimate": "",
"Add this user to additional groups.": "",
"Add to trusted store": "",
"Add {item}": "",
"Added disks are erased, then the pool is extended onto the new disks with the chosen topology. Existing data on the pool is kept intact.": "",
"Adding data VDEVs of different types is not supported.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
"Add new": "",
"Add the required no. of disks to get a vdev size estimate": "",
"Add this user to additional groups.": "",
"Add to trusted store": "",
"Add {item}": "",
"Added disks are erased, then the pool is extended onto the new disks with the chosen topology. Existing data on the pool is kept intact.": "",
"Adding data VDEVs of different types is not supported.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
"Add new": "",
"Add the required no. of disks to get a vdev size estimate": "",
"Add this user to additional groups.": "",
"Add to trusted store": "",
"Add {item}": "",
"Added disks are erased, then the pool is extended onto the new disks with the chosen topology. Existing data on the pool is kept intact.": "",
"Adding data VDEVs of different types is not supported.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/az.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
"Add new": "",
"Add the required no. of disks to get a vdev size estimate": "",
"Add this user to additional groups.": "",
"Add to trusted store": "",
"Add {item}": "",
"Added disks are erased, then the pool is extended onto the new disks with the chosen topology. Existing data on the pool is kept intact.": "",
"Adding data VDEVs of different types is not supported.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/be.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
"Add new": "",
"Add the required no. of disks to get a vdev size estimate": "",
"Add this user to additional groups.": "",
"Add to trusted store": "",
"Add {item}": "",
"Added disks are erased, then the pool is extended onto the new disks with the chosen topology. Existing data on the pool is kept intact.": "",
"Adding data VDEVs of different types is not supported.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
"Add new": "",
"Add the required no. of disks to get a vdev size estimate": "",
"Add this user to additional groups.": "",
"Add to trusted store": "",
"Add {item}": "",
"Added disks are erased, then the pool is extended onto the new disks with the chosen topology. Existing data on the pool is kept intact.": "",
"Adding data VDEVs of different types is not supported.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/bn.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
"Add new": "",
"Add the required no. of disks to get a vdev size estimate": "",
"Add this user to additional groups.": "",
"Add to trusted store": "",
"Add {item}": "",
"Added disks are erased, then the pool is extended onto the new disks with the chosen topology. Existing data on the pool is kept intact.": "",
"Adding data VDEVs of different types is not supported.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/br.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
"Add new": "",
"Add the required no. of disks to get a vdev size estimate": "",
"Add this user to additional groups.": "",
"Add to trusted store": "",
"Add {item}": "",
"Added disks are erased, then the pool is extended onto the new disks with the chosen topology. Existing data on the pool is kept intact.": "",
"Adding data VDEVs of different types is not supported.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/bs.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
"Add new": "",
"Add the required no. of disks to get a vdev size estimate": "",
"Add this user to additional groups.": "",
"Add to trusted store": "",
"Add {item}": "",
"Added disks are erased, then the pool is extended onto the new disks with the chosen topology. Existing data on the pool is kept intact.": "",
"Adding data VDEVs of different types is not supported.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
"Add new": "",
"Add the required no. of disks to get a vdev size estimate": "",
"Add this user to additional groups.": "",
"Add to trusted store": "",
"Add {item}": "",
"Added disks are erased, then the pool is extended onto the new disks with the chosen topology. Existing data on the pool is kept intact.": "",
"Adding data VDEVs of different types is not supported.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@
"Add new": "",
"Add the required no. of disks to get a vdev size estimate": "",
"Add this user to additional groups.": "",
"Add to trusted store": "",
"Add {item}": "",
"Added disks are erased, then the pool is extended onto the new disks with the chosen topology. Existing data on the pool is kept intact.": "",
"Adding data VDEVs of different types is not supported.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/cy.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
"Add new": "",
"Add the required no. of disks to get a vdev size estimate": "",
"Add this user to additional groups.": "",
"Add to trusted store": "",
"Add {item}": "",
"Added disks are erased, then the pool is extended onto the new disks with the chosen topology. Existing data on the pool is kept intact.": "",
"Adding data VDEVs of different types is not supported.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
"Add new": "",
"Add the required no. of disks to get a vdev size estimate": "",
"Add this user to additional groups.": "",
"Add to trusted store": "",
"Add {item}": "",
"Added disks are erased, then the pool is extended onto the new disks with the chosen topology. Existing data on the pool is kept intact.": "",
"Adding data VDEVs of different types is not supported.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@
"Add listen": "",
"Add new": "",
"Add the required no. of disks to get a vdev size estimate": "",
"Add to trusted store": "",
"Add {item}": "",
"Adding data VDEVs of different types is not supported.": "",
"Additional <a href=\"https://www.smartmontools.org/browser/trunk/smartmontools/smartctl.8.in\" target=\"_blank\">smartctl(8)</a> options.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/dsb.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
"Add new": "",
"Add the required no. of disks to get a vdev size estimate": "",
"Add this user to additional groups.": "",
"Add to trusted store": "",
"Add {item}": "",
"Added disks are erased, then the pool is extended onto the new disks with the chosen topology. Existing data on the pool is kept intact.": "",
"Adding data VDEVs of different types is not supported.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
"Add new": "",
"Add the required no. of disks to get a vdev size estimate": "",
"Add this user to additional groups.": "",
"Add to trusted store": "",
"Add {item}": "",
"Added disks are erased, then the pool is extended onto the new disks with the chosen topology. Existing data on the pool is kept intact.": "",
"Adding data VDEVs of different types is not supported.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/en-au.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
"Add new": "",
"Add the required no. of disks to get a vdev size estimate": "",
"Add this user to additional groups.": "",
"Add to trusted store": "",
"Add {item}": "",
"Added disks are erased, then the pool is extended onto the new disks with the chosen topology. Existing data on the pool is kept intact.": "",
"Adding data VDEVs of different types is not supported.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/en-gb.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
"Add new": "",
"Add the required no. of disks to get a vdev size estimate": "",
"Add this user to additional groups.": "",
"Add to trusted store": "",
"Add {item}": "",
"Added disks are erased, then the pool is extended onto the new disks with the chosen topology. Existing data on the pool is kept intact.": "",
"Adding data VDEVs of different types is not supported.": "",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
"Add new": "",
"Add the required no. of disks to get a vdev size estimate": "",
"Add this user to additional groups.": "",
"Add to trusted store": "",
"Add {item}": "",
"Added disks are erased, then the pool is extended onto the new disks with the chosen topology. Existing data on the pool is kept intact.": "",
"Adding data VDEVs of different types is not supported.": "",
Expand Down
Loading

0 comments on commit 6b663d5

Please sign in to comment.