Skip to content

Commit

Permalink
Use briefer name; rely on namespace to distinguish.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielballan committed Dec 13, 2023
1 parent 0c99d76 commit 3ce55d7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
16 changes: 4 additions & 12 deletions tiled/_tests/test_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,7 @@ def test_admin_api_key_any_principal(
context.authenticate(username="alice")

principal_uuid = principals_context["uuid"][username]
api_key_info = context.admin.create_api_key_other_principal(
principal_uuid, scopes=scopes
)
api_key_info = context.admin.create_api_key(principal_uuid, scopes=scopes)
api_key = api_key_info["secret"]
assert api_key
context.logout()
Expand All @@ -568,9 +566,7 @@ def test_admin_create_service_principal(enter_password, principals_context):
principal_info = context.admin.create_service_principal(role="user")
principal_uuid = principal_info["uuid"]

service_api_key_info = context.admin.create_api_key_other_principal(
principal_uuid
)
service_api_key_info = context.admin.create_api_key(principal_uuid)
context.logout()

context.api_key = service_api_key_info["secret"]
Expand All @@ -588,9 +584,7 @@ def test_admin_api_key_any_principal_exceeds_scopes(enter_password, principals_c

principal_uuid = principals_context["uuid"]["bob"]
with fail_with_status_code(400) as fail_info:
context.admin.create_api_key_other_principal(
principal_uuid, scopes=["read:principals"]
)
context.admin.create_api_key(principal_uuid, scopes=["read:principals"])
fail_message = " must be a subset of the principal's scopes "
assert fail_message in fail_info.value.response.text
context.logout()
Expand All @@ -608,9 +602,7 @@ def test_api_key_any_principal(enter_password, principals_context, username):

principal_uuid = principals_context["uuid"][username]
with fail_with_status_code(401):
context.admin.create_api_key_other_principal(
principal_uuid, scopes=["read:metadata"]
)
context.admin.create_api_key(principal_uuid, scopes=["read:metadata"])


def test_api_key_bypass_scopes(enter_password, principals_context):
Expand Down
4 changes: 1 addition & 3 deletions tiled/client/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,9 +765,7 @@ def show_principal(self, uuid):
self.context.http_client.get(f"{self.base_url}/auth/principal/{uuid}")
).json()

def create_api_key_other_principal(
self, uuid, scopes=None, expires_in=None, note=None
):
def create_api_key(self, uuid, scopes=None, expires_in=None, note=None):
"""
Generate a new API key for another user or service.
Expand Down

0 comments on commit 3ce55d7

Please sign in to comment.