Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad-ignatov committed Jan 18, 2021
1 parent 834c7f9 commit 25d5982
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
21 changes: 14 additions & 7 deletions tests/bulk_data.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const request = require("request");
const base64url = require("base64-url");
const moment = require("moment");
/** @type {any} */
const assert = require("assert");
const crypto = require("crypto");
const jwkToPem = require("jwk-to-pem");
Expand Down Expand Up @@ -2468,7 +2469,7 @@ describe("Error responses", () => {
error: "invalid_grant",
error_description: `No public keys found in the JWKS with "kid" equal to "${
jwks.keys[1].kid
}" and "kty" equal to "${jwks.keys[1].kty}"`
}"`
}, 400);
})
});
Expand Down Expand Up @@ -2520,7 +2521,7 @@ describe("Error responses", () => {
}
});

return assertError({
return lib.requestPromise({
method: "POST",
json : true,
url : tokenUrl,
Expand All @@ -2530,11 +2531,17 @@ describe("Error responses", () => {
client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
client_assertion : signed
}
}, {
error: "invalid_grant",
error_description: `Unable to verify the token with any of the public keys found in the JWKS`
}, 400);
})
})
}).then(
() => {
throw new Error("This request should have failed");
},
result => {
assert.strictEqual(result.response.statusCode, 400);
assert.strictEqual(result.response.body.error, "invalid_grant", 'The "error" property should equal "invalid_grant"');
assert.match(result.response.body.error_description, /^Unable to verify the token with any of the public keys found in the JWKS\b/);
}
);
});

it("returns 401 invalid_client if the id token contains {err:'token_invalid_token'}", () => {
Expand Down
2 changes: 1 addition & 1 deletion token_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,5 +292,5 @@ module.exports = async (req, res) => {

res.json(token);
})
.catch(e => res.end(e.toString()));
.catch(e => res.end(String(e || "")));
};

0 comments on commit 25d5982

Please sign in to comment.