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 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 = {} diff --git a/tests/unit/cluster_test.py b/tests/unit/cluster_test.py index 1e67e75..9f62578 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,7 +1047,9 @@ def mock_get_internal_user(): def test_create_user(rubrik, mocker): def mock_get_internal_user(): - return [] + return { + "data": "" + } def mock_post_internal_user(): return {