From: Andrew Bartlett Date: Wed, 21 Feb 2024 01:29:44 +0000 (+1300) Subject: python/tests: Use TestCaseInTempDir rather than "private dir" for exported keytab X-Git-Tag: tdb-1.4.11~1683 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=69c3044a7265c83d053b2690de772eb4ff9d86ca;p=thirdparty%2Fsamba.git python/tests: Use TestCaseInTempDir rather than "private dir" for exported keytab Signed-off-by: Andrew Bartlett Reviewed-by: Jo Sutton --- diff --git a/python/samba/tests/dckeytab.py b/python/samba/tests/dckeytab.py index 2e6fb482637..1cc51bdd432 100644 --- a/python/samba/tests/dckeytab.py +++ b/python/samba/tests/dckeytab.py @@ -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