Skip to content

Commit

Permalink
bugfix: azuread_application - remove computed attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
HappyTobi committed Jul 11, 2024
1 parent 6594e1c commit d1fb644
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
1 change: 0 additions & 1 deletion internal/services/applications/application_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@ func applicationResource() *pluginsdk.Resource {
Description: "App password definition",
Type: pluginsdk.TypeSet,
Optional: true,
Computed: true,
MaxItems: 1,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
Expand Down
48 changes: 48 additions & 0 deletions internal/services/applications/application_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,41 @@ func TestAccApplication_passwordNotSet(t *testing.T) {
})
}

func TestAccApplication_PasswordSetAndRemove(t *testing.T) {
data := acceptance.BuildTestData(t, "azuread_application", "test")
startDate := time.Now().AddDate(0, 0, 7).UTC().Format(time.RFC3339)
endDate := time.Now().AddDate(0, 5, 27).UTC().Format(time.RFC3339)
r := ApplicationResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.passwordComplete(data, startDate, endDate),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("password.#").HasValue("1"),
check.That(data.ResourceName).Key("password.0.key_id").Exists(),
check.That(data.ResourceName).Key("password.0.value").Exists(),
check.That(data.ResourceName).Key("password.0.start_date").Exists(),
check.That(data.ResourceName).Key("password.0.end_date").Exists(),
check.That(data.ResourceName).Key("password.0.display_name").HasValue(fmt.Sprintf("acctest-appPasswordComplete-%d", data.RandomInteger)),
),
},
{
Config: r.passwordRemoved(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
{
RefreshState: true,
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("password.#").HasValue("0"),
),
},
})
}

func (r ApplicationResource) Exists(ctx context.Context, clients *clients.Client, state *terraform.InstanceState) (*bool, error) {
client := clients.Applications.ApplicationsClientBeta
client.BaseClient.DisableRetries = true
Expand Down Expand Up @@ -1709,3 +1744,16 @@ resource "azuread_application" "test" {
}
`, data.RandomInteger, startDate, endDate)
}

func (r ApplicationResource) passwordRemoved(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azuread" {}
data "azuread_client_config" "current" {}
resource "azuread_application" "test" {
display_name = "acctest-APP-%[1]d"
owners = [data.azuread_client_config.current.object_id]
}
`, data.RandomInteger)
}

0 comments on commit d1fb644

Please sign in to comment.