Skip to content

Commit fc2b6c2

Browse files
authored
NAS-136995 / 26.04 / Make directoryservice validation more strict (#17021)
This commit removes ability for users to set a directoryservices.update request without providing the configuration and credential details if a service_type has been specified. This ensures that the config details are always valid. There is already a supported method for users to clear config if that's what's needed.
1 parent 998a852 commit fc2b6c2

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/middlewared/middlewared/api/v25_10_0/directory_services.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ def validate_ds(self):
609609
if self.service_type == undefined and self.enable is not False:
610610
raise ValueError('service_type is required in update payloads')
611611

612-
if self.enable is True and self.service_type is not None:
612+
if self.service_type not in (None, undefined):
613613
if self.configuration in (None, undefined):
614614
raise ValueError('Explicit configuration is required when service_type is specified')
615615

src/middlewared/middlewared/api/v26_04_0/directory_services.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ def validate_ds(self):
609609
if self.service_type == undefined and self.enable is not False:
610610
raise ValueError('service_type is required in update payloads')
611611

612-
if self.enable is True and self.service_type is not None:
612+
if self.service_type not in (None, undefined):
613613
if self.configuration in (None, undefined):
614614
raise ValueError('Explicit configuration is required when service_type is specified')
615615

0 commit comments

Comments
 (0)