Skip to content

Commit

Permalink
fix(workspaces): superuser with empty workspace (#1288)
Browse files Browse the repository at this point in the history
  • Loading branch information
frascuchon committed Mar 22, 2022
1 parent cd2b5c9 commit 4b1ab45
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/rubrix/server/security/model.py
Expand Up @@ -85,8 +85,10 @@ def check_workspace(self, workspace: str) -> str:
The original workspace name if user belongs to it
"""
if not workspace or workspace == self.default_workspace:
if workspace is None or workspace == self.default_workspace:
return self.default_workspace
if not workspace and self.is_superuser():
return workspace
if workspace not in (self.workspaces or []):
raise EntityNotFoundError(name=workspace, type="Workspace")
return workspace
Expand Down
3 changes: 3 additions & 0 deletions tests/server/security/test_model.py
Expand Up @@ -72,6 +72,9 @@ def test_workspace_for_superuser():
with pytest.raises(EntityNotFoundError):
assert user.check_workspace("some") == "some"

assert user.check_workspace(None) == "admin"
assert user.check_workspace("") == ""

user.workspaces = ["some"]
assert user.check_workspaces(["some"]) == ["some"]

Expand Down

0 comments on commit 4b1ab45

Please sign in to comment.