Add missing test for create_principal_admin_role
This commit is contained in:
parent
9d5918d618
commit
4d11f7217e
@ -6,7 +6,11 @@ from uuid import uuid4
|
||||
from atst.utils import sha256_hex
|
||||
|
||||
from .cloud_provider_interface import CloudProviderInterface
|
||||
from .exceptions import AuthenticationException, UserProvisioningException, SecretException
|
||||
from .exceptions import (
|
||||
AuthenticationException,
|
||||
UserProvisioningException,
|
||||
SecretException,
|
||||
)
|
||||
from .models import (
|
||||
AdminRoleDefinitionCSPPayload,
|
||||
AdminRoleDefinitionCSPResult,
|
||||
|
@ -22,6 +22,8 @@ from atst.domain.csp.cloud.models import (
|
||||
BillingProfileVerificationCSPResult,
|
||||
EnvironmentCSPPayload,
|
||||
EnvironmentCSPResult,
|
||||
PrincipalAdminRoleCSPPayload,
|
||||
PrincipalAdminRoleCSPResult,
|
||||
ProductPurchaseCSPPayload,
|
||||
ProductPurchaseCSPResult,
|
||||
ProductPurchaseVerificationCSPPayload,
|
||||
@ -577,10 +579,10 @@ def test_create_tenant_principal_credential(mock_azure: AzureCloudProvider):
|
||||
def test_create_admin_role_definition(mock_azure: AzureCloudProvider):
|
||||
with patch.object(
|
||||
AzureCloudProvider,
|
||||
"_get_elevated_management_token",
|
||||
wraps=mock_azure._get_elevated_management_token,
|
||||
) as get_elevated_management_token:
|
||||
get_elevated_management_token.return_value = "my fake token"
|
||||
"_get_tenant_admin_token",
|
||||
wraps=mock_azure._get_tenant_admin_token,
|
||||
) as get_tenant_admin_token:
|
||||
get_tenant_admin_token.return_value = "my fake token"
|
||||
|
||||
mock_result = Mock()
|
||||
mock_result.ok = True
|
||||
@ -661,6 +663,35 @@ def test_create_tenant_principal_ownership(mock_azure: AzureCloudProvider):
|
||||
assert result.principal_owner_assignment_id == "id"
|
||||
|
||||
|
||||
def test_create_principal_admin_role(mock_azure: AzureCloudProvider):
|
||||
with patch.object(
|
||||
AzureCloudProvider,
|
||||
"_get_tenant_admin_token",
|
||||
wraps=mock_azure._get_tenant_admin_token,
|
||||
) as get_tenant_admin_token:
|
||||
get_tenant_admin_token.return_value = "my fake token"
|
||||
|
||||
mock_result = Mock()
|
||||
mock_result.ok = True
|
||||
mock_result.json.return_value = {"id": "id"}
|
||||
|
||||
mock_azure.sdk.requests.post.return_value = mock_result
|
||||
|
||||
payload = PrincipalAdminRoleCSPPayload(
|
||||
**{
|
||||
"tenant_id": uuid4().hex,
|
||||
"principal_id": "6d2d2d6c-a6d6-41e1-8bb1-73d11475f8f4",
|
||||
"admin_role_def_id": uuid4().hex,
|
||||
}
|
||||
)
|
||||
|
||||
result: PrincipalAdminRoleCSPResult = mock_azure.create_principal_admin_role(
|
||||
payload
|
||||
)
|
||||
|
||||
assert result.principal_assignment_id == "id"
|
||||
|
||||
|
||||
def test_create_subscription_creation(mock_azure: AzureCloudProvider):
|
||||
with patch.object(
|
||||
AzureCloudProvider,
|
||||
|
Loading…
x
Reference in New Issue
Block a user