Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAS-131360 / 25.04 / Remove root user from set initial password form #10734

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@ export class IxInputHarness extends ComponentHarness implements IxFormControlHar
async isDisabled(): Promise<boolean> {
return (await this.getMatInputHarness()).isDisabled();
}

async isReadonly(): Promise<boolean> {
return (await this.getMatInputHarness()).isReadonly();
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
<form [formGroup]="form" (submit)="onSubmit()">
<div>
{{ 'Set up TrueNAS authentication method:' | translate }}
{{ 'Set password for TrueNAS administrative user:' | translate }}
</div>

<ix-radio-group
<ix-input
type="text"
formControlName="username"
[required]="true"
[options]="usernameOptions$"
></ix-radio-group>

<div>
{{ 'Set new password:' | translate }}
</div>
autocomplete="username"
[label]="'Username' | translate"
[readonly]="true"
></ix-input>

<ix-input
type="password"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { createComponentFactory, mockProvider, Spectator } from '@ngneat/spectat
import { of } from 'rxjs';
import { mockCall, mockWebSocket } from 'app/core/testing/utils/mock-websocket.utils';
import { LoginResult } from 'app/enums/login-result.enum';
import { IxRadioGroupHarness } from 'app/modules/forms/ix-forms/components/ix-radio-group/ix-radio-group.harness';
import { IxInputHarness } from 'app/modules/forms/ix-forms/components/ix-input/ix-input.harness';
import { IxFormHarness } from 'app/modules/forms/ix-forms/testing/ix-form.harness';
import {
SetAdminPasswordFormComponent,
Expand Down Expand Up @@ -45,26 +45,11 @@ describe('SetAdminPasswordFormComponent', () => {
form = await loader.getHarness(IxFormHarness);
});

it('sets new root password when form is submitted', async () => {
const usernameRadio = await loader.getHarness(IxRadioGroupHarness);
await usernameRadio.setValue('Root user (not recommended)');
it('shows truenas_admin in readonly Username field', async () => {
const username = await form.getControl('Username') as IxInputHarness;

await form.fillForm({
Password: '12345678',
'Reenter Password': '12345678',
});

const submitButton = await loader.getHarness(MatButtonHarness.with({ text: 'Sign In' }));
await submitButton.click();

const websocket = spectator.inject(WebSocketService);
const authService = spectator.inject(AuthService);
expect(websocket.call).toHaveBeenCalledWith('user.setup_local_administrator', ['root', '12345678']);
expect(authService.login).toHaveBeenCalledWith('root', '12345678');

const signinStore = spectator.inject(SigninStore);
expect(signinStore.setLoadingState).toHaveBeenCalledWith(true);
expect(signinStore.handleSuccessfulLogin).toHaveBeenCalled();
expect(await username.getValue()).toBe('truenas_admin');
expect(await username.isReadonly()).toBe(true);
});

it('sets new admin password when form is submitted', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import {
import { MatButton } from '@angular/material/button';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { TranslateService, TranslateModule } from '@ngx-translate/core';
import { Observable, of } from 'rxjs';
import { switchMap } from 'rxjs/operators';
import { LoginResult } from 'app/enums/login-result.enum';
import { RadioOption } from 'app/interfaces/option.interface';
import { IxInputComponent } from 'app/modules/forms/ix-forms/components/ix-input/ix-input.component';
import { IxRadioGroupComponent } from 'app/modules/forms/ix-forms/components/ix-radio-group/ix-radio-group.component';
import { FormErrorHandlerService } from 'app/modules/forms/ix-forms/services/form-error-handler.service';
Expand Down Expand Up @@ -60,11 +58,6 @@ export class SetAdminPasswordFormComponent {
],
});

readonly usernameOptions$: Observable<RadioOption[]> = of([
{ label: `${this.translate.instant('Administrative user')} (${adminUsername})`, value: adminUsername },
{ label: this.translate.instant('Root user (not recommended)'), value: 'root' },
]);

constructor(
private formBuilder: FormBuilder,
private ws: WebSocketService,
Expand Down
5 changes: 1 addition & 4 deletions src/assets/i18n/af.json
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@
"Admin Servers": "",
"Admin Username": "",
"Administrative account name on the LDAP server. Example: <i>cn=Manager,dc=test,dc=org</i>.": "",
"Administrative user": "",
"Administrators": "",
"Administrators Group": "",
"Admins": "",
Expand Down Expand Up @@ -3416,7 +3415,6 @@
"Rolling back...": "",
"Root TCP Socket": "",
"Root dataset ACL cannot be edited.": "",
"Root user (not recommended)": "",
"Rotation Rate": "",
"Rotation Rate (RPM)": "",
"Routing": "",
Expand Down Expand Up @@ -3788,9 +3786,9 @@
"Set for the default configuration to listen on all interfaces using the known values of user: <i>upsmon</i> and password: <i>fixmepass</i>.": "",
"Set if the initiator does not support physical block size values over 4K (MS SQL).": "",
"Set new password": "",
"Set new password:": "",
"Set only if required by the NFS client. Set to allow serving non-root mount requests.": "",
"Set or change the password of this SED. This password is used instead of the global SED password.": "",
"Set password for TrueNAS administrative user:": "",
"Set production status as active": "",
"Set specific times to snapshot the <i>Source Datasets</i> and replicate the snapshots to the <i>Destination Dataset</i>. Select a preset schedule or choose <i>Custom</i> to use the advanced scheduler.": "",
"Set the domain name to the username. Unset to prevent name collisions when Allow Trusted Domains is set and multiple domains use the same username.": "",
Expand Down Expand Up @@ -3856,7 +3854,6 @@
"Set to to enable support for <a href=\"https://tools.ietf.org/html/rfc3410\" target=\"_blank\">SNMP version 3</a>. See <a href=\"http://net-snmp.sourceforge.net/docs/man/snmpd.conf.html\" target=\"_blank\">snmpd.conf(5)</a> for configuration details.": "",
"Set to use encryption when replicating data. Additional encryption options will appear.": "",
"Set to use the <i>Schedule</i> in place of the <i>Replicate Specific Snapshots</i> time frame. The Schedule values are read over the <i>Replicate Specific Snapshots</i> time frame.": "",
"Set up TrueNAS authentication method:": "",
"Set when NFSv4 ACL support is needed without requiring the client and the server to sync users and groups.": "",
"Set when using Xen as the iSCSI initiator.": "",
"Set whether processes can be executed from within this dataset.": "",
Expand Down
5 changes: 1 addition & 4 deletions src/assets/i18n/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@
"Admin Servers": "",
"Admin Username": "",
"Administrative account name on the LDAP server. Example: <i>cn=Manager,dc=test,dc=org</i>.": "",
"Administrative user": "",
"Administrators": "",
"Administrators Group": "",
"Admins": "",
Expand Down Expand Up @@ -3416,7 +3415,6 @@
"Rolling back...": "",
"Root TCP Socket": "",
"Root dataset ACL cannot be edited.": "",
"Root user (not recommended)": "",
"Rotation Rate": "",
"Rotation Rate (RPM)": "",
"Routing": "",
Expand Down Expand Up @@ -3788,9 +3786,9 @@
"Set for the default configuration to listen on all interfaces using the known values of user: <i>upsmon</i> and password: <i>fixmepass</i>.": "",
"Set if the initiator does not support physical block size values over 4K (MS SQL).": "",
"Set new password": "",
"Set new password:": "",
"Set only if required by the NFS client. Set to allow serving non-root mount requests.": "",
"Set or change the password of this SED. This password is used instead of the global SED password.": "",
"Set password for TrueNAS administrative user:": "",
"Set production status as active": "",
"Set specific times to snapshot the <i>Source Datasets</i> and replicate the snapshots to the <i>Destination Dataset</i>. Select a preset schedule or choose <i>Custom</i> to use the advanced scheduler.": "",
"Set the domain name to the username. Unset to prevent name collisions when Allow Trusted Domains is set and multiple domains use the same username.": "",
Expand Down Expand Up @@ -3856,7 +3854,6 @@
"Set to to enable support for <a href=\"https://tools.ietf.org/html/rfc3410\" target=\"_blank\">SNMP version 3</a>. See <a href=\"http://net-snmp.sourceforge.net/docs/man/snmpd.conf.html\" target=\"_blank\">snmpd.conf(5)</a> for configuration details.": "",
"Set to use encryption when replicating data. Additional encryption options will appear.": "",
"Set to use the <i>Schedule</i> in place of the <i>Replicate Specific Snapshots</i> time frame. The Schedule values are read over the <i>Replicate Specific Snapshots</i> time frame.": "",
"Set up TrueNAS authentication method:": "",
"Set when NFSv4 ACL support is needed without requiring the client and the server to sync users and groups.": "",
"Set when using Xen as the iSCSI initiator.": "",
"Set whether processes can be executed from within this dataset.": "",
Expand Down
5 changes: 1 addition & 4 deletions src/assets/i18n/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@
"Admin Servers": "",
"Admin Username": "",
"Administrative account name on the LDAP server. Example: <i>cn=Manager,dc=test,dc=org</i>.": "",
"Administrative user": "",
"Administrators": "",
"Administrators Group": "",
"Admins": "",
Expand Down Expand Up @@ -3416,7 +3415,6 @@
"Rolling back...": "",
"Root TCP Socket": "",
"Root dataset ACL cannot be edited.": "",
"Root user (not recommended)": "",
"Rotation Rate": "",
"Rotation Rate (RPM)": "",
"Routing": "",
Expand Down Expand Up @@ -3788,9 +3786,9 @@
"Set for the default configuration to listen on all interfaces using the known values of user: <i>upsmon</i> and password: <i>fixmepass</i>.": "",
"Set if the initiator does not support physical block size values over 4K (MS SQL).": "",
"Set new password": "",
"Set new password:": "",
"Set only if required by the NFS client. Set to allow serving non-root mount requests.": "",
"Set or change the password of this SED. This password is used instead of the global SED password.": "",
"Set password for TrueNAS administrative user:": "",
"Set production status as active": "",
"Set specific times to snapshot the <i>Source Datasets</i> and replicate the snapshots to the <i>Destination Dataset</i>. Select a preset schedule or choose <i>Custom</i> to use the advanced scheduler.": "",
"Set the domain name to the username. Unset to prevent name collisions when Allow Trusted Domains is set and multiple domains use the same username.": "",
Expand Down Expand Up @@ -3856,7 +3854,6 @@
"Set to to enable support for <a href=\"https://tools.ietf.org/html/rfc3410\" target=\"_blank\">SNMP version 3</a>. See <a href=\"http://net-snmp.sourceforge.net/docs/man/snmpd.conf.html\" target=\"_blank\">snmpd.conf(5)</a> for configuration details.": "",
"Set to use encryption when replicating data. Additional encryption options will appear.": "",
"Set to use the <i>Schedule</i> in place of the <i>Replicate Specific Snapshots</i> time frame. The Schedule values are read over the <i>Replicate Specific Snapshots</i> time frame.": "",
"Set up TrueNAS authentication method:": "",
"Set when NFSv4 ACL support is needed without requiring the client and the server to sync users and groups.": "",
"Set when using Xen as the iSCSI initiator.": "",
"Set whether processes can be executed from within this dataset.": "",
Expand Down
5 changes: 1 addition & 4 deletions src/assets/i18n/az.json
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@
"Admin Servers": "",
"Admin Username": "",
"Administrative account name on the LDAP server. Example: <i>cn=Manager,dc=test,dc=org</i>.": "",
"Administrative user": "",
"Administrators": "",
"Administrators Group": "",
"Admins": "",
Expand Down Expand Up @@ -3416,7 +3415,6 @@
"Rolling back...": "",
"Root TCP Socket": "",
"Root dataset ACL cannot be edited.": "",
"Root user (not recommended)": "",
"Rotation Rate": "",
"Rotation Rate (RPM)": "",
"Routing": "",
Expand Down Expand Up @@ -3788,9 +3786,9 @@
"Set for the default configuration to listen on all interfaces using the known values of user: <i>upsmon</i> and password: <i>fixmepass</i>.": "",
"Set if the initiator does not support physical block size values over 4K (MS SQL).": "",
"Set new password": "",
"Set new password:": "",
"Set only if required by the NFS client. Set to allow serving non-root mount requests.": "",
"Set or change the password of this SED. This password is used instead of the global SED password.": "",
"Set password for TrueNAS administrative user:": "",
"Set production status as active": "",
"Set specific times to snapshot the <i>Source Datasets</i> and replicate the snapshots to the <i>Destination Dataset</i>. Select a preset schedule or choose <i>Custom</i> to use the advanced scheduler.": "",
"Set the domain name to the username. Unset to prevent name collisions when Allow Trusted Domains is set and multiple domains use the same username.": "",
Expand Down Expand Up @@ -3856,7 +3854,6 @@
"Set to to enable support for <a href=\"https://tools.ietf.org/html/rfc3410\" target=\"_blank\">SNMP version 3</a>. See <a href=\"http://net-snmp.sourceforge.net/docs/man/snmpd.conf.html\" target=\"_blank\">snmpd.conf(5)</a> for configuration details.": "",
"Set to use encryption when replicating data. Additional encryption options will appear.": "",
"Set to use the <i>Schedule</i> in place of the <i>Replicate Specific Snapshots</i> time frame. The Schedule values are read over the <i>Replicate Specific Snapshots</i> time frame.": "",
"Set up TrueNAS authentication method:": "",
"Set when NFSv4 ACL support is needed without requiring the client and the server to sync users and groups.": "",
"Set when using Xen as the iSCSI initiator.": "",
"Set whether processes can be executed from within this dataset.": "",
Expand Down
5 changes: 1 addition & 4 deletions src/assets/i18n/be.json
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@
"Admin Servers": "",
"Admin Username": "",
"Administrative account name on the LDAP server. Example: <i>cn=Manager,dc=test,dc=org</i>.": "",
"Administrative user": "",
"Administrators": "",
"Administrators Group": "",
"Admins": "",
Expand Down Expand Up @@ -3416,7 +3415,6 @@
"Rolling back...": "",
"Root TCP Socket": "",
"Root dataset ACL cannot be edited.": "",
"Root user (not recommended)": "",
"Rotation Rate": "",
"Rotation Rate (RPM)": "",
"Routing": "",
Expand Down Expand Up @@ -3788,9 +3786,9 @@
"Set for the default configuration to listen on all interfaces using the known values of user: <i>upsmon</i> and password: <i>fixmepass</i>.": "",
"Set if the initiator does not support physical block size values over 4K (MS SQL).": "",
"Set new password": "",
"Set new password:": "",
"Set only if required by the NFS client. Set to allow serving non-root mount requests.": "",
"Set or change the password of this SED. This password is used instead of the global SED password.": "",
"Set password for TrueNAS administrative user:": "",
"Set production status as active": "",
"Set specific times to snapshot the <i>Source Datasets</i> and replicate the snapshots to the <i>Destination Dataset</i>. Select a preset schedule or choose <i>Custom</i> to use the advanced scheduler.": "",
"Set the domain name to the username. Unset to prevent name collisions when Allow Trusted Domains is set and multiple domains use the same username.": "",
Expand Down Expand Up @@ -3856,7 +3854,6 @@
"Set to to enable support for <a href=\"https://tools.ietf.org/html/rfc3410\" target=\"_blank\">SNMP version 3</a>. See <a href=\"http://net-snmp.sourceforge.net/docs/man/snmpd.conf.html\" target=\"_blank\">snmpd.conf(5)</a> for configuration details.": "",
"Set to use encryption when replicating data. Additional encryption options will appear.": "",
"Set to use the <i>Schedule</i> in place of the <i>Replicate Specific Snapshots</i> time frame. The Schedule values are read over the <i>Replicate Specific Snapshots</i> time frame.": "",
"Set up TrueNAS authentication method:": "",
"Set when NFSv4 ACL support is needed without requiring the client and the server to sync users and groups.": "",
"Set when using Xen as the iSCSI initiator.": "",
"Set whether processes can be executed from within this dataset.": "",
Expand Down
5 changes: 1 addition & 4 deletions src/assets/i18n/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@
"Admin Servers": "",
"Admin Username": "",
"Administrative account name on the LDAP server. Example: <i>cn=Manager,dc=test,dc=org</i>.": "",
"Administrative user": "",
"Administrators": "",
"Administrators Group": "",
"Admins": "",
Expand Down Expand Up @@ -3416,7 +3415,6 @@
"Rolling back...": "",
"Root TCP Socket": "",
"Root dataset ACL cannot be edited.": "",
"Root user (not recommended)": "",
"Rotation Rate": "",
"Rotation Rate (RPM)": "",
"Routing": "",
Expand Down Expand Up @@ -3788,9 +3786,9 @@
"Set for the default configuration to listen on all interfaces using the known values of user: <i>upsmon</i> and password: <i>fixmepass</i>.": "",
"Set if the initiator does not support physical block size values over 4K (MS SQL).": "",
"Set new password": "",
"Set new password:": "",
"Set only if required by the NFS client. Set to allow serving non-root mount requests.": "",
"Set or change the password of this SED. This password is used instead of the global SED password.": "",
"Set password for TrueNAS administrative user:": "",
"Set production status as active": "",
"Set specific times to snapshot the <i>Source Datasets</i> and replicate the snapshots to the <i>Destination Dataset</i>. Select a preset schedule or choose <i>Custom</i> to use the advanced scheduler.": "",
"Set the domain name to the username. Unset to prevent name collisions when Allow Trusted Domains is set and multiple domains use the same username.": "",
Expand Down Expand Up @@ -3856,7 +3854,6 @@
"Set to to enable support for <a href=\"https://tools.ietf.org/html/rfc3410\" target=\"_blank\">SNMP version 3</a>. See <a href=\"http://net-snmp.sourceforge.net/docs/man/snmpd.conf.html\" target=\"_blank\">snmpd.conf(5)</a> for configuration details.": "",
"Set to use encryption when replicating data. Additional encryption options will appear.": "",
"Set to use the <i>Schedule</i> in place of the <i>Replicate Specific Snapshots</i> time frame. The Schedule values are read over the <i>Replicate Specific Snapshots</i> time frame.": "",
"Set up TrueNAS authentication method:": "",
"Set when NFSv4 ACL support is needed without requiring the client and the server to sync users and groups.": "",
"Set when using Xen as the iSCSI initiator.": "",
"Set whether processes can be executed from within this dataset.": "",
Expand Down
Loading
Loading