Skip to content

Commit

Permalink
who_can_write_can_read raises even if user (write) is in role (read)
Browse files Browse the repository at this point in the history
  • Loading branch information
jirik committed Dec 20, 2023
1 parent 3d56a3c commit e14e005
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/layman/common/prime_db_schema/publications_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,19 @@ class TestWhoCanWriteCanRead:
role1 = 'test_who_can_write_can_read_role1'
role2 = 'test_who_can_write_can_read_role2'

@pytest.fixture(scope="class", autouse=True)
def provide_data(self, request):
with app.app_context():
ensure_user(self.username, '13')
ensure_role(self.role1)
ensure_user_role(self.username, self.role1)
yield
if request.node.session.testsfailed == 0:
with app.app_context():
delete_user_role(self.username, self.role1)
delete_role(self.role1)
users.delete_user(self.username)

@pytest.mark.parametrize("can_read, can_write", [
pytest.param(set(), set(), id='read-empty-write-empty'),
pytest.param({username}, {username}, id='read-user-write-user'),
Expand All @@ -153,6 +166,7 @@ def test_ok(self, can_read, can_write):
pytest.param({username}, {settings.RIGHTS_EVERYONE_ROLE}, id='read-user-write-everyone'),
pytest.param({username}, {username2}, id='read-user-write-user2'),
pytest.param({username}, {role1}, id='read-user-write-role'),
pytest.param({role1}, {username}, id='read-role-write-user'),
pytest.param({role1}, {role2}, id='read-role1-write-role2'),
pytest.param({role1}, {settings.RIGHTS_EVERYONE_ROLE}, id='read-role1-write-everyone'),
])
Expand Down

0 comments on commit e14e005

Please sign in to comment.