Skip to content

Commit 88849b2

Browse files
authored
use correct query params when requiring middleware (frain-dev#569)
* patch: use correct query params when requiring middleware * chore: update tests * chore: update immune e2e tests * chore: update immune version
1 parent 7e70e39 commit 88849b2

12 files changed

+39
-21
lines changed

.github/workflows/immune-test.yml

+11-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,17 @@ jobs:
1010
if: ${{ !(contains(github.head_ref, 'ui/')) || !(contains(github.head_ref, 'cms/')) }}
1111
strategy:
1212
matrix:
13-
go-version: [ 1.16.x, 1.17.x ]
14-
immune-test-file-names: [ "test-push-events.json", "test-groups.json", "test-apps.json", "test-app-endpoints.json" ]
15-
immune-version: [ "0.2.0" ]
16-
mongodb-version: [ "4.0", "4.2", "4.4" ]
17-
redis-version: [ "6.2.6" ]
13+
go-version: [1.16.x, 1.17.x]
14+
immune-test-file-names:
15+
[
16+
"test-push-events.json",
17+
"test-groups.json",
18+
"test-apps.json",
19+
"test-app-endpoints.json",
20+
]
21+
immune-version: ["0.2.1"]
22+
mongodb-version: ["4.0", "4.2", "4.4"]
23+
redis-version: ["6.2.6"]
1824

1925
runs-on: ubuntu-latest
2026
steps:

docs/docs.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
22
// This file was generated by swaggo/swag at
3-
// 2022-03-25 14:06:05.305615 +0100 WAT m=+92.786899085
4-
3+
// 2022-03-31 14:34:17.168249328 +0100 WAT m=+76.372055978
54
package docs
65

76
import (
@@ -4111,6 +4110,9 @@ var doc = `{
41114110
"disable_endpoint": {
41124111
"type": "boolean"
41134112
},
4113+
"replay_attacks": {
4114+
"type": "boolean"
4115+
},
41144116
"signature": {
41154117
"$ref": "#/definitions/datastore.SignatureConfiguration"
41164118
},

docs/swagger.json

+3
Original file line numberDiff line numberDiff line change
@@ -4098,6 +4098,9 @@
40984098
"disable_endpoint": {
40994099
"type": "boolean"
41004100
},
4101+
"replay_attacks": {
4102+
"type": "boolean"
4103+
},
41014104
"signature": {
41024105
"$ref": "#/definitions/datastore.SignatureConfiguration"
41034106
},

docs/swagger.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ definitions:
258258
properties:
259259
disable_endpoint:
260260
type: boolean
261+
replay_attacks:
262+
type: boolean
261263
signature:
262264
$ref: '#/definitions/datastore.SignatureConfiguration'
263265
strategy:

docs/v3/openapi3.json

+3
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,9 @@
382382
"disable_endpoint": {
383383
"type": "boolean"
384384
},
385+
"replay_attacks": {
386+
"type": "boolean"
387+
},
385388
"signature": {
386389
"$ref": "#/components/schemas/datastore.SignatureConfiguration"
387390
},

docs/v3/openapi3.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ components:
257257
properties:
258258
disable_endpoint:
259259
type: boolean
260+
replay_attacks:
261+
type: boolean
260262
signature:
261263
$ref: '#/components/schemas/datastore.SignatureConfiguration'
262264
strategy:

immune-test-files/test-app-endpoints.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"setup_endpoint"
1414
],
1515
"http_method": "GET",
16-
"endpoint": "/applications/{app_id}/endpoints/{endpoint_id}?groupID={group_id}",
16+
"endpoint": "/applications/{app_id}/endpoints/{endpoint_id}?groupId={group_id}",
1717
"request_body": {},
1818
"status_code": 200,
1919
"response_body": true
@@ -27,7 +27,7 @@
2727
"setup_endpoint"
2828
],
2929
"http_method": "GET",
30-
"endpoint": "/applications/{app_id}/endpoints?groupID={group_id}",
30+
"endpoint": "/applications/{app_id}/endpoints?groupId={group_id}",
3131
"request_body": {},
3232
"status_code": 200,
3333
"response_body": true
@@ -40,7 +40,7 @@
4040
"setup_endpoint"
4141
],
4242
"http_method": "PUT",
43-
"endpoint": "/applications/{app_id}/endpoints/{endpoint_id}?groupID={group_id}",
43+
"endpoint": "/applications/{app_id}/endpoints/{endpoint_id}?groupId={group_id}",
4444
"request_body": {
4545
"url": "https://google.com",
4646
"secret": "1234",
@@ -60,7 +60,7 @@
6060
"setup_endpoint"
6161
],
6262
"http_method": "DELETE",
63-
"endpoint": "/applications/{app_id}/endpoints/{endpoint_id}?groupID={group_id}",
63+
"endpoint": "/applications/{app_id}/endpoints/{endpoint_id}?groupId={group_id}",
6464
"request_body": {},
6565
"status_code": 200,
6666
"response_body": true

immune-test-files/test-apps.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"setup_app"
1414
],
1515
"http_method": "GET",
16-
"endpoint": "/applications?perPage=10&page=1&sort=asc&q=app&groupID={group_id}",
16+
"endpoint": "/applications?perPage=10&page=1&sort=asc&q=app&groupId={group_id}",
1717
"request_body": {},
1818
"status_code": 200,
1919
"response_body": true
@@ -25,7 +25,7 @@
2525
"setup_app"
2626
],
2727
"http_method": "GET",
28-
"endpoint": "/applications/{app_id}?groupID={group_id}",
28+
"endpoint": "/applications/{app_id}?groupId={group_id}",
2929
"request_body": {},
3030
"status_code": 200,
3131
"response_body": true
@@ -37,7 +37,7 @@
3737
"setup_app"
3838
],
3939
"http_method": "PUT",
40-
"endpoint": "/applications/{app_id}?groupID={group_id}",
40+
"endpoint": "/applications/{app_id}?groupId={group_id}",
4141
"request_body": {
4242
"name": "retro-app",
4343
"support_email": "ci@gmail.com"
@@ -52,7 +52,7 @@
5252
"setup_app"
5353
],
5454
"http_method": "DELETE",
55-
"endpoint": "/applications/{app_id}?groupID={group_id}",
55+
"endpoint": "/applications/{app_id}?groupId={group_id}",
5656
"request_body": {
5757
"name": "retro-app",
5858
"support_email": "ci@gmail.com"

immune-test-files/test-push-events.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"setup_endpoint"
2020
],
2121
"http_method": "POST",
22-
"endpoint": "/events?groupID={group_id}",
22+
"endpoint": "/events?groupId={group_id}",
2323
"callback": {
2424
"enabled": true,
2525
"times": 1
@@ -44,7 +44,7 @@
4444
"setup_endpoint"
4545
],
4646
"http_method": "POST",
47-
"endpoint": "/events?groupID={group_id}",
47+
"endpoint": "/events?groupId={group_id}",
4848
"callback": {
4949
"enabled": true,
5050
"times": 2
@@ -67,7 +67,7 @@
6767
"setup_app"
6868
],
6969
"http_method": "POST",
70-
"endpoint": "/events?groupID={group_id}",
70+
"endpoint": "/events?groupId={group_id}",
7171
"request_body": {
7272
"app_id": "{app_id}",
7373
"event_type": "payment.failed",

server/dashboard_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func Test_fetchAllConfigDetails(t *testing.T) {
5252
tc.dbFn(app)
5353
}
5454

55-
req := httptest.NewRequest(tc.method, "/ui/dashboard/config?groupID=12345", nil)
55+
req := httptest.NewRequest(tc.method, "/ui/dashboard/config?groupId=12345", nil)
5656
responseRecorder := httptest.NewRecorder()
5757

5858
requireGroup(app.groupRepo)(http.HandlerFunc(app.GetAllConfigDetails)).

server/middleware.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ func requireGroup(groupRepo datastore.GroupRepository) func(next http.Handler) h
416416
var err error
417417
var groupID string
418418

419-
groupID = r.URL.Query().Get("groupID")
419+
groupID = r.URL.Query().Get("groupId")
420420

421421
if util.IsStringEmpty(groupID) {
422422
groupID = chi.URLParam(r, "groupID")

server/security_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ func TestApplicationHandler_CreateAppPortalAPIKey(t *testing.T) {
248248
for _, tc := range tt {
249249
t.Run(tc.name, func(t *testing.T) {
250250
// Arrange
251-
url := fmt.Sprintf("/api/v1/security/applications/%s/keys?groupID=%s", appID, groupId)
251+
url := fmt.Sprintf("/api/v1/security/applications/%s/keys?groupId=%s", appID, groupId)
252252
req := httptest.NewRequest(http.MethodPost, url, nil)
253253
req.SetBasicAuth("test", "test")
254254
w := httptest.NewRecorder()

0 commit comments

Comments
 (0)