Skip to content

Commit aee4b4f

Browse files
committed
fix: fix failing tests
1 parent 8decdea commit aee4b4f

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/config/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export const getAPIAuthMethods = (): Authentication[] => {
110110
const enabledAuthMethods = _apiAuthentication.filter(auth => auth.enabled);
111111

112112
if (enabledAuthMethods.length === 0) {
113-
throw new Error("No authentication method enabled.");
113+
console.log("Warning: No authentication method enabled for API endpoints.");
114114
}
115115

116116
return enabledAuthMethods;

src/service/passport/jwtAuthHandler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const jwtAuthHandler = (overrideConfig = null) => {
1313
: require('../../config').getAPIAuthMethods();
1414

1515
const jwtAuthMethod = apiAuthMethods.find((method) => method.type.toLowerCase() === "jwt");
16-
if (!jwtAuthMethod) {
16+
if (!overrideConfig && (!jwtAuthMethod || !jwtAuthMethod.enabled)) {
1717
return next();
1818
}
1919

test/testJwtAuthHandler.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ describe('jwtAuthHandler', () => {
146146

147147
it('should return 401 if no token provided', async () => {
148148
req.header.returns(null);
149-
await jwtAuthHandler()(req, res, next);
149+
await jwtAuthHandler(jwtConfig)(req, res, next);
150150

151151
expect(res.status.calledWith(401)).to.be.true;
152152
expect(res.send.calledWith('No token provided\n')).to.be.true;

0 commit comments

Comments
 (0)