From b098e1407bf8b5c0950f7815c59fd8855c2cc89e Mon Sep 17 00:00:00 2001 From: mroloux Date: Mon, 27 Apr 2020 08:52:20 +0200 Subject: [PATCH] Added call to regenerate workspace secrert key --- seatsio/workspaces/workspacesClient.py | 4 ++++ setup.py | 2 +- ...t.py => regenerateSubaccountDesignerKeyTest.py} | 2 +- ...est.py => regenerateSubaccountSecretKeyTest.py} | 2 +- .../workspaces/regenerateWorkspaceSecretKeyTest.py | 14 ++++++++++++++ 5 files changed, 21 insertions(+), 3 deletions(-) rename tests/subaccounts/{regenerateDesignerKeyTest.py => regenerateSubaccountDesignerKeyTest.py} (87%) rename tests/subaccounts/{regenerateSecretKeyTest.py => regenerateSubaccountSecretKeyTest.py} (87%) create mode 100644 tests/workspaces/regenerateWorkspaceSecretKeyTest.py diff --git a/seatsio/workspaces/workspacesClient.py b/seatsio/workspaces/workspacesClient.py index b4b001e..01c688c 100644 --- a/seatsio/workspaces/workspacesClient.py +++ b/seatsio/workspaces/workspacesClient.py @@ -20,6 +20,10 @@ def update(self, key, name): self.http_client.url("/workspaces/{key}", key=key).post( UpdateWorkspaceRequest(name)) + def regenerate_secret_key(self, key): + response = self.http_client.url("/workspaces/{key}/actions/regenerate-secret-key", key=key).post() + return response.json()["secretKey"] + def retrieve(self, key): return self.http_client.url("/workspaces/{key}", key=key).get_as(Workspace) diff --git a/setup.py b/setup.py index b33c161..de66f9c 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name='seatsio', - version='v50.2.0', + version='v50.3.0', description='The official Seats.io Python client library', author='The seats.io dev team', author_email='hello@seats.io', diff --git a/tests/subaccounts/regenerateDesignerKeyTest.py b/tests/subaccounts/regenerateSubaccountDesignerKeyTest.py similarity index 87% rename from tests/subaccounts/regenerateDesignerKeyTest.py rename to tests/subaccounts/regenerateSubaccountDesignerKeyTest.py index ffb6651..5cddf74 100644 --- a/tests/subaccounts/regenerateDesignerKeyTest.py +++ b/tests/subaccounts/regenerateSubaccountDesignerKeyTest.py @@ -2,7 +2,7 @@ from tests.util.asserts import assert_that -class RegenerateDesignerKeyTest(SeatsioClientTest): +class RegenerateSubaccountDesignerKeyTest(SeatsioClientTest): def test(self): subaccount = self.client.subaccounts.create() diff --git a/tests/subaccounts/regenerateSecretKeyTest.py b/tests/subaccounts/regenerateSubaccountSecretKeyTest.py similarity index 87% rename from tests/subaccounts/regenerateSecretKeyTest.py rename to tests/subaccounts/regenerateSubaccountSecretKeyTest.py index 1f81315..a4e99f1 100644 --- a/tests/subaccounts/regenerateSecretKeyTest.py +++ b/tests/subaccounts/regenerateSubaccountSecretKeyTest.py @@ -2,7 +2,7 @@ from tests.util.asserts import assert_that -class RegenerateSecretKeyTest(SeatsioClientTest): +class RegenerateSubaccountSecretKeyTest(SeatsioClientTest): def test(self): subaccount = self.client.subaccounts.create() diff --git a/tests/workspaces/regenerateWorkspaceSecretKeyTest.py b/tests/workspaces/regenerateWorkspaceSecretKeyTest.py new file mode 100644 index 0000000..192029f --- /dev/null +++ b/tests/workspaces/regenerateWorkspaceSecretKeyTest.py @@ -0,0 +1,14 @@ +from tests.seatsioClientTest import SeatsioClientTest +from tests.util.asserts import assert_that + + +class RegenerateWorkspaceSecretKeyTest(SeatsioClientTest): + + def test(self): + workspace = self.client.workspaces.create("a ws") + + new_secret_key = self.client.workspaces.regenerate_secret_key(workspace.key) + + assert_that(new_secret_key).is_not_blank().is_not_equal_to(workspace.secret_key) + retrieved_workspace = self.client.workspaces.retrieve(workspace.key) + assert_that(retrieved_workspace.secret_key).is_equal_to(new_secret_key)