Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcb49449

Browse files
committed
test: add unit test to create a workspace for a non-org-member
1 parenta4f1c64 commitcb49449

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

‎codersdk/deployment.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,7 @@ func (c *DeploymentValues) Options() serpent.OptionSet {
15211521
Value:&c.DERP.Config.BlockDirect,
15221522
Group:&deploymentGroupNetworkingDERP,
15231523
YAML:"blockDirect",Annotations: serpent.Annotations{}.
1524-
Mark(annotationExternalProxies,"true"),
1524+
Mark(annotationExternalProxies,"true"),
15251525
},
15261526
{
15271527
Name:"DERP Force WebSockets",
@@ -3380,7 +3380,6 @@ var ExperimentsKnown = Experiments{
33803380
ExperimentWebPush,
33813381
ExperimentWorkspacePrebuilds,
33823382
ExperimentAgenticChat,
3383-
ExperimentAITasks,
33843383
}
33853384

33863385
// ExperimentsSafe should include all experiments that are safe for

‎enterprise/coderd/workspaces_test.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,9 @@ func TestCreateUserWorkspace(t *testing.T) {
260260
},
261261
LicenseOptions:&coderdenttest.LicenseOptions{
262262
Features: license.Features{
263-
codersdk.FeatureCustomRoles:1,
264-
codersdk.FeatureTemplateRBAC:1,
263+
codersdk.FeatureCustomRoles:1,
264+
codersdk.FeatureTemplateRBAC:1,
265+
codersdk.FeatureMultipleOrganizations:1,
265266
},
266267
},
267268
})
@@ -277,9 +278,13 @@ func TestCreateUserWorkspace(t *testing.T) {
277278
}),
278279
})
279280
require.NoError(t,err)
281+
secondOrg:=coderdenttest.CreateOrganization(t,owner, coderdenttest.CreateOrganizationOptions{})
280282

281283
// use admin for setting up test
282-
admin,adminID:=coderdtest.CreateAnotherUser(t,owner,first.OrganizationID,rbac.RoleTemplateAdmin())
284+
admin,_:=coderdtest.CreateAnotherUser(t,owner,first.OrganizationID,rbac.RoleTemplateAdmin())
285+
286+
// user to make the workspace for, **note** the user is not a member of the first org.
287+
_,forUser:=coderdtest.CreateAnotherUser(t,owner,secondOrg.ID)
283288

284289
// try the test action with this user & custom role
285290
creator,_:=coderdtest.CreateAnotherUser(t,owner,first.OrganizationID,rbac.RoleMember(), rbac.RoleIdentifier{
@@ -293,14 +298,14 @@ func TestCreateUserWorkspace(t *testing.T) {
293298

294299
ctx=testutil.Context(t,testutil.WaitLong*1000)// Reset the context to avoid timeouts.
295300

296-
wrk,err:=creator.CreateUserWorkspace(ctx,adminID.ID.String(), codersdk.CreateWorkspaceRequest{
301+
wrk,err:=creator.CreateUserWorkspace(ctx,forUser.ID.String(), codersdk.CreateWorkspaceRequest{
297302
TemplateID:template.ID,
298303
Name:"workspace",
299304
})
300305
require.NoError(t,err)
301306
coderdtest.AwaitWorkspaceBuildJobCompleted(t,admin,wrk.LatestBuild.ID)
302307

303-
_,err=creator.WorkspaceByOwnerAndName(ctx,adminID.Username,wrk.Name, codersdk.WorkspaceOptions{
308+
_,err=creator.WorkspaceByOwnerAndName(ctx,forUser.Username,wrk.Name, codersdk.WorkspaceOptions{
304309
IncludeDeleted:false,
305310
})
306311
require.NoError(t,err)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp