Since the samdb connection is on the class and hangs around between tests, we need to clean up what we created.
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>
def test_authentication_policy_create(self):
"""Test creating a new authentication policy."""
+ self.addCleanup(self.delete_authentication_policy,
+ name="createTest", force=True)
+
result, out, err = self.runcmd("domain", "auth", "policy", "create",
"--name", "createTest")
self.assertIsNone(result, msg=err)
def test_authentication_policy_create_description(self):
"""Test creating a new authentication policy with description set."""
+ self.addCleanup(self.delete_authentication_policy,
+ name="descriptionTest", force=True)
+
result, out, err = self.runcmd("domain", "auth", "policy", "create",
"--name", "descriptionTest",
"--description", "Custom Description")
Also checks the upper and lower bounds are handled.
"""
+ self.addCleanup(self.delete_authentication_policy,
+ name="userTGTLifetime", force=True)
+
result, out, err = self.runcmd("domain", "auth", "policy", "create",
"--name", "userTGTLifetime",
"--user-tgt-lifetime", "60")
Also checks the upper and lower bounds are handled.
"""
+ self.addCleanup(self.delete_authentication_policy,
+ name="serviceTGTLifetime", force=True)
+
result, out, err = self.runcmd("domain", "auth", "policy", "create",
"--name", "serviceTGTLifetime",
"--service-tgt-lifetime", "60")
Also checks the upper and lower bounds are handled.
"""
+ self.addCleanup(self.delete_authentication_policy,
+ name="computerTGTLifetime", force=True)
+
result, out, err = self.runcmd("domain", "auth", "policy", "create",
"--name", "computerTGTLifetime",
"--computer-tgt-lifetime", "60")
def test_authentication_silo_create_single_policy(self):
"""Test creating a new authentication silo with a single policy."""
+ self.addCleanup(self.delete_authentication_silo,
+ name="singlePolicy", force=True)
+
result, out, err = self.runcmd("domain", "auth", "silo", "create",
"--name", "singlePolicy",
"--policy", "Single Policy")
def test_authentication_silo_create_multiple_policies(self):
"""Test creating a new authentication silo with multiple policies."""
+ self.addCleanup(self.delete_authentication_silo,
+ name="multiplePolicies", force=True)
+
result, out, err = self.runcmd("domain", "auth", "silo", "create",
"--name", "multiplePolicies",
"--user-policy", "User Policy",
"""Test creating a new authentication silo when policy is a dn."""
policy = self.get_authentication_policy("Single Policy")
+ self.addCleanup(self.delete_authentication_silo,
+ name="singlePolicyDN", force=True)
+
result, out, err = self.runcmd("domain", "auth", "silo", "create",
"--name", "singlePolicyDN",
"--policy", policy["dn"])
def test_authentication_silo_create_audit(self):
"""Test create authentication silo with --audit flag."""
+ self.addCleanup(self.delete_authentication_silo,
+ name="auditPolicies", force=True)
+
result, out, err = self.runcmd("domain", "auth", "silo", "create",
"--name", "auditPolicies",
"--policy", "Single Policy",
def test_authentication_silo_create_enforce(self):
"""Test create authentication silo with --enforce flag."""
+ self.addCleanup(self.delete_authentication_silo,
+ name="enforcePolicies", force=True)
+
result, out, err = self.runcmd("domain", "auth", "silo", "create",
"--name", "enforcePolicies",
"--policy", "Single Policy",
# Use a different name, so we don't clash with existing attributes.
name = "test_create_" + attribute
+ self.addCleanup(self.delete_claim_type, name=name, force=True)
+
result, out, err = self.runcmd("domain", "claim", "claim-type",
"create",
"--attribute", attribute,
def test_claim_type_create_boolean(self):
"""Test adding a known boolean attribute and check its type."""
+ self.addCleanup(self.delete_claim_type, name="boolAttr", force=True)
+
result, out, err = self.runcmd("domain", "claim", "claim-type",
"create", "--attribute=msNPAllowDialin",
"--name=boolAttr", "--class=user")
def test_claim_type_create_number(self):
"""Test adding a known numeric attribute and check its type."""
+ self.addCleanup(self.delete_claim_type, name="intAttr", force=True)
+
result, out, err = self.runcmd("domain", "claim", "claim-type",
"create", "--attribute=adminCount",
"--name=intAttr", "--class=user")
def test_claim_type_create_text(self):
"""Test adding a known text attribute and check its type."""
+ self.addCleanup(self.delete_claim_type, name="textAttr", force=True)
+
result, out, err = self.runcmd("domain", "claim", "claim-type",
"create", "--attribute=givenName",
"--name=textAttr", "--class=user")
def test_claim_type_create_disabled(self):
"""Test adding a disabled attribute."""
+ self.addCleanup(self.delete_claim_type, name="home", force=True)
+
result, out, err = self.runcmd("domain", "claim", "claim-type",
"create", "--attribute=msTSHomeDrive",
"--name=home", "--class=user",
def test_claim_type_create_protected(self):
"""Test adding a protected attribute."""
+ self.addCleanup(self.delete_claim_type, name="cellphone", force=True)
+
result, out, err = self.runcmd("domain", "claim", "claim-type",
"create", "--attribute=mobile",
"--name=cellphone", "--class=user",
computer_dn = f"CN=Computer,{schema_dn}"
# --class=user
+ self.addCleanup(self.delete_claim_type, name="streetName", force=True)
result, out, err = self.runcmd("domain", "claim", "claim-type",
"create", "--attribute=street",
"--name=streetName", "--class=user")
self.assertNotIn(computer_dn, applies_to)
# --class=computer
+ self.addCleanup(self.delete_claim_type, name="ext", force=True)
result, out, err = self.runcmd("domain", "claim", "claim-type",
"create", "--attribute=extensionName",
"--name=ext", "--class=computer")
self.assertIn(computer_dn, applies_to)
# --class=user --class=computer
+ self.addCleanup(self.delete_claim_type,
+ name="primaryComputer", force=True)
result, out, err = self.runcmd("domain", "claim", "claim-type",
"create", "--attribute=msDS-PrimaryComputer",
"--name=primaryComputer", "--class=user",