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(iam): user saml quota not correctly set #957

Merged
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
3 changes: 3 additions & 0 deletions .changelog/875.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
`resource/cloudavenue_iam_user_saml` - Fixed issue when `deployed_vm_quota` and `stored_vm_quota` are not set in the creation of the IAM user.
```
8 changes: 8 additions & 0 deletions .vscode/terraform.code-snippets
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,13 @@
"},",
"}",
],
},
"replace-go-mod": {
"scope": "go",
"prefix": "tf-replace-go-mod",
"body": [
"replace github.com/orange-cloudavenue/cloudavenue-sdk-go => ../cloudavenue-sdk-go",
],
"description": "Replace go.mod"
}
}
54 changes: 54 additions & 0 deletions internal/testsacc/iam_user_saml_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,60 @@ func (r *IAMUserSAMLResource) Tests(ctx context.Context) map[testsacc.TestName]f
ImportStateVerifyIgnore: []string{"take_ownership"},
},
},
Destroy: true,
}
},
"example_quota_on_creation": func(_ context.Context, resourceName string) testsacc.Test {
return testsacc.Test{
CommonChecks: []resource.TestCheckFunc{
resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.User)),
},
// ! Create testing
Create: testsacc.TFConfig{
TFConfig: testsacc.GenerateFromTemplate(resourceName, `
resource "cloudavenue_iam_user_saml" "example_quota_on_creation" {
user_name = "mickael.stanislas.ext"
role_name = "Organization Administrator"
deployed_vm_quota = 10
stored_vm_quota = 5
}`),
Checks: []resource.TestCheckFunc{
resource.TestCheckResourceAttr(resourceName, "user_name", "mickael.stanislas.ext"),
resource.TestCheckResourceAttr(resourceName, "role_name", "Organization Administrator"),
resource.TestCheckResourceAttr(resourceName, "enabled", "true"),
resource.TestCheckResourceAttr(resourceName, "deployed_vm_quota", "10"),
resource.TestCheckResourceAttr(resourceName, "stored_vm_quota", "5"),
resource.TestCheckResourceAttr(resourceName, "take_ownership", "true"),
},
},
// ! Updates testing
Updates: []testsacc.TFConfig{
// * unset quotas
{
TFConfig: testsacc.GenerateFromTemplate(resourceName, `
resource "cloudavenue_iam_user_saml" "example_quota_on_creation" {
user_name = "mickael.stanislas.ext"
role_name = "Organization Administrator"
}`),
Checks: []resource.TestCheckFunc{
resource.TestCheckResourceAttr(resourceName, "user_name", "mickael.stanislas.ext"),
resource.TestCheckResourceAttr(resourceName, "role_name", "Organization Administrator"),
resource.TestCheckResourceAttr(resourceName, "enabled", "true"),
resource.TestCheckResourceAttr(resourceName, "deployed_vm_quota", "0"),
resource.TestCheckResourceAttr(resourceName, "stored_vm_quota", "0"),
resource.TestCheckResourceAttr(resourceName, "take_ownership", "true"),
},
},
},
// ! Imports testing
Imports: []testsacc.TFImport{
{
ImportStateIDBuilder: []string{"user_name"},
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"take_ownership"},
},
},
}
},
}
Expand Down