From 10a3ff17111ae2ad4478d1bedf3adbefb336beb7 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Sun, 11 Apr 2021 19:12:48 +0200 Subject: [PATCH 01/14] Updated for #273 --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88ca269..3224131 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed +- Changed API endpoint and logic for create_user ([Issue 273](https://github.com/rubrikinc/rubrik-sdk-for-python/issues/273)) + ### Fixed + - Fix MSSQL Recovery Point timestamp validation on Windows OS Python 2 & 3 ([Issue 268](https://github.com/rubrikinc/rubrik-sdk-for-python/issues/268)) ## v2.0.10 From eaeec43bd38729646124efacffb2297e45295c1c Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Sun, 11 Apr 2021 19:13:06 +0200 Subject: [PATCH 02/14] =?UTF-8?q?Updated=20logic=20for=205.3=20cluster=20s?= =?UTF-8?q?upport=20=F0=9F=8C=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rubrik_cdm/cluster.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rubrik_cdm/cluster.py b/rubrik_cdm/cluster.py index dc138fc..25e400a 100644 --- a/rubrik_cdm/cluster.py +++ b/rubrik_cdm/cluster.py @@ -874,8 +874,8 @@ def create_user(self, username, password, first_name=None, last_name=None, email self.log("create_user: Searching for the current users on the Rubrik cluster") current_users = self.get( - "internal", "/user?username={}".format(username), timeout=timeout) - if len(current_users) > 0: + "v1", "/principal?name={}".format(username), timeout=timeout) + if len(current_users["data"]) > 0: return "No change required. The user '{}' already exists on the Rubrik cluster.".format(username) config = {} From 7e4c041e903344002411dc8a1cfbdf8fa24a9306 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Sun, 11 Apr 2021 19:26:00 +0200 Subject: [PATCH 03/14] =?UTF-8?q?Fix=20test=20=F0=9F=A7=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/unit/cluster_test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/cluster_test.py b/tests/unit/cluster_test.py index 1e67e75..2ca5c6f 100644 --- a/tests/unit/cluster_test.py +++ b/tests/unit/cluster_test.py @@ -1054,6 +1054,7 @@ def mock_post_internal_user(): return { "id": "string", "authDomainId": "string", + "data": 'string', "username": "username", "firstName": "string", "lastName": "string", From 812ca8cd96d7dd19e8ec125c331e9d39e10cddce Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Sun, 11 Apr 2021 19:29:13 +0200 Subject: [PATCH 04/14] =?UTF-8?q?Fix=20test=20again=20=F0=9F=A7=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/unit/cluster_test.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/unit/cluster_test.py b/tests/unit/cluster_test.py index 2ca5c6f..5743d88 100644 --- a/tests/unit/cluster_test.py +++ b/tests/unit/cluster_test.py @@ -1048,13 +1048,16 @@ def mock_get_internal_user(): def test_create_user(rubrik, mocker): def mock_get_internal_user(): - return [] + return { + "hasMore": false, + "data": [], + "total": 0 + } def mock_post_internal_user(): return { "id": "string", "authDomainId": "string", - "data": 'string', "username": "username", "firstName": "string", "lastName": "string", From 32acd7015f14e851d09238d279d7b3c4cf247489 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Sun, 11 Apr 2021 19:32:50 +0200 Subject: [PATCH 05/14] =?UTF-8?q?Fixing=20tests=20part=203=20=F0=9F=95=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/unit/cluster_test.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/unit/cluster_test.py b/tests/unit/cluster_test.py index 5743d88..4e145d8 100644 --- a/tests/unit/cluster_test.py +++ b/tests/unit/cluster_test.py @@ -1049,9 +1049,7 @@ def test_create_user(rubrik, mocker): def mock_get_internal_user(): return { - "hasMore": false, - "data": [], - "total": 0 + "data": "" } def mock_post_internal_user(): From 08212fa2da5c14a7eaa7b4f3a068aac8ae3a330c Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Sun, 11 Apr 2021 19:45:05 +0200 Subject: [PATCH 06/14] =?UTF-8?q?Test=20fix=20=F0=9F=A7=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/unit/cluster_test.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/unit/cluster_test.py b/tests/unit/cluster_test.py index 4e145d8..cc1cfd1 100644 --- a/tests/unit/cluster_test.py +++ b/tests/unit/cluster_test.py @@ -1048,9 +1048,14 @@ def mock_get_internal_user(): def test_create_user(rubrik, mocker): def mock_get_internal_user(): - return { - "data": "" - } + return [ + { + "data": "string" + }, + { + "data": "string" + } + ] def mock_post_internal_user(): return { From 7b888cefb80119432dd4f46ab2269a1ad7f01fa2 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Sun, 11 Apr 2021 19:50:58 +0200 Subject: [PATCH 07/14] =?UTF-8?q?Disable=20test=20for=20now=20=F0=9F=A6=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/unit/cluster_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/cluster_test.py b/tests/unit/cluster_test.py index cc1cfd1..3f21858 100644 --- a/tests/unit/cluster_test.py +++ b/tests/unit/cluster_test.py @@ -1079,8 +1079,8 @@ def mock_post_internal_user(): autospec=True, spec_set=True) mock_post.return_value = mock_post_internal_user() - assert rubrik.create_user( - "username", "password") == mock_post_internal_user() + #assert rubrik.create_user( + # "username", "password") == mock_post_internal_user() def test_read_only_authorization_minimum_installed_cdm_version(rubrik, mocker): From 2047bf6388d0bb2c65c8c6dffbdc30ccabb4d4f0 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Sun, 11 Apr 2021 21:15:04 +0200 Subject: [PATCH 08/14] =?UTF-8?q?Final=20fix=20perhaps=20=F0=9F=A7=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/unit/cluster_test.py | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/tests/unit/cluster_test.py b/tests/unit/cluster_test.py index 3f21858..828b3de 100644 --- a/tests/unit/cluster_test.py +++ b/tests/unit/cluster_test.py @@ -1024,18 +1024,17 @@ def mock_job_status(): def test_create_user_idempotence(rubrik, mocker): def mock_get_internal_user(): - return [ - { - "id": "string", - "authDomainId": "string", - "username": "string", - "firstName": "string", - "lastName": "string", - "emailAddress": "string", - "contactNumber": "string", - "mfaServerId": "string" - } - ] + return { + "id": "string", + "authDomainId": "string", + "data": "blah" + "username": "string", + "firstName": "string", + "lastName": "string", + "emailAddress": "string", + "contactNumber": "string", + "mfaServerId": "string" + } mock_get = mocker.patch('rubrik_cdm.Connect.get', autospec=True, spec_set=True) @@ -1048,14 +1047,9 @@ def mock_get_internal_user(): def test_create_user(rubrik, mocker): def mock_get_internal_user(): - return [ - { - "data": "string" - }, - { + return { "data": "string" - } - ] + } def mock_post_internal_user(): return { @@ -1079,8 +1073,8 @@ def mock_post_internal_user(): autospec=True, spec_set=True) mock_post.return_value = mock_post_internal_user() - #assert rubrik.create_user( - # "username", "password") == mock_post_internal_user() + assert rubrik.create_user( + "username", "password") == mock_post_internal_user() def test_read_only_authorization_minimum_installed_cdm_version(rubrik, mocker): From 35a8629c96e5359146343ae91d0f51228fda8387 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Sun, 11 Apr 2021 21:20:35 +0200 Subject: [PATCH 09/14] =?UTF-8?q?Add=20missing=20comma=20=F0=9F=93=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/unit/cluster_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/cluster_test.py b/tests/unit/cluster_test.py index 828b3de..375408b 100644 --- a/tests/unit/cluster_test.py +++ b/tests/unit/cluster_test.py @@ -1027,7 +1027,7 @@ def mock_get_internal_user(): return { "id": "string", "authDomainId": "string", - "data": "blah" + "data": "blah", "username": "string", "firstName": "string", "lastName": "string", From e1b7734fb1b05dda6dcc180b9b103b48feb877d7 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Sun, 11 Apr 2021 21:23:16 +0200 Subject: [PATCH 10/14] =?UTF-8?q?Add=20empty=20data=20field=20=F0=9F=A7=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/unit/cluster_test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/cluster_test.py b/tests/unit/cluster_test.py index 375408b..be468a0 100644 --- a/tests/unit/cluster_test.py +++ b/tests/unit/cluster_test.py @@ -1055,6 +1055,7 @@ def mock_post_internal_user(): return { "id": "string", "authDomainId": "string", + "data": "", "username": "username", "firstName": "string", "lastName": "string", From 9e91920efa47d2d3df554e602f287e92d8124842 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Sun, 11 Apr 2021 21:26:18 +0200 Subject: [PATCH 11/14] =?UTF-8?q?Set=20data=20to=20none=F0=9F=9A=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/unit/cluster_test.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/tests/unit/cluster_test.py b/tests/unit/cluster_test.py index be468a0..5617be7 100644 --- a/tests/unit/cluster_test.py +++ b/tests/unit/cluster_test.py @@ -1053,17 +1053,7 @@ def mock_get_internal_user(): def mock_post_internal_user(): return { - "id": "string", - "authDomainId": "string", - "data": "", - "username": "username", - "firstName": "string", - "lastName": "string", - "emailAddress": "string", - "contactNumber": "string", - "createdById": "string", - "createTime": "string", - "mfaServerId": "string" + "data": None } mock_get = mocker.patch('rubrik_cdm.Connect.get', From 26441fb912f267e2ad4feb052f24b48ebcaf2f34 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Sun, 11 Apr 2021 21:32:34 +0200 Subject: [PATCH 12/14] Matched internal post and get --- tests/unit/cluster_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/cluster_test.py b/tests/unit/cluster_test.py index 5617be7..b2b40bd 100644 --- a/tests/unit/cluster_test.py +++ b/tests/unit/cluster_test.py @@ -1048,7 +1048,7 @@ def test_create_user(rubrik, mocker): def mock_get_internal_user(): return { - "data": "string" + "data": None } def mock_post_internal_user(): From 1cbf32b7e470e5407569da571adeff390bda1d2c Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Sun, 11 Apr 2021 21:34:32 +0200 Subject: [PATCH 13/14] =?UTF-8?q?Removed=20none=20=F0=9F=9A=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/unit/cluster_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/cluster_test.py b/tests/unit/cluster_test.py index b2b40bd..44f7ee0 100644 --- a/tests/unit/cluster_test.py +++ b/tests/unit/cluster_test.py @@ -1048,12 +1048,12 @@ def test_create_user(rubrik, mocker): def mock_get_internal_user(): return { - "data": None + "data": "" } def mock_post_internal_user(): return { - "data": None + "data": "" } mock_get = mocker.patch('rubrik_cdm.Connect.get', From a69f54e5a2141dd7875fd0a3bb227ac55ab91187 Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Sun, 11 Apr 2021 21:41:32 +0200 Subject: [PATCH 14/14] =?UTF-8?q?Test=20user=20object=20=F0=9F=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/unit/cluster_test.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/unit/cluster_test.py b/tests/unit/cluster_test.py index 44f7ee0..9f62578 100644 --- a/tests/unit/cluster_test.py +++ b/tests/unit/cluster_test.py @@ -1053,7 +1053,16 @@ def mock_get_internal_user(): def mock_post_internal_user(): return { - "data": "" + "id": "string", + "authDomainId": "string", + "username": "username", + "firstName": "string", + "lastName": "string", + "emailAddress": "string", + "contactNumber": "string", + "createdById": "string", + "createTime": "string", + "mfaServerId": "string" } mock_get = mocker.patch('rubrik_cdm.Connect.get',