Skip to content

Commit

Permalink
WIP fix up conditionalaccesspolicy tests for clientApplications
Browse files Browse the repository at this point in the history
  • Loading branch information
manicminer committed Mar 23, 2023
1 parent e43ffed commit 0e4c5e4
Showing 1 changed file with 34 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,25 +291,23 @@ func TestAccConditionalAccessPolicy_clientApplications(t *testing.T) {
),
},
data.ImportStep(),
/*
{
Config: r.complete(data),
Check: resource.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.clientApplicationsIncluded(data),
Check: resource.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("id").Exists(),
check.That(data.ResourceName).Key("display_name").HasValue(fmt.Sprintf("acctest-CONPOLICY-%d", data.RandomInteger)),
check.That(data.ResourceName).Key("state").HasValue("disabled"),
),
},
data.ImportStep(),
*/
{
Config: r.complete(data),
Check: resource.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.clientApplicationsIncluded(data),
Check: resource.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("id").Exists(),
check.That(data.ResourceName).Key("display_name").HasValue(fmt.Sprintf("acctest-CONPOLICY-%d", data.RandomInteger)),
check.That(data.ResourceName).Key("state").HasValue("disabled"),
),
},
data.ImportStep(),
{
Config: r.clientApplicationsExcluded(data),
Check: resource.ComposeTestCheckFunc(
Expand Down Expand Up @@ -652,13 +650,8 @@ resource "azuread_conditional_access_policy" "test" {
func (ConditionalAccessPolicyResource) clientApplicationsIncluded(data acceptance.TestData) string {
return fmt.Sprintf(`
resource "azuread_application" "test" {
display_name = "acctestServicePrincipal-%[1]d"
}
resource "azuread_service_principal" "test" {
application_id = azuread_application.test.application_id
}
data "azuread_client_config" "test" {}
resource "azuread_conditional_access_policy" "test" {
display_name = "acctest-CONPOLICY-%[1]d"
Expand All @@ -671,9 +664,13 @@ resource "azuread_conditional_access_policy" "test" {
included_applications = ["All"]
}
client_applications {
included_service_principals = [azuread_service_principal.test.object_id]
}
client_applications {
included_service_principals = [data.azuread_client_config.test.object_id]
}
users {
included_users = ["All"]
}
}
grant_controls {
Expand All @@ -687,13 +684,8 @@ resource "azuread_conditional_access_policy" "test" {
func (ConditionalAccessPolicyResource) clientApplicationsExcluded(data acceptance.TestData) string {
return fmt.Sprintf(`
resource "azuread_application" "test" {
display_name = "acctestServicePrincipal-%[1]d"
}
resource "azuread_service_principal" "test" {
application_id = azuread_application.test.application_id
}
data "azuread_client_config" "test" {}
resource "azuread_conditional_access_policy" "test" {
display_name = "acctest-CONPOLICY-%[1]d"
Expand All @@ -706,10 +698,14 @@ resource "azuread_conditional_access_policy" "test" {
included_applications = ["All"]
}
client_applications {
included_service_principals = ["ServicePrincipalsInMyTenant"]
excluded_service_principals = [azuread_service_principal.test.object_id]
}
client_applications {
included_service_principals = ["ServicePrincipalsInMyTenant"]
excluded_service_principals = [data.azuread_client_config.test.object_id]
}
users {
included_users = ["All"]
}
}
grant_controls {
Expand Down

0 comments on commit 0e4c5e4

Please sign in to comment.