Skip to content

Commit d8fd433

Browse files
committed
fix test
1 parent 8e3bdc2 commit d8fd433

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

coderd/httpmw/groupparam.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ func ExtractGroupByNameParam(db database.Store) func(http.Handler) http.Handler
5555
}
5656

5757
ctx = context.WithValue(ctx, groupParamContextKey{}, group)
58+
chi.RouteContext(ctx).URLParams.Add("organization", group.OrganizationID.String())
5859
next.ServeHTTP(rw, r.WithContext(ctx))
5960
})
6061
}

enterprise/coderd/coderdenttest/coderdenttest_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func TestAuthorizeAllEndpoints(t *testing.T) {
4444
a := coderdtest.NewAuthTester(ctx, t, client, api.AGPL, admin)
4545
a.URLParams["licenses/{id}"] = fmt.Sprintf("licenses/%d", license.ID)
4646
a.URLParams["groups/{group}"] = fmt.Sprintf("groups/%s", group.ID.String())
47+
a.URLParams["{groupName}"] = group.Name
4748

4849
skipRoutes, assertRoute := coderdtest.AGPLRoutes(a)
4950
assertRoute["GET:/api/v2/entitlements"] = coderdtest.RouteCheck{
@@ -79,7 +80,11 @@ func TestAuthorizeAllEndpoints(t *testing.T) {
7980
AssertAction: rbac.ActionRead,
8081
AssertObject: groupObj,
8182
}
82-
assertRoute["PATCH:/api/v2/groups/{group}"] = coderdtest.RouteCheck{
83+
assertRoute["GET:/api/v2/organizations/{organization}/groups/{groupName}"] = coderdtest.RouteCheck{
84+
AssertAction: rbac.ActionRead,
85+
AssertObject: groupObj,
86+
}
87+
assertRoute["GET:/api/v2/groups/{group}"] = coderdtest.RouteCheck{
8388
AssertAction: rbac.ActionRead,
8489
AssertObject: groupObj,
8590
}

0 commit comments

Comments
 (0)