From: Andrew Bartlett Date: Tue, 9 Apr 2024 21:53:00 +0000 (+1200) Subject: python/samba/tests: Fix gMSA blackbox test to expect failure to get password after... X-Git-Tag: tdb-1.4.11~1234 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=005ce15aab35bb0981e694cc12580cf31b135b0a;p=thirdparty%2Fsamba.git python/samba/tests: Fix gMSA blackbox test to expect failure to get password after membership change Signed-off-by: Andrew Bartlett Reviewed-by: Douglas Bagnall --- diff --git a/python/samba/tests/blackbox/gmsa.py b/python/samba/tests/blackbox/gmsa.py index 830585d5ab5..1017f75de6b 100644 --- a/python/samba/tests/blackbox/gmsa.py +++ b/python/samba/tests/blackbox/gmsa.py @@ -62,7 +62,8 @@ class GMSABlackboxTest(BlackboxTestCase): # check each attr is returned for attr in attrs.split(","): - self.assertIn(attr, user_message) + if attr not in user_message: + raise KeyError return user_message @@ -85,15 +86,18 @@ class GMSABlackboxTest(BlackboxTestCase): # Grant password read access to the machine account. self.check_run(f"samba-tool service-account group-msa-membership add --name={gmsa_account} --principal={machine_account} -H {HOST} {ADMIN_CREDS}") - self.getpassword(gmsa_account, "unicodePwd", creds=machine_creds) + try: + self.getpassword(gmsa_account, "unicodePwd", creds=machine_creds) + except KeyError: + self.fail("Failed to get unicodePwd despite being in the gMSA membership") # Remove password read access from the machine account and verify. self.check_run(f"samba-tool service-account group-msa-membership remove --name={gmsa_account} --principal={machine_account} -H {HOST} {ADMIN_CREDS}") try: - self.getpassword(gmsa_account, "unicodePwd", creds=machine_creds) + self.assertRaises(KeyError, self.getpassword(gmsa_account, "unicodePwd", creds=machine_creds)) except BlackboxProcessError: - self.fail("Unexpected failure retrieving unicodePwd") + self.fail("Unexpected subcommand failure retrieving unicodePwd") def test_gmsa_add_sid_only_viewer(self): """Add unknown SID to password viewers and check group-msa-membership show output."""