azure disable_user update url, assignment id
This commit is contained in:
parent
bbd2914824
commit
08ca093eda
@ -321,7 +321,7 @@ class AzureCloudProvider(CloudProviderInterface):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
result = self.sdk.requests.delete(
|
result = self.sdk.requests.delete(
|
||||||
f"{self.sdk.cloud.endpoints.resource_manager}providers/Microsoft.Authorization/roleAssignments/{cloud_id}?api-version=2015-07-01",
|
f"{self.sdk.cloud.endpoints.resource_manager}/{cloud_id}?api-version=2015-07-01",
|
||||||
headers=headers,
|
headers=headers,
|
||||||
timeout=30,
|
timeout=30,
|
||||||
)
|
)
|
||||||
|
@ -207,6 +207,11 @@ def test_create_policy_definition_succeeds(mock_azure: AzureCloudProvider):
|
|||||||
|
|
||||||
|
|
||||||
def test_disable_user(mock_azure: AzureCloudProvider):
|
def test_disable_user(mock_azure: AzureCloudProvider):
|
||||||
|
|
||||||
|
assignment_guid = str(uuid4())
|
||||||
|
management_group_id = str(uuid4())
|
||||||
|
assignment_id = f"/providers/Microsoft.Management/managementGroups/{management_group_id}/providers/Microsoft.Authorization/roleAssignments/{assignment_guid}"
|
||||||
|
|
||||||
mock_result = Mock()
|
mock_result = Mock()
|
||||||
mock_result.json.return_value = {
|
mock_result.json.return_value = {
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -214,9 +219,9 @@ def test_disable_user(mock_azure: AzureCloudProvider):
|
|||||||
"principalId": "Pid",
|
"principalId": "Pid",
|
||||||
"scope": "/subscriptions/subId/resourcegroups/rgname",
|
"scope": "/subscriptions/subId/resourcegroups/rgname",
|
||||||
},
|
},
|
||||||
"id": "/subscriptions/subId/resourcegroups/rgname/providers/Microsoft.Authorization/roleAssignments/roleassignmentId",
|
"id": assignment_id,
|
||||||
"type": "Microsoft.Authorization/roleAssignments",
|
"type": "Microsoft.Authorization/roleAssignments",
|
||||||
"name": "roleassignmentId",
|
"name": assignment_guid,
|
||||||
}
|
}
|
||||||
|
|
||||||
mock_result.status_code = 200
|
mock_result.status_code = 200
|
||||||
@ -235,17 +240,15 @@ def test_disable_user(mock_azure: AzureCloudProvider):
|
|||||||
mock_azure = mock_get_secret(mock_azure)
|
mock_azure = mock_get_secret(mock_azure)
|
||||||
|
|
||||||
tenant_id = "60ff9d34-82bf-4f21-b565-308ef0533435"
|
tenant_id = "60ff9d34-82bf-4f21-b565-308ef0533435"
|
||||||
cloud_id = "roleassignmentId"
|
|
||||||
|
|
||||||
with pytest.raises(ConnectionException):
|
with pytest.raises(ConnectionException):
|
||||||
mock_azure.disable_user(tenant_id, cloud_id)
|
mock_azure.disable_user(tenant_id, assignment_guid)
|
||||||
with pytest.raises(ConnectionException):
|
with pytest.raises(ConnectionException):
|
||||||
mock_azure.disable_user(tenant_id, cloud_id)
|
mock_azure.disable_user(tenant_id, assignment_guid)
|
||||||
with pytest.raises(UnknownServerException, match=r".*500 Server Error.*"):
|
with pytest.raises(UnknownServerException, match=r".*500 Server Error.*"):
|
||||||
mock_azure.disable_user(tenant_id, cloud_id)
|
mock_azure.disable_user(tenant_id, assignment_guid)
|
||||||
|
|
||||||
result = mock_azure.disable_user(tenant_id, cloud_id)
|
result = mock_azure.disable_user(tenant_id, assignment_guid)
|
||||||
assert result.get("name") == cloud_id
|
assert result.get("name") == assignment_guid
|
||||||
|
|
||||||
|
|
||||||
def test_create_tenant(mock_azure: AzureCloudProvider):
|
def test_create_tenant(mock_azure: AzureCloudProvider):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user