Skip to content

Commit

Permalink
fix: cookie vuln
Browse files Browse the repository at this point in the history
  • Loading branch information
SaraMansori committed Nov 5, 2024
1 parent 7e21949 commit 544ce34
Show file tree
Hide file tree
Showing 4 changed files with 313 additions and 625 deletions.
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const path = require('path');

module.exports = {
rootDir: path.resolve('./'),
testEnvironment: 'jest-environment-jsdom',
testEnvironment: 'jest-fixed-jsdom',
testEnvironmentOptions: {
url: 'http://localhost/',
},
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"@shopify/network": "^3.3.0",
"@shopify/react-performance": "^4.1.1",
"events": "^3.3.0",
"jest-environment-jsdom": "^29.7.0",
"jest-fixed-jsdom": "^0.0.6",
"promjs": "^0.4.1",
"react-beforeunload": "^2.6.0"
},
Expand All @@ -50,8 +52,7 @@
"eslint": "8.57.0",
"eslint-import-resolver-typescript": "3.6.3",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"msw": "1.3.5",
"msw": "^2.6.0",
"prettier": "3.3.3",
"react": "18.3.1",
"react-dom": "18.3.1",
Expand Down
21 changes: 11 additions & 10 deletions test/mockServer.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { matchRequestUrl, MockedRequest, rest } from 'msw';
import { delay, http, HttpResponse, matchRequestUrl, MockedRequest } from 'msw';

Check failure on line 1 in test/mockServer.ts

View workflow job for this annotation

GitHub Actions / test / typecheck

Module '"msw"' has no exported member 'MockedRequest'.
import { setupServer } from 'msw/node';

export const server = setupServer(
rest.post(
'http://push-aggregation-gateway/push-metrics',
(_req, res, ctx) => {
return res(ctx.delay(), ctx.status(200));
},
),
rest.post('http://push-aggregation-gateway/server-down', (_req, res, ctx) => {
return res(ctx.delay(), ctx.status(503));
http.post('http://push-aggregation-gateway/push-metrics', async () => {
await delay(1);
return new HttpResponse(null, { status: 200 });
// return res(ctx.delay(), ctx.status(200));
}),
http.post('http://push-aggregation-gateway/server-down', async () => {
await delay(1);
return new HttpResponse(null, { status: 503 });
// return res(ctx.delay(), ctx.status(503));
}),
);

Expand All @@ -19,7 +20,7 @@ export const waitForRequests = async (
expectedRequests = 1,
) => {
const requestIds: string[] = [];
const requests: MockedRequest[] = [];
const requests = [];

Check failure on line 23 in test/mockServer.ts

View workflow job for this annotation

GitHub Actions / test / typecheck

Variable 'requests' implicitly has type 'any[]' in some locations where its type cannot be determined.

return new Promise<MockedRequest[]>((resolve, reject) => {
server.events.on('request:start', (req) => {
Expand Down
Loading

0 comments on commit 544ce34

Please sign in to comment.