]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
python/tests: Use TestCaseInTempDir rather than "private dir" for exported keytab
authorAndrew Bartlett <abartlet@samba.org>
Wed, 21 Feb 2024 01:29:44 +0000 (14:29 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 27 Feb 2024 01:11:37 +0000 (01:11 +0000)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jo Sutton <josutton@catalyst.net.nz>
python/samba/tests/dckeytab.py

index 2e6fb48263733f863e7eaed4aaf865ca96a9800e..1cc51bdd432a1c1708db383dd77ba1a4c87759f9 100644 (file)
@@ -26,22 +26,22 @@ from samba import tests
 from samba.dcerpc import krb5ccache
 from samba.ndr import ndr_unpack
 from samba.param import LoadParm
+from samba.tests import TestCaseInTempDir
 
 enable_net_export_keytab()
 
 
-class DCKeytabTests(tests.TestCase):
+class DCKeytabTests(TestCaseInTempDir):
     def setUp(self):
         super().setUp()
         self.lp = LoadParm()
         self.lp.load_default()
         self.creds = self.insta_creds(template=self.get_credentials())
-        self.ktfile = os.path.join(self.lp.get('private dir'), 'test.keytab')
+        self.ktfile = os.path.join(self.tempdir, 'test.keytab')
         self.principal = self.creds.get_principal()
 
     def tearDown(self):
         super().tearDown()
-        os.remove(self.ktfile)
 
     def test_export_keytab(self):
         net = Net(None, self.lp)
@@ -52,6 +52,8 @@ class DCKeytabTests(tests.TestCase):
         with open(self.ktfile, 'rb') as bytes_kt:
             keytab_bytes = bytes_kt.read()
 
+        self.rm_files('test.keytab')
+
         keytab = ndr_unpack(krb5ccache.KEYTAB, keytab_bytes)
 
         # Confirm that the principal is as expected