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

Commit6b5ca6e

Browse files
committed
add test for mismatched orgID
1 parent3641875 commit6b5ca6e

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

‎enterprise/coderd/roles.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (h enterpriseCustomRoleHandler) PatchOrganizationRole(ctx context.Context,
5454
ifrole.OrganizationID!=orgID.String() {
5555
httpapi.Write(ctx,rw,http.StatusBadRequest, codersdk.Response{
5656
Message:"Invalid request, organization in role and url must match",
57-
Detail:fmt.Sprintf("roleorg%q does not match URL%q",role.OrganizationID,orgID.String()),
57+
Detail:fmt.Sprintf("roleorganization=%q does not match URL=%q",role.OrganizationID,orgID.String()),
5858
})
5959
return codersdk.Role{},false
6060
}

‎enterprise/coderd/roles_test.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func TestCustomOrganizationRole(t *testing.T) {
8989

9090
// Revoked licenses cannot modify/create custom roles, but they can
9191
// use the existing roles.
92-
t.Run("Revoked License",func(t*testing.T) {
92+
t.Run("RevokedLicense",func(t*testing.T) {
9393
t.Parallel()
9494
dv:=coderdtest.DeploymentValues(t)
9595
dv.Experiments= []string{string(codersdk.ExperimentCustomRoles)}
@@ -208,4 +208,26 @@ func TestCustomOrganizationRole(t *testing.T) {
208208
})
209209
require.ErrorContains(t,err,"Validation")
210210
})
211+
212+
t.Run("MismatchedOrganizations",func(t*testing.T) {
213+
t.Parallel()
214+
dv:=coderdtest.DeploymentValues(t)
215+
dv.Experiments= []string{string(codersdk.ExperimentCustomRoles)}
216+
owner,first:=coderdenttest.New(t,&coderdenttest.Options{
217+
Options:&coderdtest.Options{
218+
DeploymentValues:dv,
219+
},
220+
LicenseOptions:&coderdenttest.LicenseOptions{
221+
Features: license.Features{
222+
codersdk.FeatureCustomRoles:1,
223+
},
224+
},
225+
})
226+
227+
ctx:=testutil.Context(t,testutil.WaitMedium)
228+
229+
//nolint:gocritic // owner is required for this
230+
_,err:=owner.PatchOrganizationRole(ctx,first.OrganizationID,templateAdminCustom(uuid.New()))
231+
require.ErrorContains(t,err,"does not match")
232+
})
211233
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp