From: Rob van der Linde Date: Tue, 7 Nov 2023 05:45:30 +0000 (+1300) Subject: netcmd: silo member: Make output consistent with user command X-Git-Tag: talloc-2.4.2~752 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2f20fa9b90af637b7e5ca8c6227f74f710da170e;p=thirdparty%2Fsamba.git netcmd: silo member: Make output consistent with user command * Use print with file=self.outf * Show assigned or unassigned silo Signed-off-by: Rob van der Linde Reviewed-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/netcmd/domain/auth/silo_member.py b/python/samba/netcmd/domain/auth/silo_member.py index f9ec2686cf1..af5fbc0913b 100644 --- a/python/samba/netcmd/domain/auth/silo_member.py +++ b/python/samba/netcmd/domain/auth/silo_member.py @@ -75,7 +75,14 @@ class cmd_domain_auth_silo_member_add(Command): except ModelError as e: raise CommandError(e) - self.outf.write(f"User {user} added to the authentication silo {name}.\n") + # Display silo assigned status. + if user.assigned_silo and user.assigned_silo == silo.dn: + status = "assigned" + else: + status = "unassigned" + + print(f"User {user} added to the authentication silo {name} ({status}).", + file=self.outf) class cmd_domain_auth_silo_member_list(Command): @@ -122,7 +129,7 @@ class cmd_domain_auth_silo_member_list(Command): self.print_json([member.as_dict() for member in members]) else: for member in members: - self.outf.write(f"{member.dn}\n") + print(member.dn, file=self.outf) class cmd_domain_auth_silo_member_remove(Command): @@ -174,7 +181,14 @@ class cmd_domain_auth_silo_member_remove(Command): except ModelError as e: raise CommandError(e) - self.outf.write(f"User {user} removed from the authentication silo {name}.\n") + # Display silo assigned status. + if user.assigned_silo and user.assigned_silo == silo.dn: + status = "assigned" + else: + status = "unassigned" + + print(f"User {user} removed from the authentication silo {name} ({status}).", + file=self.outf) class cmd_domain_auth_silo_member(SuperCommand): diff --git a/python/samba/tests/samba_tool/domain_auth_silo.py b/python/samba/tests/samba_tool/domain_auth_silo.py index 69a3d441680..75f5e0b7e01 100644 --- a/python/samba/tests/samba_tool/domain_auth_silo.py +++ b/python/samba/tests/samba_tool/domain_auth_silo.py @@ -603,7 +603,8 @@ class AuthSiloMemberCmdTestCase(BaseAuthCmdTest): self.assertIsNone(result, msg=err) self.assertIn( - f"User {name} added to the authentication silo {silo}.", out) + f"User {name}$ added to the authentication silo {silo} (unassigned).", + out) def test_member_add__unknown_user(self): """Test adding an unknown user to an authentication silo."""