summaryrefslogtreecommitdiff
path: root/python/samba
diff options
context:
space:
mode:
authorRob van der Linde <rob@catalyst.net.nz>2023-05-16 12:33:50 +1200
committerAndrew Bartlett <abartlet@samba.org>2023-06-25 23:29:32 +0000
commit7e9d807201637b1ac898f44ef3220f2feb5ac51d (patch)
tree54ca1f0da5e542d9cd11ee1bf02c2e57dc59ea9e /python/samba
parent9911a81cc21c928825ade11723977a139b80432b (diff)
downloadsamba-7e9d807201637b1ac898f44ef3220f2feb5ac51d.tar.gz
samba-7e9d807201637b1ac898f44ef3220f2feb5ac51d.tar.bz2
samba-7e9d807201637b1ac898f44ef3220f2feb5ac51d.zip
netcmd: domain: fix attributes created by test setUp method
Discovered this while converting the claims cli commands to use the models, some tests failed. The reason for this was that they relied on the attributes in the list ATTRIBUTES to exist. However, then we have to also prefix the attributes we create in the test_claim_type_create test. Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Diffstat (limited to 'python/samba')
-rw-r--r--python/samba/tests/samba_tool/domain_claim.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/python/samba/tests/samba_tool/domain_claim.py b/python/samba/tests/samba_tool/domain_claim.py
index 1cc267ce0c6..57b2889bf3d 100644
--- a/python/samba/tests/samba_tool/domain_claim.py
+++ b/python/samba/tests/samba_tool/domain_claim.py
@@ -70,10 +70,13 @@ class ClaimCmdTestCase(SambaToolCmdTest):
self.host = "ldap://{DC_SERVER}".format(**os.environ)
self.creds = "-U{DC_USERNAME}%{DC_PASSWORD}".format(**os.environ)
self.samdb = self.getSamDB("-H", self.host, self.creds)
-
- # Generate some known claim types.
- # Use unique names that aren't in the ATTRIBUTES list.
self.claim_types = []
+
+ # Generate some known claim types used by tests.
+ for attribute in ATTRIBUTES:
+ self.create_claim_type(attribute, classes=["user"])
+
+ # Generate some more with unique names not in the ATTRIBUTES list.
self.create_claim_type("accountExpires", name="expires",
classes=["user"])
self.create_claim_type("department", name="dept", classes=["user"],
@@ -220,14 +223,19 @@ class ClaimCmdTestCase(SambaToolCmdTest):
"""
# Each known attribute must be in the schema.
for attribute in ATTRIBUTES:
+ # Use a different name, so we don't clash with existing attributes.
+ name = "test_create_" + attribute
+
result, out, err = self.runcmd("domain", "claim", "claim-type",
- "create", f"--attribute={attribute}",
+ "create",
+ "--attribute", attribute,
+ "--name", name,
"--class=user")
self.assertIsNone(result, msg=err)
# It should have used the attribute name as displayName.
- claim_type = self.get_claim_type(attribute)
- self.assertEqual(str(claim_type["displayName"]), attribute)
+ claim_type = self.get_claim_type(name)
+ self.assertEqual(str(claim_type["displayName"]), name)
self.assertEqual(str(claim_type["Enabled"]), "TRUE")
self.assertEqual(str(claim_type["objectClass"][-1]), "msDS-ClaimType")
self.assertEqual(str(claim_type["msDS-ClaimSourceType"]), "AD")