Skip to content
This repository has been archived by the owner on Apr 16, 2019. It is now read-only.

Commit

Permalink
coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
hueniverse committed Sep 19, 2015
1 parent fb271c1 commit 88628b7
Show file tree
Hide file tree
Showing 5 changed files with 1,494 additions and 393 deletions.
2 changes: 1 addition & 1 deletion lib/endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ exports.rsvp = function (req, payload, options, callback) {
return callback(Boom.forbidden('Invalid application'));
}

var ticketOptions = ticketOptions || {};
var ticketOptions = options.ticket || {};
if (ext) {
ticketOptions = Hoek.shallow(ticketOptions);
ticketOptions.ext = ext;
Expand Down
4 changes: 4 additions & 0 deletions lib/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ exports.validate = function (scope) {

exports.isSubset = function (scope, subset) {

if (!scope) {
return false;
}

if (scope.length < subset.length) {
return false;
}
Expand Down
18 changes: 15 additions & 3 deletions lib/ticket.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,22 @@ exports.reissue = function (parentTicket, grant, encryptionPassword, options, ca
return fail(Boom.internal('Invalid options object'));
}

if (options.scope &&
!Scope.isSubset(parentTicket.scope, options.scope)) {
if (parentTicket.scope) {
var error = Scope.validate(parentTicket.scope);
if (error) {
return fail(error);
}
}

return fail(Boom.forbidden('New scope is not a subset of the parent ticket scope'));
if (options.scope) {
error = Scope.validate(options.scope);
if (error) {
return fail(error);
}

if (!Scope.isSubset(parentTicket.scope, options.scope)) {
return fail(Boom.forbidden('New scope is not a subset of the parent ticket scope'));
}
}

if (options.issueTo &&
Expand Down
Loading

0 comments on commit 88628b7

Please sign in to comment.