Make AADP purchase quantity configurable
Also remove a few constant params from the payload model.
This commit is contained in:
parent
4fb9b88e1d
commit
6b8ea41925
@ -99,6 +99,7 @@ class AzureCloudProvider(CloudProviderInterface):
|
||||
self.ps_client_id = config["POWERSHELL_CLIENT_ID"]
|
||||
self.owner_role_def_id = config["AZURE_OWNER_ROLE_DEF_ID"]
|
||||
self.graph_resource = config["AZURE_GRAPH_RESOURCE"]
|
||||
self.default_aadp_qty = config["AZURE_AADP_QTY"]
|
||||
|
||||
if azure_sdk_provider is None:
|
||||
self.sdk = AzureSDKProvider()
|
||||
@ -528,17 +529,11 @@ class AzureCloudProvider(CloudProviderInterface):
|
||||
"Could not resolve token for aad premium product purchase"
|
||||
)
|
||||
|
||||
payload_as_dict = payload.dict(by_alias=True)
|
||||
|
||||
create_product_purchase_body = {
|
||||
"type": "AADPremium",
|
||||
"sku": "AADP1",
|
||||
"productProperties": {
|
||||
"beneficiaryTenantId": payload_as_dict["productProperties"][
|
||||
"beneficiaryTenantId"
|
||||
],
|
||||
},
|
||||
"quantity": payload_as_dict.get("quantity"),
|
||||
"productProperties": {"beneficiaryTenantId": payload.tenant_id,},
|
||||
"quantity": self.default_aadp_qty,
|
||||
}
|
||||
create_product_purchase_headers = {
|
||||
"Authorization": f"Bearer {sp_token}",
|
||||
|
@ -409,10 +409,6 @@ class KeyVaultCredentials(BaseModel):
|
||||
|
||||
|
||||
class ProductPurchaseCSPPayload(BaseCSPPayload):
|
||||
type: str
|
||||
sku: str
|
||||
quantity: int
|
||||
productProperties: Dict
|
||||
billing_account_name: str
|
||||
billing_profile_name: str
|
||||
|
||||
|
@ -463,10 +463,6 @@ def test_create_product_purchase(mock_azure: AzureCloudProvider):
|
||||
payload = ProductPurchaseCSPPayload(
|
||||
**dict(
|
||||
tenant_id="6d2d2d6c-a6d6-41e1-8bb1-73d11475f8f4",
|
||||
type="AADPremium",
|
||||
sku="AADP1",
|
||||
productProperties={"beneficiaryTenantId": str(uuid4()),},
|
||||
quantity=4,
|
||||
billing_account_name="7c89b735-b22b-55c0-ab5a-c624843e8bf6:de4416ce-acc6-44b1-8122-c87c4e903c91_2019-05-31",
|
||||
billing_profile_name="KQWI-W2SU-BG7-TGB",
|
||||
)
|
||||
|
@ -12,6 +12,7 @@ AZURE_CONFIG = {
|
||||
"POWERSHELL_CLIENT_ID": "MOCK",
|
||||
"AZURE_OWNER_ROLE_DEF_ID": "MOCK",
|
||||
"AZURE_GRAPH_RESOURCE": "MOCK",
|
||||
"AZURE_AADP_QTY": 5,
|
||||
}
|
||||
|
||||
AUTH_CREDENTIALS = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user