mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
netcmd: tests: test that create objects make use of addCleanup
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>
This commit is contained in:
parent
91fa5088b5
commit
f1d5f93f3d
@ -93,6 +93,9 @@ class AuthPolicyCmdTestCase(BaseAuthCmdTest):
|
||||
|
||||
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)
|
||||
@ -104,6 +107,9 @@ class AuthPolicyCmdTestCase(BaseAuthCmdTest):
|
||||
|
||||
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")
|
||||
@ -119,6 +125,9 @@ class AuthPolicyCmdTestCase(BaseAuthCmdTest):
|
||||
|
||||
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")
|
||||
@ -152,6 +161,9 @@ class AuthPolicyCmdTestCase(BaseAuthCmdTest):
|
||||
|
||||
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")
|
||||
@ -185,6 +197,9 @@ class AuthPolicyCmdTestCase(BaseAuthCmdTest):
|
||||
|
||||
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")
|
||||
|
@ -91,6 +91,9 @@ class AuthSiloCmdTestCase(BaseAuthCmdTest):
|
||||
|
||||
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")
|
||||
@ -106,6 +109,9 @@ class AuthSiloCmdTestCase(BaseAuthCmdTest):
|
||||
|
||||
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",
|
||||
@ -125,6 +131,9 @@ class AuthSiloCmdTestCase(BaseAuthCmdTest):
|
||||
"""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"])
|
||||
@ -155,6 +164,9 @@ class AuthSiloCmdTestCase(BaseAuthCmdTest):
|
||||
|
||||
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",
|
||||
@ -167,6 +179,9 @@ class AuthSiloCmdTestCase(BaseAuthCmdTest):
|
||||
|
||||
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",
|
||||
|
@ -224,6 +224,8 @@ class ClaimCmdTestCase(SambaToolCmdTest):
|
||||
# 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,
|
||||
@ -240,6 +242,8 @@ class ClaimCmdTestCase(SambaToolCmdTest):
|
||||
|
||||
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")
|
||||
@ -251,6 +255,8 @@ class ClaimCmdTestCase(SambaToolCmdTest):
|
||||
|
||||
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")
|
||||
@ -262,6 +268,8 @@ class ClaimCmdTestCase(SambaToolCmdTest):
|
||||
|
||||
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")
|
||||
@ -273,6 +281,8 @@ class ClaimCmdTestCase(SambaToolCmdTest):
|
||||
|
||||
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",
|
||||
@ -285,6 +295,8 @@ class ClaimCmdTestCase(SambaToolCmdTest):
|
||||
|
||||
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",
|
||||
@ -306,6 +318,7 @@ class ClaimCmdTestCase(SambaToolCmdTest):
|
||||
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")
|
||||
@ -318,6 +331,7 @@ class ClaimCmdTestCase(SambaToolCmdTest):
|
||||
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")
|
||||
@ -330,6 +344,8 @@ class ClaimCmdTestCase(SambaToolCmdTest):
|
||||
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",
|
||||
|
Loading…
Reference in New Issue
Block a user