models for creating billing owner
This commit is contained in:
parent
3f60d3494e
commit
45dbf9454e
@ -18,6 +18,8 @@ from .models import (
|
||||
ApplicationCSPResult,
|
||||
BillingInstructionCSPPayload,
|
||||
BillingInstructionCSPResult,
|
||||
BillingOwnerCSPPayload,
|
||||
BillingOwnerCSPResult,
|
||||
BillingProfileCreationCSPPayload,
|
||||
BillingProfileCreationCSPResult,
|
||||
BillingProfileTenantAccessCSPPayload,
|
||||
@ -776,6 +778,9 @@ class AzureCloudProvider(CloudProviderInterface):
|
||||
if response.ok:
|
||||
return PrincipalAdminRoleCSPResult(**response.json())
|
||||
|
||||
def create_billing_owner(self, payload: BillingOwnerCSPPayload):
|
||||
pass
|
||||
|
||||
def force_tenant_admin_pw_update(self, creds, tenant_owner_id):
|
||||
# use creds to update to force password recovery?
|
||||
# not sure what the endpoint/method for this is, yet
|
||||
|
@ -487,10 +487,7 @@ class ProductPurchaseVerificationCSPResult(AliasModel):
|
||||
premium_purchase_date: str
|
||||
|
||||
|
||||
class UserCSPPayload(BaseCSPPayload):
|
||||
display_name: str
|
||||
tenant_host_name: str
|
||||
email: str
|
||||
class UserMixin(BaseModel):
|
||||
password: Optional[str]
|
||||
|
||||
@property
|
||||
@ -506,6 +503,12 @@ class UserCSPPayload(BaseCSPPayload):
|
||||
return password or token_urlsafe(16)
|
||||
|
||||
|
||||
class UserCSPPayload(BaseCSPPayload, UserMixin):
|
||||
display_name: str
|
||||
tenant_host_name: str
|
||||
email: str
|
||||
|
||||
|
||||
class UserCSPResult(AliasModel):
|
||||
id: str
|
||||
|
||||
@ -554,3 +557,32 @@ class ReportingCSPPayload(BaseCSPPayload):
|
||||
return values
|
||||
except (KeyError, IndexError):
|
||||
raise ValueError("Invoice section ID not present in payload")
|
||||
|
||||
|
||||
class BillingOwnerCSPPayload(BaseCSPPayload, UserMixin):
|
||||
"""
|
||||
This class needs to consume data in the shape it's in from the
|
||||
top-level portfolio CSP data, but return it in the shape
|
||||
needed for user provisioning.
|
||||
"""
|
||||
|
||||
first_name: str
|
||||
last_name: str
|
||||
domain_name: str
|
||||
password_recovery_email_address: str
|
||||
|
||||
@property
|
||||
def display_name(self):
|
||||
return f"{self.first_name} {self.last_name}"
|
||||
|
||||
@property
|
||||
def tenant_host_name(self):
|
||||
return self.domain_name
|
||||
|
||||
@property
|
||||
def email(self):
|
||||
return self.password_recovery_email_address
|
||||
|
||||
|
||||
class BillingOwnerCSPResult(AliasModel):
|
||||
id: str
|
||||
|
@ -8,6 +8,7 @@ from atst.domain.csp.cloud.models import (
|
||||
ManagementGroupCSPPayload,
|
||||
ManagementGroupCSPResponse,
|
||||
UserCSPPayload,
|
||||
BillingOwnerCSPPayload,
|
||||
)
|
||||
|
||||
|
||||
@ -121,3 +122,37 @@ def test_UserCSPPayload_user_principal_name():
|
||||
def test_UserCSPPayload_password():
|
||||
payload = UserCSPPayload(**user_payload)
|
||||
assert payload.password
|
||||
|
||||
|
||||
class TestBillingOwnerCSPPayload:
|
||||
user_payload = {
|
||||
"tenant_id": "123",
|
||||
"first_name": "Han",
|
||||
"last_name": "Solo",
|
||||
"domain_name": "rebelalliance",
|
||||
"password_recovery_email_address": "han@moseisley.cantina",
|
||||
}
|
||||
|
||||
def test_display_name(self):
|
||||
payload = BillingOwnerCSPPayload(**self.user_payload)
|
||||
assert payload.display_name == "Han Solo"
|
||||
|
||||
def test_tenant_host_name(self):
|
||||
payload = BillingOwnerCSPPayload(**self.user_payload)
|
||||
assert payload.tenant_host_name == self.user_payload["domain_name"]
|
||||
|
||||
def test_mail_nickname(self):
|
||||
payload = BillingOwnerCSPPayload(**self.user_payload)
|
||||
assert payload.mail_nickname == "han.solo"
|
||||
|
||||
def test_password(self):
|
||||
payload = BillingOwnerCSPPayload(**self.user_payload)
|
||||
assert payload.password
|
||||
|
||||
def test_user_principal_name(self):
|
||||
payload = BillingOwnerCSPPayload(**self.user_payload)
|
||||
assert payload.user_principal_name == f"han.solo@rebelalliance.onmicrosoft.com"
|
||||
|
||||
def test_email(self):
|
||||
payload = BillingOwnerCSPPayload(**self.user_payload)
|
||||
assert payload.email == self.user_payload["password_recovery_email_address"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user