Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resource_me_identity update #443

Merged
merged 1 commit into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions ovh/resource_me_identity_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,15 @@ func resourceMeIdentityUserUpdate(d *schema.ResourceData, meta interface{}) erro
description := d.Get("description").(string)
email := d.Get("email").(string)
group := d.Get("group").(string)
login := d.Get("login").(string)
params := &MeIdentityUserUpdateOpts{
Login: login,
Description: description,
Email: email,
Group: group,
}
err := config.OVHClient.Put(
fmt.Sprintf("/me/identity/user/%s", id),
nil,
params,
nil,
)
if err != nil {
return fmt.Errorf("Unable to update identity user %s:\n\t %q", id, err)
Expand Down
28 changes: 28 additions & 0 deletions ovh/resource_me_identity_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,34 @@ func TestAccMeIdentityUser_basic(t *testing.T) {
})
}

func TestAccMeIdentityUser_update(t *testing.T) {
desc := "Identity user created by Terraform Acc."
email := "[email protected]"
group := "DEFAULT"
login := acctest.RandomWithPrefix(test_prefix)
password := base64.StdEncoding.EncodeToString([]byte(acctest.RandomWithPrefix(test_prefix)))

newEmail := "[email protected]"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheckCredentials(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(testAccMeIdentityUserConfig, desc, email, group, login, password),
Check: resource.ComposeTestCheckFunc(
checkIdentityUserResourceAttr("ovh_me_identity_user.user_1", desc, email, group, login)...,
),
},
{
Config: fmt.Sprintf(testAccMeIdentityUserConfig, desc, newEmail, group, login, password),
Check: resource.ComposeTestCheckFunc(
checkIdentityUserResourceAttr("ovh_me_identity_user.user_1", desc, newEmail, group, login)...,
),
}},
})
}

const testAccMeIdentityUserConfig = `
resource "ovh_me_identity_user" "user_1" {
description = "%s"
Expand Down
1 change: 0 additions & 1 deletion ovh/types_me.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ type MeIdentityUserCreateOpts struct {
}

type MeIdentityUserUpdateOpts struct {
Login string `json:"user"`
Description string `json:"description"`
Email string `json:"email"`
Group string `json:"group"`
Expand Down