feat: expose Everyone group through UI (#9117)

- Allows setting quota allowances on the 'Everyone' group.
This commit is contained in:
Jon Ayers
2023-08-17 13:25:16 -05:00
committed by GitHub
parent 8910f05172
commit 2f6687a475
23 changed files with 458 additions and 80 deletions

View File

@ -525,7 +525,7 @@ func TestGroupSync(t *testing.T) {
require.NoError(t, err)
for _, group := range orgGroups {
if slice.Contains(tc.initialOrgGroups, group.Name) {
if slice.Contains(tc.initialOrgGroups, group.Name) || group.IsEveryone() {
require.Equal(t, group.Source, codersdk.GroupSourceUser)
} else {
require.Equal(t, group.Source, codersdk.GroupSourceOIDC)
@ -543,6 +543,7 @@ func TestGroupSync(t *testing.T) {
}
delete(orgGroupsMap, expected)
}
delete(orgGroupsMap, database.EveryoneGroup)
require.Empty(t, orgGroupsMap, "unexpected groups found")
expectedUserGroups := make(map[string]struct{})
@ -554,7 +555,9 @@ func TestGroupSync(t *testing.T) {
userInGroup := slice.ContainsCompare(group.Members, codersdk.User{Email: user.Email}, func(a, b codersdk.User) bool {
return a.Email == b.Email
})
if _, ok := expectedUserGroups[group.Name]; ok {
if group.IsEveryone() {
require.True(t, userInGroup, "user cannot be removed from 'Everyone' group")
} else if _, ok := expectedUserGroups[group.Name]; ok {
require.Truef(t, userInGroup, "user should be in group %s", group.Name)
} else {
require.Falsef(t, userInGroup, "user should not be in group %s", group.Name)