Skip to content

Commit 1bc8556

Browse files
committed
assertUniqueRoutes
1 parent a565c15 commit 1bc8556

File tree

5 files changed

+72
-1
lines changed

5 files changed

+72
-1
lines changed

coderd/apidoc/docs.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,26 @@ const docTemplate = `{
15731573
}
15741574
},
15751575
"/scim/v2/Users": {
1576+
"get": {
1577+
"security": [
1578+
{
1579+
"CoderSessionToken": []
1580+
}
1581+
],
1582+
"produces": [
1583+
"application/scim+json"
1584+
],
1585+
"tags": [
1586+
"Enterprise"
1587+
],
1588+
"summary": "SCIM 2.0: Get users",
1589+
"operationId": "scim-get-users",
1590+
"responses": {
1591+
"200": {
1592+
"description": "OK"
1593+
}
1594+
}
1595+
},
15761596
"post": {
15771597
"security": [
15781598
{

coderd/apidoc/swagger.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,6 +1373,22 @@
13731373
}
13741374
},
13751375
"/scim/v2/Users": {
1376+
"get": {
1377+
"security": [
1378+
{
1379+
"CoderSessionToken": []
1380+
}
1381+
],
1382+
"produces": ["application/scim+json"],
1383+
"tags": ["Enterprise"],
1384+
"summary": "SCIM 2.0: Get users",
1385+
"operationId": "scim-get-users",
1386+
"responses": {
1387+
"200": {
1388+
"description": "OK"
1389+
}
1390+
}
1391+
},
13761392
"post": {
13771393
"security": [
13781394
{

coderd/coderdtest/swaggerparser.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ func parseSwaggerComment(commentGroup *ast.CommentGroup) SwaggerComment {
118118
}
119119

120120
func VerifySwaggerDefinitions(t *testing.T, router chi.Router, swaggerComments []SwaggerComment) {
121+
assertUniqueRoutes(t, swaggerComments)
122+
121123
err := chi.Walk(router, func(method, route string, handler http.Handler, middlewares ...func(http.Handler) http.Handler) error {
122124
method = strings.ToLower(method)
123125
if route != "/" && strings.HasSuffix(route, "/") {
@@ -223,3 +225,16 @@ func assertSecurityDefined(t *testing.T, comment SwaggerComment) {
223225
}
224226
assert.Equal(t, "CoderSessionToken", comment.security, "@Security must be equal CoderSessionToken")
225227
}
228+
229+
func assertUniqueRoutes(t *testing.T, comments []SwaggerComment) {
230+
m := map[string]struct{}{}
231+
232+
for _, c := range comments {
233+
key := c.method + " " + c.router
234+
_, alreadyDefined := m[key]
235+
assert.False(t, alreadyDefined, "defined route must be unique (method: %s, route: %s)", c.method, c.router)
236+
if !alreadyDefined {
237+
m[key] = struct{}{}
238+
}
239+
}
240+
}

docs/api/enterprise.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,26 @@ Status Code **200**
787787

788788
To perform this operation, you must be authenticated. [Learn more](authentication.md).
789789

790+
## SCIM 2.0: Get users
791+
792+
### Code samples
793+
794+
```shell
795+
# Example request using curl
796+
curl -X GET http://coder-server:8080/api/v2/scim/v2/Users \
797+
-H 'Coder-Session-Token: API_KEY'
798+
```
799+
800+
`GET /scim/v2/Users`
801+
802+
### Responses
803+
804+
| Status | Meaning | Description | Schema |
805+
| ------ | ------------------------------------------------------- | ----------- | ------ |
806+
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | |
807+
808+
To perform this operation, you must be authenticated. [Learn more](authentication.md).
809+
790810
## SCIM 2.0: Create new user
791811

792812
### Code samples

enterprise/coderd/scim.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (api *API) scimVerifyAuthHeader(r *http.Request) bool {
4949
// @Produce application/scim+json
5050
// @Tags Enterprise
5151
// @Success 200
52-
// @Router /scim/v2/Users [post]
52+
// @Router /scim/v2/Users [get]
5353
//
5454
//nolint:revive
5555
func (api *API) scimGetUsers(rw http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)