Skip to content

Commit

Permalink
Do not pass unnecessary arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed Sep 18, 2024
1 parent ef5889d commit 9daa07c
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions test/unit/data/model/db/test_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_private_user_role_assoc_not_affected_by_setting_user_roles(session, mak
assert user.email != private_role.name

# Delete user roles
GalaxyRBACAgent(session).set_user_group_and_role_associations(user, group_ids=[], role_ids=[])
GalaxyRBACAgent(session).set_user_group_and_role_associations(user, role_ids=[])
# association with private role is preserved
verify_user_associations(user, [], [private_role])

Expand All @@ -59,7 +59,7 @@ def test_private_user_role_assoc_not_affected_by_setting_role_users(session, mak
assert user.email != private_role.name

# Update role users
GalaxyRBACAgent(session).set_role_user_and_group_associations(private_role, user_ids=[], group_ids=[])
GalaxyRBACAgent(session).set_role_user_and_group_associations(private_role, user_ids=[])
# association of private role with user is preserved
verify_role_associations(private_role, [user], [])

Expand All @@ -71,9 +71,7 @@ def test_cannot_assign_private_roles(session, make_user_and_role, make_role):
verify_user_associations(user, [], [private_role1]) # the only existing association is with the private role

# Try to assign 2 more roles: regular role + another private role
GalaxyRBACAgent(session).set_user_group_and_role_associations(
user, group_ids=[], role_ids=[new_role.id, private_role2.id]
)
GalaxyRBACAgent(session).set_user_group_and_role_associations(user, role_ids=[new_role.id, private_role2.id])
# Only regular role has been added: other private role ignored; original private role still assigned
verify_user_associations(user, [], [private_role1, new_role])

Expand Down Expand Up @@ -219,7 +217,7 @@ def test_invalid_user(self, session, make_user_and_role, make_role, make_group):

# try to set associations
with pytest.raises(RequestParameterInvalidException):
GalaxyRBACAgent(session).set_group_user_and_role_associations(group, user_ids=user_ids, role_ids=[])
GalaxyRBACAgent(session).set_group_user_and_role_associations(group, user_ids=user_ids)

# verify no change
assert len(group.users) == 0
Expand All @@ -241,7 +239,7 @@ def test_invalid_role(self, session, make_role, make_group):

# try to set associations
with pytest.raises(RequestParameterInvalidException):
GalaxyRBACAgent(session).set_group_user_and_role_associations(group, user_ids=[], role_ids=role_ids)
GalaxyRBACAgent(session).set_group_user_and_role_associations(group, role_ids=role_ids)

# verify no change
assert len(group.roles) == 0
Expand Down Expand Up @@ -483,7 +481,7 @@ def test_invalid_group(self, session, make_user_and_role, make_group):

# try to set associations
with pytest.raises(RequestParameterInvalidException):
GalaxyRBACAgent(session).set_user_group_and_role_associations(user, group_ids=group_ids, role_ids=[])
GalaxyRBACAgent(session).set_user_group_and_role_associations(user, group_ids=group_ids)

# verify no change
assert len(user.groups) == 0
Expand All @@ -505,7 +503,7 @@ def test_invalid_role(self, session, make_user_and_role, make_role):

# try to set associations
with pytest.raises(RequestParameterInvalidException):
GalaxyRBACAgent(session).set_user_group_and_role_associations(user, group_ids=[], role_ids=role_ids)
GalaxyRBACAgent(session).set_user_group_and_role_associations(user, role_ids=role_ids)

# verify no change
assert len(user.roles) == 1 # one is the private role association
Expand Down Expand Up @@ -743,7 +741,7 @@ def test_invalid_user(self, session, make_role, make_user_and_role):

# try to set associations
with pytest.raises(RequestParameterInvalidException):
GalaxyRBACAgent(session).set_role_user_and_group_associations(role, user_ids=user_ids, group_ids=[])
GalaxyRBACAgent(session).set_role_user_and_group_associations(role, user_ids=user_ids)

# verify no change
assert len(role.users) == 0
Expand All @@ -765,7 +763,7 @@ def test_invalid_group(self, session, make_role, make_group):

# try to set associations
with pytest.raises(RequestParameterInvalidException):
GalaxyRBACAgent(session).set_role_user_and_group_associations(role, user_ids=[], group_ids=group_ids)
GalaxyRBACAgent(session).set_role_user_and_group_associations(role, group_ids=group_ids)

# verify no change
assert len(role.groups) == 0
Expand Down Expand Up @@ -907,7 +905,7 @@ def test_delete_default_user_permissions_and_default_history_permissions(
assert have_same_elements(history3.default_permissions, [dhp3])

# now update role users
GalaxyRBACAgent(session).set_role_user_and_group_associations(role, user_ids=user_ids, group_ids=[])
GalaxyRBACAgent(session).set_role_user_and_group_associations(role, user_ids=user_ids)

# verify user role associations
verify_role_associations(role, new_users_to_add, [])
Expand Down

0 comments on commit 9daa07c

Please sign in to comment.