(t *testing.T)
| 176 | } |
| 177 | |
| 178 | func TestSharingStatus(t *testing.T) { |
| 179 | t.Parallel() |
| 180 | |
| 181 | t.Run("ListSharedUsers", func(t *testing.T) { |
| 182 | t.Parallel() |
| 183 | |
| 184 | var ( |
| 185 | client, db, orgOwner = coderdenttest.NewWithDatabase(t, &coderdenttest.Options{ |
| 186 | LicenseOptions: &coderdenttest.LicenseOptions{ |
| 187 | Features: license.Features{ |
| 188 | codersdk.FeatureTemplateRBAC: 1, |
| 189 | }, |
| 190 | }, |
| 191 | }) |
| 192 | workspaceOwnerClient, workspaceOwner = coderdtest.CreateAnotherUser(t, client, orgOwner.OrganizationID, rbac.ScopedRoleOrgAuditor(orgOwner.OrganizationID)) |
| 193 | workspace = dbfake.WorkspaceBuild(t, db, database.WorkspaceTable{ |
| 194 | OwnerID: workspaceOwner.ID, |
| 195 | OrganizationID: orgOwner.OrganizationID, |
| 196 | }).Do().Workspace |
| 197 | _, orgMember = coderdtest.CreateAnotherUser(t, client, orgOwner.OrganizationID) |
| 198 | ctx = testutil.Context(t, testutil.WaitMedium) |
| 199 | ) |
| 200 | |
| 201 | group, err := createGroupWithMembers(ctx, client, orgOwner.OrganizationID, "new-group", []uuid.UUID{orgMember.ID}) |
| 202 | require.NoError(t, err) |
| 203 | |
| 204 | err = client.UpdateWorkspaceACL(ctx, workspace.ID, codersdk.UpdateWorkspaceACL{ |
| 205 | GroupRoles: map[string]codersdk.WorkspaceRole{ |
| 206 | group.ID.String(): codersdk.WorkspaceRoleUse, |
| 207 | }, |
| 208 | }) |
| 209 | require.NoError(t, err) |
| 210 | |
| 211 | inv, root := clitest.New(t, "sharing", "status", workspace.Name) |
| 212 | clitest.SetupConfig(t, workspaceOwnerClient, root) |
| 213 | |
| 214 | out := new(bytes.Buffer) |
| 215 | inv.Stdout = out |
| 216 | err = inv.WithContext(ctx).Run() |
| 217 | require.NoError(t, err) |
| 218 | |
| 219 | found := false |
| 220 | for _, line := range strings.Split(out.String(), "\n") { |
| 221 | if strings.Contains(line, orgMember.Username) && strings.Contains(line, string(codersdk.WorkspaceRoleUse)) && strings.Contains(line, group.Name) { |
| 222 | found = true |
| 223 | break |
| 224 | } |
| 225 | } |
| 226 | assert.True(t, found, "expected to find username %s with role %s in the output: %s", orgMember.Username, codersdk.WorkspaceRoleUse, out.String()) |
| 227 | }) |
| 228 | } |
| 229 | |
| 230 | func TestSharingRemove(t *testing.T) { |
| 231 | t.Parallel() |
nothing calls this directly
no test coverage detected