mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
fix: allow workspace owners to view timings (#15364)
Anyone with authz access to a workspace should be able to read timings information of its builds. To do this without `AsSystemContext` would do an extra 4 db calls.
This commit is contained in:
@ -1188,17 +1188,19 @@ func TestWorkspaceBuildTimings(t *testing.T) {
|
||||
|
||||
// Setup the test environment with a template and version
|
||||
db, pubsub := dbtestutil.NewDB(t)
|
||||
client := coderdtest.New(t, &coderdtest.Options{
|
||||
ownerClient := coderdtest.New(t, &coderdtest.Options{
|
||||
Database: db,
|
||||
Pubsub: pubsub,
|
||||
})
|
||||
owner := coderdtest.CreateFirstUser(t, client)
|
||||
owner := coderdtest.CreateFirstUser(t, ownerClient)
|
||||
client, user := coderdtest.CreateAnotherUser(t, ownerClient, owner.OrganizationID)
|
||||
|
||||
file := dbgen.File(t, db, database.File{
|
||||
CreatedBy: owner.UserID,
|
||||
})
|
||||
versionJob := dbgen.ProvisionerJob(t, db, pubsub, database.ProvisionerJob{
|
||||
OrganizationID: owner.OrganizationID,
|
||||
InitiatorID: owner.UserID,
|
||||
InitiatorID: user.ID,
|
||||
FileID: file.ID,
|
||||
Tags: database.StringMap{
|
||||
"custom": "true",
|
||||
@ -1219,7 +1221,7 @@ func TestWorkspaceBuildTimings(t *testing.T) {
|
||||
// build number, each test will have its own workspace and build.
|
||||
makeBuild := func() database.WorkspaceBuild {
|
||||
ws := dbgen.Workspace(t, db, database.WorkspaceTable{
|
||||
OwnerID: owner.UserID,
|
||||
OwnerID: user.ID,
|
||||
OrganizationID: owner.OrganizationID,
|
||||
TemplateID: template.ID,
|
||||
})
|
||||
|
Reference in New Issue
Block a user