diff --git a/atst/domain/csp/cloud/azure_cloud_provider.py b/atst/domain/csp/cloud/azure_cloud_provider.py index 5d6e91d8..5d9ca275 100644 --- a/atst/domain/csp/cloud/azure_cloud_provider.py +++ b/atst/domain/csp/cloud/azure_cloud_provider.py @@ -798,7 +798,7 @@ class AzureCloudProvider(CloudProviderInterface): graph_token, billing_admin_role_id, user_result.id ) - return BillingOwnerCSPResult(id=user_result.id) + return BillingOwnerCSPResult(billing_owner_id=user_result.id) def _assign_billing_owner_role(self, graph_token, billing_admin_role_id, user_id): request_body = { diff --git a/atst/domain/csp/cloud/mock_cloud_provider.py b/atst/domain/csp/cloud/mock_cloud_provider.py index 7ec0636f..3454ec74 100644 --- a/atst/domain/csp/cloud/mock_cloud_provider.py +++ b/atst/domain/csp/cloud/mock_cloud_provider.py @@ -18,6 +18,8 @@ from .models import ( ApplicationCSPResult, BillingInstructionCSPPayload, BillingInstructionCSPResult, + BillingOwnerCSPPayload, + BillingOwnerCSPResult, BillingProfileCreationCSPPayload, BillingProfileCreationCSPResult, BillingProfileTenantAccessCSPResult, @@ -366,6 +368,13 @@ class MockCloudProvider(CloudProviderInterface): return PrincipalAdminRoleCSPResult(**dict(id="principal_assignment_id")) + def create_billing_owner(self, payload: BillingOwnerCSPPayload): + self._maybe_raise(self.NETWORK_FAILURE_PCT, self.NETWORK_EXCEPTION) + self._maybe_raise(self.SERVER_FAILURE_PCT, self.SERVER_EXCEPTION) + self._maybe_raise(self.UNAUTHORIZED_RATE, self.AUTHORIZATION_EXCEPTION) + + return BillingOwnerCSPResult(billing_owner_id="foo") + def create_or_update_user(self, auth_credentials, user_info, csp_role_id): self._authorize(auth_credentials) diff --git a/atst/domain/csp/cloud/models.py b/atst/domain/csp/cloud/models.py index b4920856..4656c432 100644 --- a/atst/domain/csp/cloud/models.py +++ b/atst/domain/csp/cloud/models.py @@ -580,4 +580,4 @@ class BillingOwnerCSPPayload(BaseCSPPayload, UserMixin): class BillingOwnerCSPResult(AliasModel): - id: str + billing_owner_id: str diff --git a/atst/models/mixins/state_machines.py b/atst/models/mixins/state_machines.py index a7edf268..8342853a 100644 --- a/atst/models/mixins/state_machines.py +++ b/atst/models/mixins/state_machines.py @@ -26,6 +26,7 @@ class AzureStages(Enum): PRINCIPAL_ADMIN_ROLE = "tenant principal admin" TENANT_ADMIN_OWNERSHIP = "tenant admin ownership" TENANT_PRINCIPAL_OWNERSHIP = "tenant principial ownership" + BILLING_OWNER = "billing owner" def _build_csp_states(csp_stages): diff --git a/tests/domain/test_portfolio_state_machine.py b/tests/domain/test_portfolio_state_machine.py index 2c27cfd8..5c7ca25c 100644 --- a/tests/domain/test_portfolio_state_machine.py +++ b/tests/domain/test_portfolio_state_machine.py @@ -113,6 +113,7 @@ def test_fsm_transition_start(mock_cloud_provider, portfolio: Portfolio): FSMStates.PRINCIPAL_ADMIN_ROLE_CREATED, FSMStates.TENANT_ADMIN_OWNERSHIP_CREATED, FSMStates.TENANT_PRINCIPAL_OWNERSHIP_CREATED, + FSMStates.BILLING_OWNER_CREATED, ] if portfolio.csp_data is not None: