models for creating billing owner
This commit is contained in:
parent
3f60d3494e
commit
45dbf9454e
@ -18,6 +18,8 @@ from .models import (
|
|||||||
ApplicationCSPResult,
|
ApplicationCSPResult,
|
||||||
BillingInstructionCSPPayload,
|
BillingInstructionCSPPayload,
|
||||||
BillingInstructionCSPResult,
|
BillingInstructionCSPResult,
|
||||||
|
BillingOwnerCSPPayload,
|
||||||
|
BillingOwnerCSPResult,
|
||||||
BillingProfileCreationCSPPayload,
|
BillingProfileCreationCSPPayload,
|
||||||
BillingProfileCreationCSPResult,
|
BillingProfileCreationCSPResult,
|
||||||
BillingProfileTenantAccessCSPPayload,
|
BillingProfileTenantAccessCSPPayload,
|
||||||
@ -776,6 +778,9 @@ class AzureCloudProvider(CloudProviderInterface):
|
|||||||
if response.ok:
|
if response.ok:
|
||||||
return PrincipalAdminRoleCSPResult(**response.json())
|
return PrincipalAdminRoleCSPResult(**response.json())
|
||||||
|
|
||||||
|
def create_billing_owner(self, payload: BillingOwnerCSPPayload):
|
||||||
|
pass
|
||||||
|
|
||||||
def force_tenant_admin_pw_update(self, creds, tenant_owner_id):
|
def force_tenant_admin_pw_update(self, creds, tenant_owner_id):
|
||||||
# use creds to update to force password recovery?
|
# use creds to update to force password recovery?
|
||||||
# not sure what the endpoint/method for this is, yet
|
# not sure what the endpoint/method for this is, yet
|
||||||
|
@ -487,10 +487,7 @@ class ProductPurchaseVerificationCSPResult(AliasModel):
|
|||||||
premium_purchase_date: str
|
premium_purchase_date: str
|
||||||
|
|
||||||
|
|
||||||
class UserCSPPayload(BaseCSPPayload):
|
class UserMixin(BaseModel):
|
||||||
display_name: str
|
|
||||||
tenant_host_name: str
|
|
||||||
email: str
|
|
||||||
password: Optional[str]
|
password: Optional[str]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -506,6 +503,12 @@ class UserCSPPayload(BaseCSPPayload):
|
|||||||
return password or token_urlsafe(16)
|
return password or token_urlsafe(16)
|
||||||
|
|
||||||
|
|
||||||
|
class UserCSPPayload(BaseCSPPayload, UserMixin):
|
||||||
|
display_name: str
|
||||||
|
tenant_host_name: str
|
||||||
|
email: str
|
||||||
|
|
||||||
|
|
||||||
class UserCSPResult(AliasModel):
|
class UserCSPResult(AliasModel):
|
||||||
id: str
|
id: str
|
||||||
|
|
||||||
@ -554,3 +557,32 @@ class ReportingCSPPayload(BaseCSPPayload):
|
|||||||
return values
|
return values
|
||||||
except (KeyError, IndexError):
|
except (KeyError, IndexError):
|
||||||
raise ValueError("Invoice section ID not present in payload")
|
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,
|
ManagementGroupCSPPayload,
|
||||||
ManagementGroupCSPResponse,
|
ManagementGroupCSPResponse,
|
||||||
UserCSPPayload,
|
UserCSPPayload,
|
||||||
|
BillingOwnerCSPPayload,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -121,3 +122,37 @@ def test_UserCSPPayload_user_principal_name():
|
|||||||
def test_UserCSPPayload_password():
|
def test_UserCSPPayload_password():
|
||||||
payload = UserCSPPayload(**user_payload)
|
payload = UserCSPPayload(**user_payload)
|
||||||
assert payload.password
|
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