From b153faaeee4a73d022757680f2476726f37bb4d4 Mon Sep 17 00:00:00 2001 From: Ben Pearman Date: Fri, 22 Mar 2024 17:38:36 +1300 Subject: [PATCH 1/2] API responds with status code 200 on permissions PUT requests --- koordinates/permissions.py | 4 ++-- tests/test_permissions.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/koordinates/permissions.py b/koordinates/permissions.py index 62dab48..995412b 100644 --- a/koordinates/permissions.py +++ b/koordinates/permissions.py @@ -66,9 +66,9 @@ def set(self, permissions): self._URL_KEY, "PUT", "multi" ) r = self.client.request("PUT", target_url, json=permissions) - if r.status_code != 201: + if r.status_code != 200: raise exceptions.ServerError( - "Expected 201 response, got %s: %s" % (r.status_code, target_url) + "Expected 200 response, got %s: %s" % (r.status_code, target_url) ) return self.list() diff --git a/tests/test_permissions.py b/tests/test_permissions.py index 1352d01..fa30a82 100644 --- a/tests/test_permissions.py +++ b/tests/test_permissions.py @@ -140,7 +140,7 @@ def test_set_layer_permissions(responses, client, layer): responses.PUT, target_url, body=layer_list_permissions_good_simulated_response, - status=201, + status=200, ) base_url = client.get_url("LAYER", "GET", "single", {"id": layer.id}) target_url = base_url + client.get_url_path("PERMISSION", "GET", "multi") @@ -254,7 +254,7 @@ def test_set_set_permissions(responses, client, set_): responses.PUT, target_url, body=set_list_permissions_good_simulated_response, - status=201, + status=200, ) base_url = client.get_url("SET", "GET", "single", {"id": set_.id}) target_url = base_url + client.get_url_path("PERMISSION", "GET", "multi") @@ -388,7 +388,7 @@ def test_source_set_permissions(responses, client, source): responses.PUT, target_url, body=source_list_permissions_good_simulated_response, - status=201, + status=200, ) base_url = client.get_url("SOURCE", "GET", "single", {"id": source.id}) target_url = base_url + client.get_url_path("PERMISSION", "GET", "multi") From 9464dcf5ce0009249c2e469ba4f815d92d155421 Mon Sep 17 00:00:00 2001 From: Ben Pearman Date: Fri, 22 Mar 2024 17:43:27 +1300 Subject: [PATCH 2/2] Document how permissions are set in the quickstart --- docs/source/user/quickstart.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/source/user/quickstart.rst b/docs/source/user/quickstart.rst index c3b755d..32f72b6 100644 --- a/docs/source/user/quickstart.rst +++ b/docs/source/user/quickstart.rst @@ -81,6 +81,11 @@ Publish a specific version of a Layer:: >>> layer_version = client.layers.get(8888).get_version(9999) >>> layer_version.publish() +Set the permissions of a Layer:: + + >>> permissions = [{"permission": "view", "group": "everyone"}, {"permission": "admin", "user": 123}] + >>> layer.permissions.set(permissions) + Authentication ==============