Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor actions and permissions factory to align with new server #1411

Merged
merged 5 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions integration/test_rbac.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest

from integration.conftest import ClientFactory
from weaviate.auth import Auth
from weaviate.rbac.models import RBAC
Expand All @@ -12,11 +13,13 @@ def test_create_role(client_factory: ClientFactory) -> None:
pytest.skip("This test requires Weaviate 1.28.0 or higher")
client.roles.create(
name="CollectionCreator",
permissions=RBAC.permissions.database(actions=RBAC.actions.database.CREATE_COLLECTIONS),
permissions=RBAC.permissions.collection(
actions=RBAC.actions.collection.CREATE_COLLECTIONS
),
)
role = client.roles.by_name("CollectionCreator")
assert role is not None
assert role.name == "CollectionCreator"
assert role.database_permissions is not None
assert len(role.database_permissions) == 1
assert role.database_permissions[0] == RBAC.actions.database.CREATE_COLLECTIONS
assert role.database_permissions[0] == RBAC.actions.collection.CREATE_COLLECTIONS
dirkkul marked this conversation as resolved.
Show resolved Hide resolved
10 changes: 5 additions & 5 deletions weaviate/rbac/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ class CollectionsAction(str, _Action, Enum):
UPDATE_TENANTS = "update_tenants"
DELETE_TENANTS = "delete_tenants"

CREATE_COLLECTIONS = "create_collections"
READ_COLLECTIONS = "read_collections"
UPDATE_COLLECTIONS = "update_collections"
DELETE_COLLECTIONS = "delete_collections"

@staticmethod
def values() -> List[str]:
return [action.value for action in CollectionsAction]


class DatabaseAction(str, _Action, Enum):
CREATE_COLLECTIONS = "create_collections"
READ_COLLECTIONS = "read_collections"
UPDATE_COLLECTIONS = "update_collections"
DELETE_COLLECTIONS = "delete_collections"

MANAGE_CLUSTER = "manage_cluster"
MANAGE_ROLES = "manage_roles"
READ_ROLES = "read_roles"
Expand Down
Loading