-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
267 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,35 @@ func TestAccApiManagementIdentityProviderAAD_basic(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccApiManagementIdentityProviderAAD_clientLibrary(t *testing.T) { | ||
data := acceptance.BuildTestData(t, "azurerm_api_management_identity_provider_aad", "test") | ||
r := ApiManagementIdentityProviderAADResource{} | ||
|
||
data.ResourceTest(t, r, []acceptance.TestStep{ | ||
{ | ||
Config: r.clientLibrary(data), | ||
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep("client_secret"), | ||
{ | ||
Config: r.clientLibraryUpdate(data), | ||
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep("client_secret"), | ||
{ | ||
Config: r.clientLibrary(data), | ||
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep("client_secret"), | ||
}) | ||
} | ||
|
||
func TestAccApiManagementIdentityProviderAAD_update(t *testing.T) { | ||
data := acceptance.BuildTestData(t, "azurerm_api_management_identity_provider_aad", "test") | ||
r := ApiManagementIdentityProviderAADResource{} | ||
|
@@ -92,6 +121,70 @@ func (ApiManagementIdentityProviderAADResource) Exists(ctx context.Context, clie | |
return pointer.To(resp.Model != nil && resp.Model.Id != nil), nil | ||
} | ||
|
||
func (ApiManagementIdentityProviderAADResource) clientLibrary(data acceptance.TestData) string { | ||
return fmt.Sprintf(` | ||
provider "azurerm" { | ||
features {} | ||
} | ||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG-api-%d" | ||
location = "%s" | ||
} | ||
resource "azurerm_api_management" "test" { | ||
name = "acctestAM-%d" | ||
location = azurerm_resource_group.test.location | ||
resource_group_name = azurerm_resource_group.test.name | ||
publisher_name = "pub1" | ||
publisher_email = "[email protected]" | ||
sku_name = "Developer_1" | ||
} | ||
resource "azurerm_api_management_identity_provider_aad" "test" { | ||
resource_group_name = azurerm_resource_group.test.name | ||
api_management_name = azurerm_api_management.test.name | ||
client_id = "00000000-0000-0000-0000-000000000000" | ||
client_library = "MSAL" | ||
client_secret = "00000000000000000000000000000000" | ||
signin_tenant = "00000000-0000-0000-0000-000000000000" | ||
allowed_tenants = ["%s"] | ||
} | ||
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.Client().TenantID) | ||
} | ||
|
||
func (ApiManagementIdentityProviderAADResource) clientLibraryUpdate(data acceptance.TestData) string { | ||
return fmt.Sprintf(` | ||
provider "azurerm" { | ||
features {} | ||
} | ||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG-api-%d" | ||
location = "%s" | ||
} | ||
resource "azurerm_api_management" "test" { | ||
name = "acctestAM-%d" | ||
location = azurerm_resource_group.test.location | ||
resource_group_name = azurerm_resource_group.test.name | ||
publisher_name = "pub1" | ||
publisher_email = "[email protected]" | ||
sku_name = "Developer_1" | ||
} | ||
resource "azurerm_api_management_identity_provider_aad" "test" { | ||
resource_group_name = azurerm_resource_group.test.name | ||
api_management_name = azurerm_api_management.test.name | ||
client_id = "00000000-0000-0000-0000-000000000000" | ||
client_library = "MSAL-2" | ||
client_secret = "00000000000000000000000000000000" | ||
signin_tenant = "00000000-0000-0000-0000-000000000000" | ||
allowed_tenants = ["%s"] | ||
} | ||
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.Client().TenantID) | ||
} | ||
|
||
func (ApiManagementIdentityProviderAADResource) basic(data acceptance.TestData) string { | ||
return fmt.Sprintf(` | ||
provider "azurerm" { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,36 @@ func TestAccAzureRMApiManagementIdentityProviderAADB2C_basic(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccAzureRMApiManagementIdentityProviderAADB2C_clientLibrary(t *testing.T) { | ||
data := acceptance.BuildTestData(t, "azurerm_api_management_identity_provider_aadb2c", "test") | ||
r := ApiManagementIdentityProviderAADB2CResource{} | ||
b2cConfig := testAccAzureRMApiManagementIdentityProviderAADB2C_getB2CConfig(t) | ||
|
||
data.ResourceTest(t, r, []acceptance.TestStep{ | ||
{ | ||
Config: r.clientLibrary(data, b2cConfig), | ||
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep("client_secret"), | ||
{ | ||
Config: r.clientLibraryUpdate(data, b2cConfig), | ||
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep("client_secret"), | ||
{ | ||
Config: r.clientLibrary(data, b2cConfig), | ||
Check: acceptance.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep("client_secret"), | ||
}) | ||
} | ||
|
||
func TestAccAzureRMApiManagementIdentityProviderAADB2C_requiresImport(t *testing.T) { | ||
data := acceptance.BuildTestData(t, "azurerm_api_management_identity_provider_aadb2c", "test") | ||
r := ApiManagementIdentityProviderAADB2CResource{} | ||
|
@@ -162,6 +192,126 @@ resource "azurerm_api_management_identity_provider_aadb2c" "test" { | |
`, b2cConfig["tenant_id"], b2cConfig["client_id"], b2cConfig["client_secret"], b2cConfig["tenant_slug"], data.RandomInteger, data.Locations.Primary) | ||
} | ||
|
||
func (ApiManagementIdentityProviderAADB2CResource) clientLibrary(data acceptance.TestData, b2cConfig map[string]string) string { | ||
return fmt.Sprintf(` | ||
provider "azurerm" { | ||
features {} | ||
} | ||
provider "azuread" { | ||
tenant_id = "%[1]s" | ||
client_id = "%[2]s" | ||
client_secret = "%[3]s" | ||
} | ||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG-api-%[5]d" | ||
location = "%[6]s" | ||
} | ||
resource "azurerm_api_management" "test" { | ||
name = "acctestAM-%[5]d" | ||
location = azurerm_resource_group.test.location | ||
resource_group_name = azurerm_resource_group.test.name | ||
publisher_name = "pub1" | ||
publisher_email = "[email protected]" | ||
sku_name = "Developer_1" | ||
} | ||
resource "azuread_application" "test" { | ||
display_name = "acctestAM-%[5]d" | ||
web { | ||
redirect_uris = [azurerm_api_management.test.developer_portal_url] | ||
implicit_grant { | ||
access_token_issuance_enabled = true | ||
} | ||
} | ||
} | ||
resource "azuread_application_password" "test" { | ||
application_object_id = azuread_application.test.object_id | ||
} | ||
resource "azurerm_api_management_identity_provider_aadb2c" "test" { | ||
resource_group_name = azurerm_resource_group.test.name | ||
api_management_name = azurerm_api_management.test.name | ||
client_id = azuread_application.test.application_id | ||
client_library = "MSAL" | ||
client_secret = azuread_application_password.test.value | ||
allowed_tenant = "%[4]s.onmicrosoft.com" | ||
signin_tenant = "%[4]s.onmicrosoft.com" | ||
authority = "%[4]s.b2clogin.com" | ||
signin_policy = "B2C_1_Login" | ||
signup_policy = "B2C_1_Signup" | ||
profile_editing_policy = "B2C_1_EditProfile" | ||
password_reset_policy = "B2C_1_ResetPassword" | ||
depends_on = [azuread_application_password.test] | ||
} | ||
`, b2cConfig["tenant_id"], b2cConfig["client_id"], b2cConfig["client_secret"], b2cConfig["tenant_slug"], data.RandomInteger, data.Locations.Primary) | ||
} | ||
|
||
func (ApiManagementIdentityProviderAADB2CResource) clientLibraryUpdate(data acceptance.TestData, b2cConfig map[string]string) string { | ||
return fmt.Sprintf(` | ||
provider "azurerm" { | ||
features {} | ||
} | ||
provider "azuread" { | ||
tenant_id = "%[1]s" | ||
client_id = "%[2]s" | ||
client_secret = "%[3]s" | ||
} | ||
resource "azurerm_resource_group" "test" { | ||
name = "acctestRG-api-%[5]d" | ||
location = "%[6]s" | ||
} | ||
resource "azurerm_api_management" "test" { | ||
name = "acctestAM-%[5]d" | ||
location = azurerm_resource_group.test.location | ||
resource_group_name = azurerm_resource_group.test.name | ||
publisher_name = "pub1" | ||
publisher_email = "[email protected]" | ||
sku_name = "Developer_1" | ||
} | ||
resource "azuread_application" "test" { | ||
display_name = "acctestAM-%[5]d" | ||
web { | ||
redirect_uris = [azurerm_api_management.test.developer_portal_url] | ||
implicit_grant { | ||
access_token_issuance_enabled = true | ||
} | ||
} | ||
} | ||
resource "azuread_application_password" "test" { | ||
application_object_id = azuread_application.test.object_id | ||
} | ||
resource "azurerm_api_management_identity_provider_aadb2c" "test" { | ||
resource_group_name = azurerm_resource_group.test.name | ||
api_management_name = azurerm_api_management.test.name | ||
client_id = azuread_application.test.application_id | ||
client_library = "MSAL-2" | ||
client_secret = azuread_application_password.test.value | ||
allowed_tenant = "%[4]s.onmicrosoft.com" | ||
signin_tenant = "%[4]s.onmicrosoft.com" | ||
authority = "%[4]s.b2clogin.com" | ||
signin_policy = "B2C_1_Login" | ||
signup_policy = "B2C_1_Signup" | ||
profile_editing_policy = "B2C_1_EditProfile" | ||
password_reset_policy = "B2C_1_ResetPassword" | ||
depends_on = [azuread_application_password.test] | ||
} | ||
`, b2cConfig["tenant_id"], b2cConfig["client_id"], b2cConfig["client_secret"], b2cConfig["tenant_slug"], data.RandomInteger, data.Locations.Primary) | ||
} | ||
|
||
func (r ApiManagementIdentityProviderAADB2CResource) requiresImport(data acceptance.TestData, b2cConfig map[string]string) string { | ||
template := r.basic(data, b2cConfig) | ||
return fmt.Sprintf(` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters