Skip to content

Commit

Permalink
Move *_collection actions to Collection
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkkul committed Nov 13, 2024
1 parent 8a7b873 commit 4994f77
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
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.database(
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
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

0 comments on commit 4994f77

Please sign in to comment.