tests: Fix intermittent error in PSO test
authorTim Beale <timbeale@catalyst.net.nz>
Mon, 28 May 2018 22:46:50 +0000 (10:46 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 30 May 2018 02:23:27 +0000 (04:23 +0200)
Deleting a group fails if the primaryGroupID of a user is set to that of
the group. This can happen in the PSO tests, as we don't clear the
primaryGroupID before cleaning up. Normally it seems to work OK, but
this is relying purely on the subtree delete order.

Update the test to clear the primaryGroupID before the tearDown is
called, to make things more robust.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13448

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
source4/dsdb/tests/python/password_settings.py

index a5de7ff..71ab74e 100644 (file)
@@ -565,6 +565,9 @@ class PasswordSettingsTestCase(PasswordTestCase):
         admin_pso.apply_to(admin_users)
         self.assert_PSO_applied(user, admin_pso)
 
+        # restore the default primaryGroupID so we can safely delete the group
+        user.set_primary_group(domain_users)
+
     def test_pso_none_applied(self):
         """Tests cases where no Resultant PSO should be returned"""