Skip to content

Commit

Permalink
add test for must_change_password attribute
Browse files Browse the repository at this point in the history
Signed-off-by: Alessio Greggi <[email protected]>
  • Loading branch information
alegrey91 committed Aug 5, 2024
1 parent b3d77b6 commit 5fdbd00
Showing 1 changed file with 54 additions and 2 deletions.
56 changes: 54 additions & 2 deletions rancher2/resource_rancher2_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ const (
)

var (
testAccRancher2User string
testAccRancher2UserUpdate string
testAccRancher2User string
testAccRancher2UserUpdate string
testAccRancher2UserUpdatePasswordReset string
)

func init() {
Expand All @@ -38,6 +39,16 @@ resource "` + testAccRancher2UserType + `" "foo" {
must_change_password = true
}
`

testAccRancher2UserUpdatePasswordReset = `
resource "` + testAccRancher2UserType + `" "foo" {
name = "Terraform user acceptance test - Updated"
username = "foo"
password = "TestACC1234567"
enabled = true
must_change_password = false
}
`
}

func TestAccRancher2User_basic(t *testing.T) {
Expand Down Expand Up @@ -81,6 +92,47 @@ func TestAccRancher2User_basic(t *testing.T) {
})
}

func TestAccRancher2User_passwordReset(t *testing.T) {
var user *managementClient.User

resource.Test(t, resource.TestCase{
Providers: testAccProviders,
CheckDestroy: testAccCheckRancher2UserDestroy,
Steps: []resource.TestStep{
{
Config: testAccRancher2User,
Check: resource.ComposeTestCheckFunc(
testAccCheckRancher2UserExists(testAccRancher2UserType+".foo", user),
resource.TestCheckResourceAttr(testAccRancher2UserType+".foo", "name", "Terraform user acceptance test"),
resource.TestCheckResourceAttr(testAccRancher2UserType+".foo", "password", "TestACC123456"),
resource.TestCheckResourceAttr(testAccRancher2UserType+".foo", "enabled", "true"),
resource.TestCheckResourceAttr(testAccRancher2UserType+".foo", "must_change_password", "true"),
),
},
{
Config: testAccRancher2UserUpdatePasswordReset,
Check: resource.ComposeTestCheckFunc(
testAccCheckRancher2UserExists(testAccRancher2UserType+".foo", user),
resource.TestCheckResourceAttr(testAccRancher2UserType+".foo", "name", "Terraform user acceptance test - Updated (password reset)"),
resource.TestCheckResourceAttr(testAccRancher2UserType+".foo", "password", "TestACC1234567"),
resource.TestCheckResourceAttr(testAccRancher2UserType+".foo", "enabled", "true"),
resource.TestCheckResourceAttr(testAccRancher2UserType+".foo", "must_change_password", "false"),
),
},
{
Config: testAccRancher2User,
Check: resource.ComposeTestCheckFunc(
testAccCheckRancher2UserExists(testAccRancher2UserType+".foo", user),
resource.TestCheckResourceAttr(testAccRancher2UserType+".foo", "name", "Terraform user acceptance test"),
resource.TestCheckResourceAttr(testAccRancher2UserType+".foo", "password", "TestACC123456"),
resource.TestCheckResourceAttr(testAccRancher2UserType+".foo", "enabled", "true"),
resource.TestCheckResourceAttr(testAccRancher2UserType+".foo", "must_change_password", "true"),
),
},
},
})
}

func TestAccRancher2User_disappears(t *testing.T) {
var user *managementClient.User

Expand Down

0 comments on commit 5fdbd00

Please sign in to comment.