Update AADP Purchase url and respose format to newer schema.
This commit is contained in:
parent
a0ea3e3220
commit
bbed83d897
@ -539,7 +539,7 @@ class AzureCloudProvider(CloudProviderInterface):
|
|||||||
"Authorization": f"Bearer {sp_token}",
|
"Authorization": f"Bearer {sp_token}",
|
||||||
}
|
}
|
||||||
|
|
||||||
product_purchase_url = f"https://management.azure.com/providers/Microsoft.Billing/billingAccounts/{payload.billing_account_name}/billingProfiles/{payload.billing_profile_name}/products?api-version=2019-10-01-preview"
|
product_purchase_url = f"https://management.azure.com/providers/Microsoft.Billing/billingAccounts/{payload.billing_account_name}/billingProfiles/{payload.billing_profile_name}/purchaseProduct?api-version=2019-10-01-preview"
|
||||||
|
|
||||||
result = self.sdk.requests.post(
|
result = self.sdk.requests.post(
|
||||||
product_purchase_url,
|
product_purchase_url,
|
||||||
@ -577,9 +577,7 @@ class AzureCloudProvider(CloudProviderInterface):
|
|||||||
# 202 has location/retry after headers
|
# 202 has location/retry after headers
|
||||||
return self._ok(ProductPurchaseCSPResult(**result.headers))
|
return self._ok(ProductPurchaseCSPResult(**result.headers))
|
||||||
elif result.status_code == 200:
|
elif result.status_code == 200:
|
||||||
premium_purchase_date = result.json()["product"]["properties"][
|
premium_purchase_date = result.json()["properties"]["purchaseDate"]
|
||||||
"purchaseDate"
|
|
||||||
]
|
|
||||||
return self._ok(
|
return self._ok(
|
||||||
ProductPurchaseVerificationCSPResult(
|
ProductPurchaseVerificationCSPResult(
|
||||||
premium_purchase_date=premium_purchase_date
|
premium_purchase_date=premium_purchase_date
|
||||||
|
@ -484,32 +484,24 @@ def test_create_product_purchase_verification(mock_azure):
|
|||||||
mock_result = Mock()
|
mock_result = Mock()
|
||||||
mock_result.status_code = 200
|
mock_result.status_code = 200
|
||||||
mock_result.json.return_value = {
|
mock_result.json.return_value = {
|
||||||
"status": "string",
|
"id": "/providers/Microsoft.Billing/billingAccounts/BILLINGACCOUNTNAME/billingProfiles/BILLINGPROFILENAME/invoiceSections/INVOICESECTION/products/29386e29-a025-faae-f70b-b1cbbc266600",
|
||||||
"product": {
|
"name": "29386e29-a025-faae-f70b-b1cbbc266600",
|
||||||
"id": "string",
|
|
||||||
"name": "string",
|
|
||||||
"type": "string",
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"displayName": "string",
|
"availabilityId": "C07TTFC7Q9XK",
|
||||||
"purchaseDate": "2020-01-30T18:57:05.981Z",
|
"billingProfileId": "/providers/Microsoft.Billing/billingAccounts/BILLINGACCOUNTNAME/billingProfiles/BILLINGPROFILENAME",
|
||||||
"productTypeId": "string",
|
"billingProfileDisplayName": "ATAT Billing Profile",
|
||||||
"productType": "string",
|
"endDate": "01/30/2021",
|
||||||
"status": "Active",
|
"invoiceSectionId": "/providers/Microsoft.Billing/billingAccounts/BILLINGACCOUNTNAME/billingProfiles/BILLINGPROFILENAME/invoiceSections/INVOICESECTION",
|
||||||
"endDate": "2020-01-30T18:57:05.981Z",
|
"invoiceSectionDisplayName": "ATAT Billing Profile",
|
||||||
"billingFrequency": "OneTime",
|
"productType": "Azure Active Directory Premium P1",
|
||||||
"lastCharge": {"currency": "string", "value": 0},
|
"productTypeId": "C07TTFC7Q9XK",
|
||||||
"lastChargeDate": "2020-01-30T18:57:05.981Z",
|
"skuId": "0002",
|
||||||
"quantity": 0,
|
"skuDescription": "Azure Active Directory Premium P1",
|
||||||
"skuId": "string",
|
"purchaseDate": "01/31/2020",
|
||||||
"skuDescription": "string",
|
"quantity": 5,
|
||||||
"availabilityId": "string",
|
"status": "AutoRenew",
|
||||||
"parentProductId": "string",
|
|
||||||
"invoiceSectionId": "string",
|
|
||||||
"invoiceSectionDisplayName": "string",
|
|
||||||
"billingProfileId": "string",
|
|
||||||
"billingProfileDisplayName": "string",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
"type": "Microsoft.Billing/billingAccounts/billingProfiles/invoiceSections/products",
|
||||||
}
|
}
|
||||||
|
|
||||||
mock_azure.sdk.requests.get.return_value = mock_result
|
mock_azure.sdk.requests.get.return_value = mock_result
|
||||||
@ -523,7 +515,7 @@ def test_create_product_purchase_verification(mock_azure):
|
|||||||
|
|
||||||
result = mock_azure.create_product_purchase_verification(payload)
|
result = mock_azure.create_product_purchase_verification(payload)
|
||||||
body: ProductPurchaseVerificationCSPResult = result.get("body")
|
body: ProductPurchaseVerificationCSPResult = result.get("body")
|
||||||
assert body.premium_purchase_date == "2020-01-30T18:57:05.981Z"
|
assert body.premium_purchase_date == "01/31/2020"
|
||||||
|
|
||||||
|
|
||||||
def test_create_tenant_principal_app(mock_azure: AzureCloudProvider):
|
def test_create_tenant_principal_app(mock_azure: AzureCloudProvider):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user