Skip to content

Commit

Permalink
test_role.py tests also write rights and removing roles
Browse files Browse the repository at this point in the history
  • Loading branch information
jirik committed Dec 4, 2023
1 parent 6dbde70 commit fb79710
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions tests/dynamic_data/publications/access_rights/test_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ class PublicationTypes(base_test_classes.PublicationByDefinitionBase):


USERNAME = 'test_access_rights_role_user1'
USERS_AND_ROLES = {USERNAME, 'ROLE1', 'EVERYONE'}
USER_ROLE1_ROLE3_EVERYONE = {USERNAME, 'ROLE1', 'ROLE3', 'EVERYONE'}
USER_ROLE1 = {USERNAME, 'ROLE1'}
USER_ROLE1_ROLE2 = {USERNAME, 'ROLE1', 'ROLE2'}


@pytest.mark.usefixtures('oauth2_provider_mock')
Expand All @@ -38,14 +40,29 @@ class TestPublication(base_test.TestSingleRestPublication):
None),
rest_args={
'access_rights': {
'read': ','.join(USERS_AND_ROLES),
'read': ','.join(USER_ROLE1_ROLE2),
'write': ','.join(USER_ROLE1),
},
'actor_name': USERNAME,
},
post_before_test_args={
'access_rights': {
'read': ','.join(USER_ROLE1_ROLE3_EVERYONE),
}
},
type=EnumTestTypes.MANDATORY,
)]

def test_publication(self, publication, rest_method, rest_args):
if rest_method.enum_item == base_test_classes.RestMethod.PATCH:
info = process_client.get_workspace_publication(publication.type, publication.workspace, publication.name)
assert set(info['access_rights']['read']) == USER_ROLE1_ROLE3_EVERYONE
assert set(info['access_rights']['write']) == {'EVERYONE'}

rest_method.fn(publication, args=rest_args)
assert_util.is_publication_valid_and_complete(publication)
info = process_client.get_workspace_publication(publication.type, publication.workspace, publication.name)
assert set(info['access_rights']['read']) == USERS_AND_ROLES

info = process_client.get_workspace_publication(publication.type, publication.workspace, publication.name,
actor_name=USERNAME)
assert set(info['access_rights']['read']) == USER_ROLE1_ROLE2
assert set(info['access_rights']['write']) == USER_ROLE1

0 comments on commit fb79710

Please sign in to comment.