Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token requests can trigger a "UnhandledPromiseRejectionWarning" in version 4.0.0+ #141

Closed
dnicolson opened this issue Nov 16, 2021 · 2 comments · Fixed by #142
Closed

Token requests can trigger a "UnhandledPromiseRejectionWarning" in version 4.0.0+ #141

dnicolson opened this issue Nov 16, 2021 · 2 comments · Fixed by #142
Assignees
Labels
bug Something isn't working

Comments

@dnicolson
Copy link

Summary

It is possible to trigger an UnhandledPromiseRejectionWarning: AssertionError [ERR_ASSERTION]: Invalid 'grant_type' type warning for invalid requests in version 4.0.0 and later.

Steps to Reproduce

  1. Start the following server in 4.0.0 or 4.1.0:
const { OAuth2Server } = require('oauth2-mock-server');

async function startServer() {
    let server = new OAuth2Server();
    await server.issuer.keys.generate('RS256');
    await server.start(8080, 'localhost');
}

startServer();
  1. Run curl --request POST --url http://localhost:8080/token --header 'Content-Type: multipart/form-data;'

Expected Behavior

An assertion failure message. The equivalent code in version 3.2.0 works as expected:

const { OAuth2Server } = require('oauth2-mock-server');

async function startServer() {
    let server = new OAuth2Server();
    await server.issuer.keys.generateRSA();
    await server.start(8080, 'localhost');
}

startServer();

Environment

  • oauth2-mock-server version: 4.1.0
  • Noje.JS version: 14.15.0
  • NPM version: 6.14.8
  • Operating System: macOS 11.6
@nulltoken nulltoken added the bug Something isn't working label Nov 16, 2021
@nulltoken
Copy link
Contributor

@dnicolson Great catch!

A fix is on its way in #142

@nulltoken
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants