@@ -218,7 +218,6 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
218218
219219 if options .Database == nil {
220220 options .Database , options .Pubsub = dbtestutil .NewDB (t )
221- options .Database = dbauthz .New (options .Database , options .Authorizer , options .Logger .Leveled (slog .LevelDebug ))
222221 }
223222
224223 // 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
260259 t .Cleanup (closeBatcher )
261260 }
262261
262+ accessControlStore := & atomic.Pointer [dbauthz.AccessControlStore ]{}
263+ var acs dbauthz.AccessControlStore = dbauthz.AGPLTemplateAccessControlStore {}
264+ accessControlStore .Store (& acs )
265+
263266 var templateScheduleStore atomic.Pointer [schedule.TemplateScheduleStore ]
264267 if options .TemplateScheduleStore == nil {
265268 options .TemplateScheduleStore = schedule .NewAGPLTemplateScheduleStore ()
@@ -279,6 +282,7 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
279282 options .Pubsub ,
280283 & templateScheduleStore ,
281284 & auditor ,
285+ accessControlStore ,
282286 * options .Logger ,
283287 options .AutobuildTicker ,
284288 ).WithStatsChannel (options .AutobuildStats )
@@ -416,6 +420,7 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
416420 Authorizer : options .Authorizer ,
417421 Telemetry : telemetry .NewNoop (),
418422 TemplateScheduleStore : & templateScheduleStore ,
423+ AccessControlStore : accessControlStore ,
419424 TLSCertificates : options .TLSCertificates ,
420425 TrialGenerator : options .TrialGenerator ,
421426 TailnetCoordinator : options .Coordinator ,
@@ -915,7 +920,7 @@ func CreateWorkspace(t testing.TB, client *codersdk.Client, organization uuid.UU
915920}
916921
917922// 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 {
919924 t .Helper ()
920925 ctx := context .Background ()
921926 workspace , err := client .Workspace (ctx , workspaceID )
@@ -925,10 +930,16 @@ func MustTransitionWorkspace(t testing.TB, client *codersdk.Client, workspaceID
925930 template , err := client .Template (ctx , workspace .TemplateID )
926931 require .NoError (t , err , "fetch workspace template" )
927932
928- build , err := client . CreateWorkspaceBuild ( ctx , workspace . ID , codersdk.CreateWorkspaceBuildRequest {
933+ req := codersdk.CreateWorkspaceBuildRequest {
929934 TemplateVersionID : template .ActiveVersionID ,
930935 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 )
932943 require .NoError (t , err , "unexpected error transitioning workspace to %s" , to )
933944
934945 _ = AwaitWorkspaceBuildJobCompleted (t , client , build .ID )
0 commit comments