Skip to content

Commit

Permalink
Implement async/sync tests for nbf claim (#537)
Browse files Browse the repository at this point in the history
Refactor the existing tests for the nbf claim to use the async/sync test
helpers. This required fixing a case where an error was improperly
handled for an async call.
  • Loading branch information
MitMaro authored and ziluvatar committed Oct 16, 2018
1 parent 9ae3f20 commit 88bc965
Show file tree
Hide file tree
Showing 2 changed files with 220 additions and 141 deletions.
7 changes: 6 additions & 1 deletion sign.js
Expand Up @@ -147,7 +147,12 @@ module.exports = function (payload, secretOrPrivateKey, options, callback) {
}

if (typeof options.notBefore !== 'undefined') {
payload.nbf = timespan(options.notBefore, timestamp);
try {
payload.nbf = timespan(options.notBefore, timestamp);
}
catch (err) {
return failure(err);
}
if (typeof payload.nbf === 'undefined') {
return failure(new Error('"notBefore" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));
}
Expand Down

0 comments on commit 88bc965

Please sign in to comment.