Skip to content

Commit fa399d6

Browse files
committed
steven said its ok to remove this
1 parent 76a490e commit fa399d6

File tree

1 file changed

+2
-78
lines changed

1 file changed

+2
-78
lines changed

coderd/authzquery/workspace_test.go

Lines changed: 2 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,12 @@ package authzquery_test
33
import (
44
"context"
55
"testing"
6-
"time"
76

8-
"github.com/moby/moby/pkg/namesgenerator"
9-
10-
"github.com/coder/coder/coderd/rbac"
11-
12-
"github.com/google/uuid"
137
"github.com/stretchr/testify/require"
148

15-
"github.com/coder/coder/coderd/database"
16-
179
"github.com/coder/coder/coderd/authzquery"
18-
"github.com/coder/coder/coderd/coderdtest"
19-
"github.com/coder/coder/coderd/database/databasefake"
10+
"github.com/coder/coder/coderd/database"
11+
"github.com/coder/coder/coderd/rbac"
2012
)
2113

2214
func TestWorkspaceFunctions(t *testing.T) {
@@ -92,75 +84,7 @@ func TestWorkspaceFunctions(t *testing.T) {
9284
tc := tc
9385
t.Run(tc.Name, func(t *testing.T) {
9486
t.Parallel()
95-
9687
testAuthorizeFunction(t, tc.Config)
9788
})
9889
}
99-
100-
}
101-
102-
func TestWorkspace(t *testing.T) {
103-
// GetWorkspaceByID
104-
var (
105-
db = databasefake.New()
106-
// TODO: Recorder should record all authz calls
107-
rec = &coderdtest.RecordingAuthorizer{}
108-
q = authzquery.NewAuthzQuerier(db, rec)
109-
actor = rbac.Subject{
110-
ID: uuid.New().String(),
111-
Roles: rbac.RoleNames{rbac.RoleOwner()},
112-
Groups: []string{},
113-
Scope: rbac.ScopeAll,
114-
}
115-
ctx = authzquery.WithAuthorizeContext(context.Background(), actor)
116-
)
117-
118-
workspace := insertRandomWorkspace(t, db)
119-
120-
// Test recorder
121-
_, err := q.GetWorkspaceByID(ctx, workspace.ID)
122-
require.NoError(t, err)
123-
124-
_, err = q.UpdateWorkspace(ctx, database.UpdateWorkspaceParams{
125-
ID: workspace.ID,
126-
Name: "new-name",
127-
})
128-
require.NoError(t, err)
129-
130-
rec.AssertActor(t, actor,
131-
rec.Pair(rbac.ActionRead, workspace),
132-
rec.Pair(rbac.ActionUpdate, workspace),
133-
)
134-
require.NoError(t, rec.AllAsserted())
135-
}
136-
137-
func insertRandomWorkspace(t *testing.T, db database.Store, opts ...func(w *database.Workspace)) database.Workspace {
138-
workspace := &database.Workspace{
139-
ID: uuid.New(),
140-
CreatedAt: time.Now().Add(time.Hour * -1),
141-
UpdatedAt: time.Now(),
142-
OwnerID: uuid.New(),
143-
OrganizationID: uuid.New(),
144-
TemplateID: uuid.New(),
145-
Deleted: false,
146-
Name: namesgenerator.GetRandomName(1),
147-
LastUsedAt: time.Now(),
148-
}
149-
for _, opt := range opts {
150-
opt(workspace)
151-
}
152-
153-
newWorkspace, err := db.InsertWorkspace(context.Background(), database.InsertWorkspaceParams{
154-
ID: workspace.ID,
155-
CreatedAt: workspace.CreatedAt,
156-
UpdatedAt: workspace.UpdatedAt,
157-
OwnerID: workspace.OwnerID,
158-
OrganizationID: workspace.OrganizationID,
159-
TemplateID: workspace.TemplateID,
160-
Name: workspace.Name,
161-
AutostartSchedule: workspace.AutostartSchedule,
162-
Ttl: workspace.Ttl,
163-
})
164-
require.NoError(t, err, "insert workspace")
165-
return newWorkspace
16690
}

0 commit comments

Comments
 (0)