Comments (3)
@robertbullen Since issues like this one have been open for so long I created a different library aws-cognito-express.
from cognito-express.
The unit tests mask this bug because of how they are passing an async callback:
cognito-express/test/strategy.js
Lines 121 to 130 in 86c7386
Because the callback is async, it will be executed after the strategy.init()
promise, and hence the test itself, resolves. This means that the expect
assertions occur outside of the detection of chai.
Restructuring the test as follows:
it("should check if Validate function can fail successfully when invalid token is passed (Promise)", async () => {
await strategy.init(result => expect(result).to.eql(true));
try {
await strategy.validate("token");
} catch (err) {
expect(err).to.eql("Not a valid JWT token");
};
});
Surfaces the failure:
Strategy Positive Scenarios
✓ should check if GeneratePem function exists
✓ should check if jwtVerify function exists
✓ should check if configurationIsCorrect function exists
✓ should check if Validate function exists
✓ should check if Strategy can initialized successfully (208ms)
✓ should check if Validate function can fail successfully when invalid token is passed (129ms)
1) should check if Validate function can fail successfully when invalid token is passed (Promise)
✓ should check if Validate function can execute successfully by detecting an expired token (134ms)
14 passing (632ms)
1 failing
1) Strategy Positive Scenarios
should check if Validate function can fail successfully when invalid token is passed (Promise):
AssertionError: expected [TypeError: callback is not a function] to deeply equal 'Not a valid JWT token'
at Context.it (test/strategy.js:126:19)
at <anonymous>
from cognito-express.
@ghdna, do you have any thoughts on or plans for this PR?
from cognito-express.
Related Issues (20)
- This callback would never be called in case of error HOT 1
- Getting socket hang up error randomly when deployed on lambda HOT 2
- tokenExpiration question HOT 7
- Contributions for cognito-express HOT 1
- post test coverage reports fail
- How to make the https://cognito-idp request from Proxy from with-in the app? HOT 2
- tokenExpiration expects seconds, not microseconds
- How to refresh tokens with this library? HOT 1
- Excessive Logging HOT 1
- How to deal with constructor background error HOT 1
- Runtime.UnhandledPromiseRejection HOT 10
- Invalid JWT token results in error object in callback as string rather than object HOT 3
- is the <tokenExpiration> really mandatory/needed? HOT 1
- npm audit - json-schema is vulnerable to Prototype Pollution HOT 5
- Curl Method Option needed to get around issues running cognito-express in Ubuntu on windows + Windows Powershell HOT 1
- Cognito Token JsonWebTokenError: invalid signature HOT 1
- The new release "3.0.2" is still using the old version 3.0.1 HOT 1
- Seeing intermittent ERR_SOCKET_CONNECTION_TIMEOUT
- Getting User's Status From Cognito
- CVE-2023-45857 - axios HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cognito-express.