1
0
mirror of https://github.com/samba-team/samba.git synced 2025-12-18 08:23:51 +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:
Rob van der Linde
2023-09-28 14:48:09 +13:00
committed by Andrew Bartlett
parent 91fa5088b5
commit f1d5f93f3d
3 changed files with 46 additions and 0 deletions

View File

@@ -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")