@@ -218,7 +218,6 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
218
218
219
219
if options .Database == nil {
220
220
options .Database , options .Pubsub = dbtestutil .NewDB (t )
221
- options .Database = dbauthz .New (options .Database , options .Authorizer , options .Logger .Leveled (slog .LevelDebug ))
222
221
}
223
222
224
223
// Some routes expect a deployment ID, so just make sure one exists.
@@ -260,6 +259,10 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
260
259
t .Cleanup (closeBatcher )
261
260
}
262
261
262
+ accessControlStore := & atomic.Pointer [dbauthz.AccessControlStore ]{}
263
+ var acs dbauthz.AccessControlStore = dbauthz.AGPLTemplateAccessControlStore {}
264
+ accessControlStore .Store (& acs )
265
+
263
266
var templateScheduleStore atomic.Pointer [schedule.TemplateScheduleStore ]
264
267
if options .TemplateScheduleStore == nil {
265
268
options .TemplateScheduleStore = schedule .NewAGPLTemplateScheduleStore ()
@@ -279,6 +282,7 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
279
282
options .Pubsub ,
280
283
& templateScheduleStore ,
281
284
& auditor ,
285
+ accessControlStore ,
282
286
* options .Logger ,
283
287
options .AutobuildTicker ,
284
288
).WithStatsChannel (options .AutobuildStats )
@@ -416,6 +420,7 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
416
420
Authorizer : options .Authorizer ,
417
421
Telemetry : telemetry .NewNoop (),
418
422
TemplateScheduleStore : & templateScheduleStore ,
423
+ AccessControlStore : accessControlStore ,
419
424
TLSCertificates : options .TLSCertificates ,
420
425
TrialGenerator : options .TrialGenerator ,
421
426
TailnetCoordinator : options .Coordinator ,
@@ -915,7 +920,7 @@ func CreateWorkspace(t testing.TB, client *codersdk.Client, organization uuid.UU
915
920
}
916
921
917
922
// TransitionWorkspace is a convenience method for transitioning a workspace from one state to another.
918
- func MustTransitionWorkspace (t testing.TB , client * codersdk.Client , workspaceID uuid.UUID , from , to database.WorkspaceTransition ) codersdk.Workspace {
923
+ func MustTransitionWorkspace (t testing.TB , client * codersdk.Client , workspaceID uuid.UUID , from , to database.WorkspaceTransition , muts ... func ( req * codersdk. CreateWorkspaceBuildRequest ) ) codersdk.Workspace {
919
924
t .Helper ()
920
925
ctx := context .Background ()
921
926
workspace , err := client .Workspace (ctx , workspaceID )
@@ -925,10 +930,16 @@ func MustTransitionWorkspace(t testing.TB, client *codersdk.Client, workspaceID
925
930
template , err := client .Template (ctx , workspace .TemplateID )
926
931
require .NoError (t , err , "fetch workspace template" )
927
932
928
- build , err := client . CreateWorkspaceBuild ( ctx , workspace . ID , codersdk.CreateWorkspaceBuildRequest {
933
+ req := codersdk.CreateWorkspaceBuildRequest {
929
934
TemplateVersionID : template .ActiveVersionID ,
930
935
Transition : codersdk .WorkspaceTransition (to ),
931
- })
936
+ }
937
+
938
+ for _ , mut := range muts {
939
+ mut (& req )
940
+ }
941
+
942
+ build , err := client .CreateWorkspaceBuild (ctx , workspace .ID , req )
932
943
require .NoError (t , err , "unexpected error transitioning workspace to %s" , to )
933
944
934
945
_ = AwaitWorkspaceBuildJobCompleted (t , client , build .ID )
0 commit comments