-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #602 from hashicorp/bugfix/service-principal-no-fe…
…atures Bugfix: allow service principal with no features / all features disabled
- Loading branch information
Showing
2 changed files
with
55 additions
and
3 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,6 +136,13 @@ func TestAccServicePrincipal_featuresUpdate(t *testing.T) { | |
r := ServicePrincipalResource{} | ||
|
||
data.ResourceTest(t, r, []resource.TestStep{ | ||
{ | ||
Config: r.noFeatures(data), | ||
Check: resource.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep("use_existing"), | ||
{ | ||
Config: r.basic(data), | ||
Check: resource.ComposeTestCheckFunc( | ||
|
@@ -178,6 +185,20 @@ func TestAccServicePrincipal_featuresUpdate(t *testing.T) { | |
), | ||
}, | ||
data.ImportStep("use_existing"), | ||
{ | ||
Config: r.noFeatures(data), | ||
Check: resource.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep("use_existing"), | ||
{ | ||
Config: r.features(data), | ||
Check: resource.ComposeTestCheckFunc( | ||
check.That(data.ResourceName).ExistsInAzure(r), | ||
), | ||
}, | ||
data.ImportStep("use_existing"), | ||
}) | ||
} | ||
|
||
|
@@ -464,6 +485,35 @@ resource "azuread_service_principal" "test" { | |
`, r.templateComplete(data), data.RandomInteger) | ||
} | ||
|
||
func (r ServicePrincipalResource) noFeatures(data acceptance.TestData) string { | ||
return fmt.Sprintf(` | ||
%[1]s | ||
resource "azuread_service_principal" "test" { | ||
application_id = azuread_application.test.application_id | ||
account_enabled = false | ||
alternative_names = ["foo", "bar"] | ||
app_role_assignment_required = true | ||
description = "An internal app for testing" | ||
login_url = "https://test-%[2]d.internal/login" | ||
notes = "Just testing something" | ||
preferred_single_sign_on_mode = "saml" | ||
features { | ||
custom_single_sign_on_app = false | ||
enterprise_application = false | ||
gallery_application = false | ||
} | ||
notification_email_addresses = [ | ||
"[email protected]", | ||
"[email protected]", | ||
] | ||
} | ||
`, r.templateComplete(data), data.RandomInteger) | ||
} | ||
|
||
func (ServicePrincipalResource) templateThreeUsers(data acceptance.TestData) string { | ||
return fmt.Sprintf(` | ||
provider "azuread" {} | ||
|
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