]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
python:tests: Take INTERDOMAIN_TRUST into account
authorAndreas Schneider <asn@samba.org>
Tue, 11 Nov 2025 06:26:16 +0000 (07:26 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 14 Nov 2025 19:23:38 +0000 (19:23 +0000)
If we run e.g. fl2008rc2 env before we run this test, we have a trust account
for this domain.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Nov 14 19:23:38 UTC 2025 on atb-devel-224

python/samba/tests/samba_tool/domain_models.py

index f503e44ef883d51f44db3537072669632b2bd89e..527fab01d5eb36369bf216d18948ce0190ef7750 100644 (file)
@@ -76,33 +76,43 @@ class ModelTests(SambaToolCmdTest):
             User.query(self.samdb, account_type=AccountType.NORMAL_ACCOUNT)
         )
         humans = len(humans_list)
+        trusts_list = list(
+            User.query(self.samdb, account_type=AccountType.INTERDOMAIN_TRUST)
+        )
+        trusts = len(trusts_list)
 
         # Debug output
         print("\n=== Debug Output for test_query_filter_enum ===")
         print(f"Total users: {robots_vs_humans}")
         print(f"Robots (WORKSTATION_TRUST): {robots}")
         print(f"Humans (NORMAL_ACCOUNT): {humans}")
-        print(f"Sum (robots + humans): {robots + humans}")
-        print(f"Difference: {robots_vs_humans - (robots + humans)}")
+        print(f"Trusts (INTERDOMAIN_TRUST): {trusts}")
+        print(f"Sum (robots + humans + trusts): {robots + humans + trusts}")
+        print(f"Difference: {robots_vs_humans - (robots + humans + trusts)}")
 
         # Find users that are neither robots nor humans
         robots_dns = {str(user.dn) for user in robots_list}
         humans_dns = {str(user.dn) for user in humans_list}
+        trust_dns = {str(user.dn) for user in trusts_list}
         all_dns = {str(user.dn) for user in all_users}
-        other_dns = all_dns - robots_dns - humans_dns
+        other_dns = all_dns - robots_dns - humans_dns - trust_dns
 
         if other_dns:
-            print(f"\nUsers that are neither WORKSTATION_TRUST nor NORMAL_ACCOUNT ({len(other_dns)}):")
+            print(f"\nUsers that are neither WORKSTATION_TRUST nor "
+                  f"NORMAL_ACCOUNT nor INTERDOMAIN_TRUST ({len(other_dns)}):")
             for user in all_users:
                 if str(user.dn) in other_dns:
                     account_type_value = user.account_type
-                    print(f"  - {user.account_name}: account_type={account_type_value}")
+                    print(f"  - {user.account_name}: "
+                          f"account_type={account_type_value}")
 
         print("=== End Debug Output ===\n")
 
         self.assertNotEqual(robots, 0)
         self.assertNotEqual(humans, 0)
-        self.assertEqual(robots + humans, robots_vs_humans)
+        # If we have domain trusts or not, depends if we have setup
+        # environments with domain trusts before.
+        self.assertEqual(robots + humans + trusts, robots_vs_humans)
 
     def test_as_dict(self):
         """Test the as_dict method for serializing to dict then JSON."""