]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
tests/krb5: Only create testing accounts once per test run
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Thu, 2 Dec 2021 03:50:55 +0000 (16:50 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 6 Dec 2021 22:08:32 +0000 (22:08 +0000)
This decreases the time that the tests take to run.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/tests/krb5/as_canonicalization_tests.py

index 674fcb3710165a9e71b629cb60592a0ef9f7ed2b..7c64ce19bb7503f6e7b6abc3b6ca99045981b036 100755 (executable)
@@ -134,6 +134,12 @@ USER_NAME = "tstkrb5cnnusr"
 @DynamicTestCase
 class KerberosASCanonicalizationTests(KDCBaseTest):
 
+    @classmethod
+    def setUpClass(cls):
+        super().setUpClass()
+        cls.user_creds = None
+        cls.machine_creds = None
+
     @classmethod
     def setUpDynamicTestCases(cls):
 
@@ -164,14 +170,14 @@ class KerberosASCanonicalizationTests(KDCBaseTest):
     def user_account_creds(self):
         if self.user_creds is None:
             samdb = self.get_samdb()
-            self.user_creds, _ = self.create_account(samdb, USER_NAME)
+            type(self).user_creds, _ = self.create_account(samdb, USER_NAME)
 
         return self.user_creds
 
     def machine_account_creds(self):
         if self.machine_creds is None:
             samdb = self.get_samdb()
-            self.machine_creds, _ = self.create_account(
+            type(self).machine_creds, _ = self.create_account(
                 samdb,
                 MACHINE_NAME,
                 account_type=self.AccountType.COMPUTER)
@@ -185,9 +191,6 @@ class KerberosASCanonicalizationTests(KDCBaseTest):
         self.do_asn1_print = global_asn1_print
         self.do_hexdump = global_hexdump
 
-        self.user_creds = None
-        self.machine_creds = None
-
     def _test_with_args(self, x, ct):
         if ct == CredentialsType.User:
             creds = self.user_account_creds()