Skip to content

Commit

Permalink
fix(testutil/harness.go): set Content-Type header for POST requests
Browse files Browse the repository at this point in the history
refactor(v1_identities_updateIdentity.ts): simplify ratelimits check logic
  • Loading branch information
chronark committed Sep 5, 2024
1 parent 0d341be commit edbf56e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions apps/agent/pkg/api/testutil/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ func CallRoute[Req any, Res any](t *testing.T, route *routes.Route, headers http

httpReq := httptest.NewRequest(route.Method(), route.Path(), body)
httpReq.Header = headers
if httpReq.Header == nil {
httpReq.Header = http.Header{}
}
if route.Method() == http.MethodPost {
httpReq.Header.Set("Content-Type", "application/json")
}

mux.ServeHTTP(rr, httpReq)
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/routes/v1_identities_updateIdentity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export const registerV1IdentitiesUpdateIdentity = (app: App) =>
});
}

if (req.ratelimits && req.ratelimits.length >= 2) {
if (req.ratelimits) {
const uniqueNames = new Set<string>();
for (const { name } of req.ratelimits) {
if (uniqueNames.has(name)) {
Expand Down

0 comments on commit edbf56e

Please sign in to comment.