(t *testing.T)
| 4611 | } |
| 4612 | |
| 4613 | func TestWorkspacesSharedWith(t *testing.T) { |
| 4614 | t.Parallel() |
| 4615 | |
| 4616 | t.Run("ContainsActorsWithFullData", func(t *testing.T) { |
| 4617 | t.Parallel() |
| 4618 | |
| 4619 | dv := coderdtest.DeploymentValues(t) |
| 4620 | |
| 4621 | client, db, user := coderdenttest.NewWithDatabase(t, &coderdenttest.Options{ |
| 4622 | Options: &coderdtest.Options{ |
| 4623 | DeploymentValues: dv, |
| 4624 | }, |
| 4625 | LicenseOptions: &coderdenttest.LicenseOptions{ |
| 4626 | Features: license.Features{ |
| 4627 | codersdk.FeatureTemplateRBAC: 1, |
| 4628 | }, |
| 4629 | }, |
| 4630 | }) |
| 4631 | |
| 4632 | _, workspaceOwner := coderdtest.CreateAnotherUser(t, client, user.OrganizationID) |
| 4633 | |
| 4634 | workspace := dbfake.WorkspaceBuild(t, db, database.WorkspaceTable{ |
| 4635 | OwnerID: workspaceOwner.ID, |
| 4636 | OrganizationID: user.OrganizationID, |
| 4637 | }).Do().Workspace |
| 4638 | |
| 4639 | _, sharedWithUser := coderdtest.CreateAnotherUser(t, client, user.OrganizationID) |
| 4640 | |
| 4641 | ctx := testutil.Context(t, testutil.WaitMedium) |
| 4642 | |
| 4643 | // Update a shared with user to have a name and avatar |
| 4644 | _, err := db.UpdateUserProfile(dbauthz.AsSystemRestricted(ctx), database.UpdateUserProfileParams{ |
| 4645 | ID: sharedWithUser.ID, |
| 4646 | Email: sharedWithUser.Email, |
| 4647 | Username: sharedWithUser.Username, |
| 4648 | Name: "Shared User Name", |
| 4649 | AvatarURL: "/emojis/1fae1.png", |
| 4650 | }) |
| 4651 | require.NoError(t, err) |
| 4652 | |
| 4653 | // Create a shared with group with a name and avatar |
| 4654 | sharedWithGroup, err := client.CreateGroup(ctx, user.OrganizationID, codersdk.CreateGroupRequest{ |
| 4655 | Name: "shared-with-group", |
| 4656 | AvatarURL: "/emojis/1f60d.png", |
| 4657 | }) |
| 4658 | require.NoError(t, err) |
| 4659 | |
| 4660 | // Share workspace with user and group |
| 4661 | err = client.UpdateWorkspaceACL(ctx, workspace.ID, codersdk.UpdateWorkspaceACL{ |
| 4662 | UserRoles: map[string]codersdk.WorkspaceRole{ |
| 4663 | sharedWithUser.ID.String(): codersdk.WorkspaceRoleUse, |
| 4664 | }, |
| 4665 | GroupRoles: map[string]codersdk.WorkspaceRole{ |
| 4666 | sharedWithGroup.ID.String(): codersdk.WorkspaceRoleAdmin, |
| 4667 | }, |
| 4668 | }) |
| 4669 | require.NoError(t, err) |
| 4670 |
nothing calls this directly
no test coverage detected