mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-10-25 22:50:12 -05:00
ipatests: make TestDuplicates teardowns order agnostic
Fixtures 'user4' and 'user5' track the same actual user 'tuser'. If used together their teardowns can fail depending on the order of execution. With this change fixtures of TestDuplicates are simplified and method-scoped. Related: https://pagure.io/freeipa/issue/9571 Signed-off-by: Stanislav Levin <slev@altlinux.org> Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
This commit is contained in:
1 parent
97718f688c
commit
18d550a336
1 file changed
+28
-48
@@ -120,12 +120,6 @@ def stageduser3(request, xmlrpc_setup):
|
||||
return tracker.make_fixture_activate(request)
|
||||
|
||||
|
||||
@pytest.fixture(scope='class')
|
||||
def stageduser4(request, xmlrpc_setup):
|
||||
tracker = StageUserTracker(u'tuser', u'test', u'user')
|
||||
return tracker.make_fixture(request)
|
||||
|
||||
|
||||
@pytest.fixture(scope='class')
|
||||
def stageduser_notposix(request, xmlrpc_setup):
|
||||
tracker = StageUserTracker(u'notposix', u'notposix', u'notposix')
|
||||
@@ -161,18 +155,6 @@ def user3(request, xmlrpc_setup):
|
||||
return tracker.make_fixture(request)
|
||||
|
||||
|
||||
@pytest.fixture(scope='class')
|
||||
def user4(request, xmlrpc_setup):
|
||||
tracker = UserTracker(u'tuser', u'test', u'user')
|
||||
return tracker.make_fixture(request)
|
||||
|
||||
|
||||
@pytest.fixture(scope='class')
|
||||
def user5(request, xmlrpc_setup):
|
||||
tracker = UserTracker(u'tuser', u'test', u'user')
|
||||
return tracker.make_fixture(request)
|
||||
|
||||
|
||||
@pytest.fixture(scope='class')
|
||||
def user6(request, xmlrpc_setup):
|
||||
tracker = UserTracker(u'suser2', u'staged', u'user')
|
||||
@@ -724,52 +706,50 @@ class TestManagers(XMLRPC_test):
|
||||
|
||||
@pytest.mark.tier1
|
||||
class TestDuplicates(XMLRPC_test):
|
||||
def test_active_same_as_preserved(self, user4, user5):
|
||||
user4.ensure_missing()
|
||||
user5.make_preserved_user()
|
||||
command = user4.make_create_command()
|
||||
@pytest.fixture
|
||||
def user(self, request, xmlrpc_setup):
|
||||
tracker = UserTracker("tuser", "test", "user")
|
||||
return tracker.make_fixture(request)
|
||||
|
||||
@pytest.fixture
|
||||
def stageduser(self, request, xmlrpc_setup):
|
||||
tracker = StageUserTracker("tuser", "test", "user")
|
||||
return tracker.make_fixture(request)
|
||||
|
||||
def test_active_same_as_preserved(self, user):
|
||||
user.make_preserved_user()
|
||||
command = user.make_create_command()
|
||||
with raises_exact(errors.DuplicateEntry(
|
||||
message=u'user with name "%s" already exists' % user4.uid)):
|
||||
message=u'user with name "%s" already exists' % user.uid)):
|
||||
command()
|
||||
user5.delete()
|
||||
|
||||
def test_staged_same_as_active(self, user4, stageduser4):
|
||||
user4.ensure_exists()
|
||||
stageduser4.create() # can be created
|
||||
def test_staged_same_as_active(self, user, stageduser):
|
||||
user.create()
|
||||
stageduser.create() # can be created
|
||||
|
||||
command = stageduser4.make_activate_command()
|
||||
command = stageduser.make_activate_command()
|
||||
with raises_exact(errors.DuplicateEntry(
|
||||
message=u'active user with name "%s" already exists' %
|
||||
user4.uid)):
|
||||
user.uid)):
|
||||
command() # cannot be activated
|
||||
|
||||
user4.delete()
|
||||
stageduser4.delete()
|
||||
def test_staged_same_as_preserved(self, user, stageduser):
|
||||
user.make_preserved_user()
|
||||
stageduser.create() # can be created
|
||||
|
||||
def test_staged_same_as_preserved(self, user5, stageduser4):
|
||||
user5.make_preserved_user()
|
||||
stageduser4.create() # can be created
|
||||
|
||||
command = stageduser4.make_activate_command()
|
||||
command = stageduser.make_activate_command()
|
||||
with raises_exact(errors.DuplicateEntry(
|
||||
message=u'This entry already exists')):
|
||||
command() # cannot be activated
|
||||
|
||||
user5.delete()
|
||||
stageduser4.delete()
|
||||
def test_active_same_as_staged(self, user, stageduser):
|
||||
stageduser.create()
|
||||
user.create() # can be created
|
||||
|
||||
def test_active_same_as_staged(self, user4, stageduser4):
|
||||
user4.ensure_missing()
|
||||
stageduser4.ensure_exists()
|
||||
command = user4.make_create_command()
|
||||
result = command()
|
||||
user4.track_create()
|
||||
user4.check_create(result) # can be created
|
||||
|
||||
command = stageduser4.make_activate_command()
|
||||
command = stageduser.make_activate_command()
|
||||
with raises_exact(errors.DuplicateEntry(
|
||||
message=u'active user with name "%s" already exists' %
|
||||
user4.uid)):
|
||||
user.uid)):
|
||||
command() # cannot be activated
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user