Skip to content

Commit

Permalink
NAS-134556 / 25.10 / Fix bind_ip for smb service config (#11663)
Browse files Browse the repository at this point in the history
  • Loading branch information
RehanY147 authored Mar 5, 2025
1 parent 0724134 commit efb6ef3
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
3 changes: 0 additions & 3 deletions src/app/interfaces/bind-ip.interface.ts

This file was deleted.

3 changes: 1 addition & 2 deletions src/app/interfaces/smb-config.interface.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { SmbEncryption } from 'app/enums/smb-encryption.enum';
import { BindIp } from 'app/interfaces/bind-ip.interface';

export interface SmbConfig {
aapl_extensions: boolean;
admin_group: string | null;
bindip: BindIp[];
bindip: string[];
cifs_SID: string;
description: string;
dirmask: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
(delete)="removeBindIp(i)"
>
<ix-select
formControlName="$ipv4_interface"
formControlName="bindIp"
[label]="'IP Address' | translate"
[options]="bindIpAddressOptions$"
[required]="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { of } from 'rxjs';
import { mockCall, mockApi } from 'app/core/testing/utils/mock-api.utils';
import { mockAuth } from 'app/core/testing/utils/mock-auth.utils';
import { SmbEncryption } from 'app/enums/smb-encryption.enum';
import { BindIp } from 'app/interfaces/bind-ip.interface';
import { SmbConfig } from 'app/interfaces/smb-config.interface';
import { User } from 'app/interfaces/user.interface';
import { DialogService } from 'app/modules/dialog/dialog.service';
Expand Down Expand Up @@ -54,7 +53,7 @@ describe('ServiceSmbComponent', () => {
guest: 'nobody',
filemask: '',
dirmask: '',
bindip: [] as BindIp[],
bindip: [] as string[],
cifs_SID: 'mockSid',
ntlmv1_auth: false,
enable_smb1: false,
Expand Down Expand Up @@ -195,10 +194,10 @@ describe('ServiceSmbComponent', () => {
const bindIpList = await loader.getHarness(IxListHarness.with({ label: 'Bind IP Addresses' }));
await bindIpList.pressAddButton();
const bindIpForm1 = await bindIpList.getLastListItem();
await bindIpForm1.fillForm({ 'IP Address': '1.1.1.1/32' });
await bindIpForm1.fillForm({ 'IP Address': '1.1.1.1' });
await bindIpList.pressAddButton();
const bindIpForm2 = await bindIpList.getLastListItem();
await bindIpForm2.fillForm({ 'IP Address': '2.2.2.2/32' });
await bindIpForm2.fillForm({ 'IP Address': '2.2.2.2' });

const form = await loader.getHarness(IxFormHarness);
await form.fillForm({
Expand Down Expand Up @@ -229,8 +228,8 @@ describe('ServiceSmbComponent', () => {
aapl_extensions: true,
admin_group: 'test-group',
bindip: [
{ $ipv4_interface: '1.1.1.1/32' },
{ $ipv4_interface: '2.2.2.2/32' },
'1.1.1.1',
'2.2.2.2',
],
guest: 'nobody',
dirmask: '0777',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { SmbEncryption, smbEncryptionLabels } from 'app/enums/smb-encryption.enu
import { choicesToOptions } from 'app/helpers/operators/options.operators';
import { mapToOptions } from 'app/helpers/options.helper';
import { helptextServiceSmb } from 'app/helptext/services/components/service-smb';
import { BindIp } from 'app/interfaces/bind-ip.interface';
import { SmbConfigUpdate } from 'app/interfaces/smb-config.interface';
import { DialogService } from 'app/modules/dialog/dialog.service';
import { SimpleAsyncComboboxProvider } from 'app/modules/forms/ix-forms/classes/simple-async-combobox-provider';
Expand All @@ -38,6 +37,10 @@ import { ApiService } from 'app/modules/websocket/api.service';
import { ErrorHandlerService } from 'app/services/error-handler.service';
import { UserService } from 'app/services/user.service';

interface BindIp {
bindIp: string;
}

@UntilDestroy({ arrayName: 'subscriptions' })
@Component({
selector: 'ix-service-smb',
Expand Down Expand Up @@ -138,8 +141,8 @@ export class ServiceSmbComponent implements OnInit {
map(([options, config]) => {
return [
...new Set<string>([
...config.bindip.map((item) => item.$ipv4_interface),
...options.map((option) => `${option.value}/32`),
...config.bindip,
...options.map((option) => `${option.value}`),
]),
].map((value) => ({ label: value, value }));
}),
Expand Down Expand Up @@ -171,7 +174,7 @@ export class ServiceSmbComponent implements OnInit {
this.api.call('smb.config').pipe(untilDestroyed(this)).subscribe({
next: (config) => {
config.bindip.forEach(() => this.addBindIp());
this.form.patchValue(config);
this.form.patchValue({ ...config, bindip: config.bindip.map((ip) => ({ bindIp: ip })) });
this.isFormLoading = false;
this.cdr.markForCheck();
},
Expand All @@ -185,7 +188,7 @@ export class ServiceSmbComponent implements OnInit {

addBindIp(): void {
this.form.controls.bindip.push(this.fb.group({
$ipv4_interface: ['', [Validators.required]],
bindIp: ['', [Validators.required]],
}));
}

Expand All @@ -198,7 +201,10 @@ export class ServiceSmbComponent implements OnInit {
}

onSubmit(): void {
const values: SmbConfigUpdate = this.form.value;
const values: SmbConfigUpdate = {
...this.form.value,
bindip: this.form.value.bindip.map((value) => value.bindIp),
};

this.isFormLoading = true;
this.api.call('smb.update', [values])
Expand Down

0 comments on commit efb6ef3

Please sign in to comment.