step in state machine to reset tenant admin password to random value

This commit is contained in:
2020-03-05 12:57:56 -05:00
parent f2dbd4fbc7
commit 16cf5dfe00
7 changed files with 426 additions and 0 deletions

View File

@@ -56,6 +56,8 @@ from atat.domain.csp.cloud.models import (
TaskOrderBillingVerificationCSPResult,
TenantAdminOwnershipCSPPayload,
TenantAdminOwnershipCSPResult,
TenantAdminCredentialResetCSPPayload,
TenantAdminCredentialResetCSPResult,
TenantCSPPayload,
TenantCSPResult,
TenantPrincipalAppCSPPayload,
@@ -1431,6 +1433,38 @@ def test_update_active_directory_user_email(mock_azure: AzureCloudProvider):
assert result
def test_update_active_directory_user_password_profile(mock_azure: AzureCloudProvider):
mock_result = Mock()
mock_result.ok = True
mock_http_error_resp = mock_requests_response(
status=500,
raise_for_status=mock_azure.sdk.requests.exceptions.HTTPError(
"500 Server Error"
),
)
mock_azure.sdk.requests.patch.side_effect = [
mock_azure.sdk.requests.exceptions.ConnectionError,
mock_azure.sdk.requests.exceptions.Timeout,
mock_http_error_resp,
mock_result,
]
payload = TenantAdminCredentialResetCSPPayload(
tenant_id="6d2d2d6c-a6d6-41e1-8bb1-73d11475f8f4",
user_id="admin",
new_password="asdfghjkl", # pragma: allowlist secret
)
with pytest.raises(ConnectionException):
mock_azure._update_active_directory_user_password_profile("token", payload)
with pytest.raises(ConnectionException):
mock_azure._update_active_directory_user_password_profile("token", payload)
with pytest.raises(UnknownServerException, match=r".*500 Server Error.*"):
mock_azure._update_active_directory_user_password_profile("token", payload)
result = mock_azure._update_active_directory_user_password_profile("token", payload)
assert result
def test_create_user(mock_azure: AzureCloudProvider):
with patch.object(
AzureCloudProvider,

View File

@@ -305,6 +305,7 @@ def test_fsm_transition_start(
FSMStates.INITIAL_MGMT_GROUP_CREATED,
FSMStates.INITIAL_MGMT_GROUP_VERIFICATION_CREATED,
FSMStates.TENANT_ADMIN_OWNERSHIP_CREATED,
FSMStates.TENANT_ADMIN_CREDENTIAL_RESET_CREATED,
FSMStates.TENANT_PRINCIPAL_OWNERSHIP_CREATED,
FSMStates.BILLING_OWNER_CREATED,
FSMStates.COMPLETED,