MCPcopy Index your code
hub / github.com/coder/coder / TestDeleteWorkspaceACL

Function TestDeleteWorkspaceACL

enterprise/coderd/workspaces_test.go:4518–4611  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

4516}
4517
4518func TestDeleteWorkspaceACL(t *testing.T) {
4519 t.Parallel()
4520
4521 t.Run("WorkspaceOwnerCanDelete_Groups", func(t *testing.T) {
4522 t.Parallel()
4523
4524 var (
4525 client, db, admin = coderdenttest.NewWithDatabase(t, &coderdenttest.Options{
4526 Options: &coderdtest.Options{
4527 DeploymentValues: coderdtest.DeploymentValues(t, func(dv *codersdk.DeploymentValues) {
4528 }),
4529 },
4530 LicenseOptions: &coderdenttest.LicenseOptions{
4531 Features: license.Features{
4532 codersdk.FeatureTemplateRBAC: 1,
4533 },
4534 },
4535 })
4536 workspaceOwnerClient, workspaceOwner = coderdtest.CreateAnotherUser(t, client, admin.OrganizationID, rbac.ScopedRoleOrgAuditor(admin.OrganizationID))
4537 workspace = dbfake.WorkspaceBuild(t, db, database.WorkspaceTable{
4538 OwnerID: workspaceOwner.ID,
4539 OrganizationID: admin.OrganizationID,
4540 }).Do().Workspace
4541 )
4542
4543 ctx := testutil.Context(t, testutil.WaitMedium)
4544
4545 group, err := client.CreateGroup(ctx, admin.OrganizationID, codersdk.CreateGroupRequest{
4546 Name: "wibble",
4547 })
4548 require.NoError(t, err)
4549 err = client.UpdateWorkspaceACL(ctx, workspace.ID, codersdk.UpdateWorkspaceACL{
4550 GroupRoles: map[string]codersdk.WorkspaceRole{
4551 group.ID.String(): codersdk.WorkspaceRoleUse,
4552 },
4553 })
4554 require.NoError(t, err)
4555
4556 err = workspaceOwnerClient.DeleteWorkspaceACL(ctx, workspace.ID)
4557 require.NoError(t, err)
4558
4559 acl, err := workspaceOwnerClient.WorkspaceACL(ctx, workspace.ID)
4560 require.NoError(t, err)
4561 require.Empty(t, acl.Groups)
4562 })
4563
4564 t.Run("SharedGroupUsersCannotDelete", func(t *testing.T) {
4565 t.Parallel()
4566
4567 var (
4568 client, db, admin = coderdenttest.NewWithDatabase(t, &coderdenttest.Options{
4569 Options: &coderdtest.Options{
4570 DeploymentValues: coderdtest.DeploymentValues(t, func(dv *codersdk.DeploymentValues) {
4571 }),
4572 },
4573 LicenseOptions: &coderdenttest.LicenseOptions{
4574 Features: license.Features{
4575 codersdk.FeatureTemplateRBAC: 1,

Callers

nothing calls this directly

Calls 15

NewWithDatabaseFunction · 0.92
DeploymentValuesFunction · 0.92
CreateAnotherUserFunction · 0.92
ScopedRoleOrgAuditorFunction · 0.92
WorkspaceBuildFunction · 0.92
ContextFunction · 0.92
CreateGroupMethod · 0.80
UpdateWorkspaceACLMethod · 0.80
DeleteWorkspaceACLMethod · 0.80
WorkspaceACLMethod · 0.80
PatchGroupMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected