]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
netcmd: silo member: Make output consistent with user command
authorRob van der Linde <rob@catalyst.net.nz>
Tue, 7 Nov 2023 05:45:30 +0000 (18:45 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 15 Nov 2023 04:05:34 +0000 (04:05 +0000)
 * Use print with file=self.outf
 * Show assigned or unassigned silo

Signed-off-by: Rob van der Linde <rob@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/netcmd/domain/auth/silo_member.py
python/samba/tests/samba_tool/domain_auth_silo.py

index f9ec2686cf19a29cf0d9fd6f33da5fbbb2e56042..af5fbc0913bee87869ccead4b747f74a73309d3e 100644 (file)
@@ -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):
index 69a3d4416802cd5844b67652011b83b525616879..75f5e0b7e0155cbfbe1e56fa4cf95a4caae5128a 100644 (file)
@@ -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."""