Skip to content
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions rubrik_cdm/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down
27 changes: 14 additions & 13 deletions tests/unit/cluster_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand Down