diff --git a/internal/aws/iam/user_resource_test.go b/internal/aws/iam/user_resource_test.go new file mode 100644 index 000000000..686c4cc2a --- /dev/null +++ b/internal/aws/iam/user_resource_test.go @@ -0,0 +1,52 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +// Code generated by generators/resource/main.go; DO NOT EDIT. + +package iam_test + +import ( + "testing" + "fmt" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-provider-awscc/internal/acctest" +) + +func TestAccAWSIAMUser_updatePassword(t *testing.T) { + td := acctest.NewTestData(t, "AWS::IAM::User", "awscc_iam_user", "test") + resourceName := td.ResourceName + rName := td.RandomName() + + td.ResourceTest(t, []resource.TestStep{ + { + Config: testAccAWSIAMUserPasswordConfig(&td, rName, "MyRandomPassword123$%!"), + Check: resource.ComposeTestCheckFunc( + td.CheckExistsInAWS(), + resource.TestCheckResourceAttr(resourceName, "login_profile.password", "MyRandomPassword123$%!"), + resource.TestCheckResourceAttr(resourceName, "login_profile.password_reset_required", "true"), + ), + }, + { + Config: testAccAWSIAMUserPasswordConfig(&td, rName, "MyRandomPassword456_-_"), + Check: resource.ComposeTestCheckFunc( + td.CheckExistsInAWS(), + resource.TestCheckResourceAttr(resourceName, "login_profile.password", "MyRandomPassword456_-_"), + resource.TestCheckResourceAttr(resourceName, "login_profile.password_reset_required", "true"), + ), + }, + }) +} + +func testAccAWSIAMUserPasswordConfig(td *acctest.TestData, rName, password string) string { + return fmt.Sprintf(` +resource %[1]q %[2]q { + user_name = %[3]q + + login_profile = { + password = %[4]q + password_reset_required = true + } +} +`, td.TerraformResourceType, td.ResourceLabel, rName, password) +} \ No newline at end of file