Skip to content

Commit

Permalink
Fixes auth tests
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpolman committed May 20, 2024
1 parent abe3b76 commit a4f2f32
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 140 deletions.
6 changes: 3 additions & 3 deletions apps/auth/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#####################################################################################################
## Develop stage
#####################################################################################################
FROM node:16-slim as develop
FROM node:18-slim as develop

WORKDIR /usr/src/app

Expand All @@ -18,7 +18,7 @@ CMD [ "npx", "nx", "serve", "auth" ]
#####################################################################################################
## Build stage
#####################################################################################################
FROM node:16-slim as build
FROM node:18-slim as build

WORKDIR /usr/src/app
COPY --from=develop ./usr/src/app/ ./
Expand All @@ -29,7 +29,7 @@ COPY ./newrelic.js ./yarn.lock ./dist/apps/auth/
#####################################################################################################
## Production stage
#####################################################################################################
FROM node:16-slim as production
FROM node:18-slim as production

ENV NODE_ENV=production

Expand Down
7 changes: 6 additions & 1 deletion apps/auth/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "apps/auth/jest.config.ts"
"jestConfig": "apps/auth/jest.config.ts",
"testTimeout": 60000,
"passWithNoTests": false,
"bail": false,
"runInBand": true,
"logHeapUsage": true
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion apps/auth/src/app/controllers/oidc/signin/grants.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('OAuth2 Grants', () => {
variant: AccountVariant.EmailPassword,
active: true,
});
sub = account._id;
sub = account.id;
});

afterAll(async () => {
Expand Down
8 changes: 2 additions & 6 deletions apps/auth/src/app/middlewares/validateJwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@ import jwksRsa from 'jwks-rsa';
import expressJwtPermissions from 'express-jwt-permissions';
import { expressjwt } from 'express-jwt';
import { AUTH_URL } from '../config/secrets';
import { getJwks } from '../util/jwks';

export const validateJwt = expressjwt({
secret: jwksRsa.expressJwtSecret({
cache: true,
rateLimit: true,
jwksRequestsPerMinute: 5,
jwksUri: '', // Unnecessary, keys are provided through getKeysInterceptor.
getKeysInterceptor: () => {
return getJwks().keys;
},
jwksRequestsPerMinute: 10,
jwksUri: `${AUTH_URL}/jwks`, // Unnecessary, keys are provided through getKeysInterceptor.
}),
issuer: AUTH_URL,
algorithms: ['RS256'],
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"ngrok": "~/ngrok http --domain=local.auth.thx.network https://localhost:3030 > /dev/null &",
"hardhat": "nx run api:hardhat",
"hardhat-deploy": "nx run api:hardhat-deploy",
"test": "NODE_OPTIONS='--max-old-space-size=8192' nx test",
"test": "NODE_TLS_REJECT_UNAUTHORIZED='0' NODE_OPTIONS='--max-old-space-size=8192' nx test",
"serve:docker": "docker-compose --env-file .env.example -f docker-compose.yml -f docker-compose.safe.yml up --build -d",
"serve:app": "nx serve app",
"serve:api": "NODE_TLS_REJECT_UNAUTHORIZED='0' nx serve api",
Expand Down Expand Up @@ -39,6 +39,7 @@
"@tkey/security-questions": "10.1.0",
"@tkey/web-storage": "10.1.0",
"@types/multer": "^1.4.11",
"@types/oidc-provider": "^7.14.0",
"@vuepic/vue-datepicker": "7.2.0",
"@wagmi/connectors": "^4.1.14",
"@wagmi/core": "^2.6.5",
Expand Down Expand Up @@ -80,7 +81,7 @@
"multer": "^1.4.5-lts.1",
"newrelic": "^11.17.0",
"oidc-client-ts": "^2.2.4",
"oidc-provider": "^8.4.6",
"oidc-provider": "7.14.3",
"pinia": "^2.0.23",
"promise-poller": "^1.9.1",
"protobufjs": "^7.2.4",
Expand Down
Loading

0 comments on commit a4f2f32

Please sign in to comment.