@@ -260,8 +260,9 @@ func TestCreateUserWorkspace(t *testing.T) {
260
260
},
261
261
LicenseOptions :& coderdenttest.LicenseOptions {
262
262
Features : license.Features {
263
- codersdk .FeatureCustomRoles :1 ,
264
- codersdk .FeatureTemplateRBAC :1 ,
263
+ codersdk .FeatureCustomRoles :1 ,
264
+ codersdk .FeatureTemplateRBAC :1 ,
265
+ codersdk .FeatureMultipleOrganizations :1 ,
265
266
},
266
267
},
267
268
})
@@ -278,29 +279,34 @@ func TestCreateUserWorkspace(t *testing.T) {
278
279
})
279
280
require .NoError (t ,err )
280
281
281
- // use admin for setting up test
282
- admin ,adminID := coderdtest .CreateAnotherUser (t ,owner ,first .OrganizationID ,rbac .RoleTemplateAdmin ())
282
+ secondOrg := coderdenttest .CreateOrganization (t ,owner , coderdenttest.CreateOrganizationOptions {})
283
+
284
+ // user to make the workspace for, **note** the user is not a member of the first org.
285
+ // This is strange, but technically valid. The creator can create a workspace for
286
+ // this user in this org, even though the user cannot access the workspace.
287
+ _ ,forUser := coderdtest .CreateAnotherUser (t ,owner ,secondOrg .ID )
288
+
289
+ // Need an admin to make the template
290
+ admin ,_ := coderdtest .CreateAnotherUser (t ,owner ,first .OrganizationID ,rbac .ScopedRoleOrgTemplateAdmin (first .OrganizationID ))
283
291
284
292
// try the test action with this user & custom role
285
293
creator ,_ := coderdtest .CreateAnotherUser (t ,owner ,first .OrganizationID ,rbac .RoleMember (), rbac.RoleIdentifier {
286
294
Name :r .Name ,
287
295
OrganizationID :first .OrganizationID ,
288
296
})
289
297
290
- version := coderdtest .CreateTemplateVersion (t ,admin ,first .OrganizationID ,nil )
291
- coderdtest .AwaitTemplateVersionJobCompleted (t ,admin ,version .ID )
292
- template := coderdtest .CreateTemplate (t ,admin ,first .OrganizationID ,version .ID )
298
+ template ,_ := coderdtest .DynamicParameterTemplate (t ,admin ,first .OrganizationID , coderdtest.DynamicParameterTemplateParams {})
293
299
294
300
ctx = testutil .Context (t ,testutil .WaitLong * 1000 )// Reset the context to avoid timeouts.
295
301
296
- wrk ,err := creator .CreateUserWorkspace (ctx ,adminID .ID .String (), codersdk.CreateWorkspaceRequest {
302
+ wrk ,err := creator .CreateUserWorkspace (ctx ,forUser .ID .String (), codersdk.CreateWorkspaceRequest {
297
303
TemplateID :template .ID ,
298
304
Name :"workspace" ,
299
305
})
300
306
require .NoError (t ,err )
301
- coderdtest .AwaitWorkspaceBuildJobCompleted (t ,admin ,wrk .LatestBuild .ID )
307
+ coderdtest .AwaitWorkspaceBuildJobCompleted (t ,creator ,wrk .LatestBuild .ID )
302
308
303
- _ ,err = creator .WorkspaceByOwnerAndName (ctx ,adminID .Username ,wrk .Name , codersdk.WorkspaceOptions {
309
+ _ ,err = creator .WorkspaceByOwnerAndName (ctx ,forUser .Username ,wrk .Name , codersdk.WorkspaceOptions {
304
310
IncludeDeleted :false ,
305
311
})
306
312
require .NoError (t ,err )