Skip to content

Commit

Permalink
Upgrade neuro-auth-client (#519)
Browse files Browse the repository at this point in the history
* Upgrade neuro-auth-client

Committed via https://github.com/asottile/all-repos

* fix lint
  • Loading branch information
zubenkoivan authored Dec 14, 2021
1 parent 4dea549 commit 5b39d3c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ install_requires =
aiohttp-remotes==1.1.0
cchardet==2.1.7
iso8601==1.0.2
neuro_auth_client==21.11.0
neuro-auth-client==21.12.0
# uvloop 0.15.x has a bug and doesn't work with AWS registry + Kaniko
# cache: https://github.com/neuro-inc/platform-registry-api/issues/343
# uvloop 0.15.3 definitely has the bug, but upcoming versions may
Expand Down
34 changes: 22 additions & 12 deletions tests/unit/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,12 @@ def test_filter_images_by_project(self) -> None:
]
project = "testproject"
tree = ClientSubTreeViewRoot._from_json(
"job",
{
"action": "list",
"children": {"alice": {"action": "manage", "children": {}}},
"path": "/",
}
},
)
assert list(V2Handler.filter_images_1_indexed(images_names, tree, project)) == [
(1, "alice/img1"),
Expand All @@ -202,11 +203,12 @@ def test_filter_images_by_tree_user_mismatch(self) -> None:
]
project = "testproject"
tree = ClientSubTreeViewRoot._from_json(
"job",
{
"action": "list",
"children": {"alice": {"action": "manage", "children": {}}},
"path": "/",
}
},
)
assert list(V2Handler.filter_images_1_indexed(images_names, tree, project)) == [
(1, "alice/img1"),
Expand All @@ -222,11 +224,12 @@ def test_filter_images_by_tree_superuser(self) -> None:
]
project = "testproject"
tree = ClientSubTreeViewRoot._from_json(
"job",
{
"action": "manage",
"children": {"alice": {"action": "manage", "children": {}}},
"path": "/",
}
},
)
assert list(V2Handler.filter_images_1_indexed(images_names, tree, project)) == [
(1, "alice/img1"),
Expand All @@ -239,11 +242,12 @@ def test_filter_images_no_elements(self) -> None:
images_names: list[str] = []
project = "testproject"
tree = ClientSubTreeViewRoot._from_json(
"job",
{
"action": "list",
"children": {"alice": {"action": "manage", "children": {}}},
"path": "/",
}
},
)
assert (
list(V2Handler.filter_images_1_indexed(images_names, tree, project)) == []
Expand All @@ -269,29 +273,32 @@ def test_default_permissions(self) -> None:
# alice checks her own image "alice/img"
image = "alice/img"
tree = ClientSubTreeViewRoot._from_json(
"job",
{
"action": "list",
"children": {"alice": {"action": "manage", "children": {}}},
"path": "/",
}
},
)
assert check_image_catalog_permission(image, tree) is True

def test_another_user_default_permissions__forbidden(self) -> None:
image = "alice/img"
tree = ClientSubTreeViewRoot._from_json(
"job",
{
"action": "list",
"children": {"bob": {"action": "manage", "children": {}}},
"path": "/",
}
},
)
assert check_image_catalog_permission(image, tree) is False

def test_shared_image_read_permissions(self) -> None:
image = "alice/img"
# tree requested by bob:
tree = ClientSubTreeViewRoot._from_json(
"job",
{
"action": "list",
"children": {
Expand All @@ -302,13 +309,14 @@ def test_shared_image_read_permissions(self) -> None:
},
},
"path": "/",
}
},
)
assert check_image_catalog_permission(image, tree) is True

def test_shared_image_manage_permissions(self) -> None:
image = "alice/img"
tree = ClientSubTreeViewRoot._from_json(
"job",
{
"action": "list",
"children": {
Expand All @@ -319,20 +327,21 @@ def test_shared_image_manage_permissions(self) -> None:
},
},
"path": "/",
}
},
)
assert check_image_catalog_permission(image, tree) is True

def test_shared_image_deny_permissions(self) -> None:
image = "alice/img"
tree = ClientSubTreeViewRoot._from_json(
{"action": "deny", "children": {}, "path": "/"}
"job", {"action": "deny", "children": {}, "path": "/"}
)
assert check_image_catalog_permission(image, tree) is False

def test_shared_image_slashes_in_image_name(self) -> None:
image = "alice/foo/bar/img"
tree = ClientSubTreeViewRoot._from_json(
"job",
{
"action": "list",
"children": {
Expand All @@ -355,13 +364,14 @@ def test_shared_image_slashes_in_image_name(self) -> None:
},
},
"path": "/",
}
},
)
assert check_image_catalog_permission(image, tree) is True

def test_shared_image_parent_read_permissions(self) -> None:
image = "alice/foo/bar/img"
tree = ClientSubTreeViewRoot._from_json(
"job",
{
"action": "list",
"children": {
Expand All @@ -372,14 +382,14 @@ def test_shared_image_parent_read_permissions(self) -> None:
},
},
"path": "/",
}
},
)
assert check_image_catalog_permission(image, tree) is True

def test_shared_image_root_read_permissions(self) -> None:
image = "alice/foo/bar/img"
tree = ClientSubTreeViewRoot._from_json(
{"action": "read", "children": {}, "path": "/"}
"job", {"action": "read", "children": {}, "path": "/"}
)
assert check_image_catalog_permission(image, tree) is True

Expand Down

0 comments on commit 5b39d3c

Please sign in to comment.