- Notifications
You must be signed in to change notification settings - Fork928
fix: include dormant users in template acl query#14461
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 |
---|---|---|
@@ -1025,6 +1025,46 @@ func TestTemplateACL(t *testing.T) { | ||
require.Len(t, acl.Users, 0, "deleted users should be filtered") | ||
}) | ||
// Test that we do not filter dormant users. | ||
t.Run("IncludeDormantUsers", func(t *testing.T) { | ||
t.Parallel() | ||
client, user := coderdenttest.New(t, &coderdenttest.Options{LicenseOptions: &coderdenttest.LicenseOptions{ | ||
Features: license.Features{ | ||
codersdk.FeatureTemplateRBAC: 1, | ||
}, | ||
}}) | ||
anotherClient, _ := coderdtest.CreateAnotherUser(t, client, user.OrganizationID, rbac.RoleTemplateAdmin(), rbac.RoleUserAdmin()) | ||
ctx := testutil.Context(t, testutil.WaitLong) | ||
// nolint:gocritic // Must use owner to create user. | ||
user1, err := client.CreateUserWithOrgs(ctx, codersdk.CreateUserRequestWithOrgs{ | ||
Email: "coder@coder.com", | ||
Username: "coder", | ||
Password: "SomeStrongPassword!", | ||
OrganizationIDs: []uuid.UUID{user.OrganizationID}, | ||
}) | ||
require.NoError(t, err) | ||
require.Equal(t, codersdk.UserStatusDormant, user1.Status) | ||
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil) | ||
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID) | ||
err = anotherClient.UpdateTemplateACL(ctx, template.ID, codersdk.UpdateTemplateACL{ | ||
UserPerms: map[string]codersdk.TemplateRole{ | ||
user1.ID.String(): codersdk.TemplateRoleUse, | ||
}, | ||
}) | ||
require.NoError(t, err) | ||
acl, err := anotherClient.TemplateACL(ctx, template.ID) | ||
require.NoError(t, err) | ||
require.Contains(t, acl.Users, codersdk.TemplateUser{ | ||
User: user1, | ||
Role: codersdk.TemplateRoleUse, | ||
}) | ||
}) | ||
// Test that we do not return suspended users. | ||
t.Run("FilterSuspendedUsers", func(t *testing.T) { | ||
MemberAuthor
| ||
t.Parallel() | ||
Uh oh!
There was an error while loading.Please reload this page.