- Notifications
You must be signed in to change notification settings - Fork4
fix: support unmanaged roles on user resource#250
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -42,6 +42,9 @@ func TestAccUserResource(t *testing.T) { | ||
cfg4.LoginType = ptr.Ref("github") | ||
cfg4.Password = nil | ||
cfg5 := cfg4 | ||
cfg5.Roles = nil | ||
resource.Test(t, resource.TestCase{ | ||
IsUnitTest: true, | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
@@ -68,7 +71,7 @@ func TestAccUserResource(t *testing.T) { | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
// We can't pull the password from the API. | ||
ImportStateVerifyIgnore: []string{"password", "roles"}, | ||
}, | ||
// ImportState by username | ||
{ | ||
@@ -77,7 +80,7 @@ func TestAccUserResource(t *testing.T) { | ||
ImportStateVerify: true, | ||
ImportStateId: "example", | ||
// We can't pull the password from the API. | ||
ImportStateVerifyIgnore: []string{"password", "roles"}, | ||
MemberAuthor
| ||
}, | ||
// Update and Read testing | ||
{ | ||
@@ -114,8 +117,42 @@ func TestAccUserResource(t *testing.T) { | ||
// The Plan should be to create the entire resource | ||
ExpectNonEmptyPlan: true, | ||
}, | ||
// Unmanaged roles | ||
{ | ||
Config: cfg5.String(t), | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
resource.TestCheckNoResourceAttr("coderd_user.test", "roles"), | ||
), | ||
}, | ||
}, | ||
}) | ||
t.Run("CreateUnmanagedRolesOk", func(t *testing.T) { | ||
cfg := testAccUserResourceConfig{ | ||
URL: client.URL.String(), | ||
Token: client.SessionToken(), | ||
Username: ptr.Ref("unmanaged"), | ||
Name: ptr.Ref("Unmanaged User"), | ||
Email: ptr.Ref("unmanaged@coder.com"), | ||
Roles: nil, // Start with unmanaged roles | ||
LoginType: ptr.Ref("password"), | ||
Password: ptr.Ref("SomeSecurePassword!"), | ||
} | ||
resource.Test(t, resource.TestCase{ | ||
IsUnitTest: true, | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: cfg.String(t), | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
resource.TestCheckNoResourceAttr("coderd_user.test", "roles"), | ||
), | ||
}, | ||
}, | ||
}) | ||
}) | ||
} | ||
type testAccUserResourceConfig struct { | ||
Uh oh!
There was an error while loading.Please reload this page.