wasteful-scope
Version:
OAuth2 scope utilities for the wasteful scope parsing, comparing, merging, etc
49 lines (44 loc) • 994 B
JavaScript
;
module.exports.create = function (groups) {
var scopeutils = require('wasteful-scope').create(groups)
, _ = require('lodash')
, obj
, expected
;
obj = scopeutils.parse("me:email,phone:email,phone:tel,sms friends:name,birthday::");
expected = {
"scope": {
"me": {
"group": "me",
"readable": [
"email",
"phone"
],
"writeable": [
"email",
"phone"
],
"executable": [
"tel",
"sms"
]
},
"friends": {
"group": "friends",
"readable": [
"name",
"birthday"
],
"writeable": [],
"executable": []
}
},
"invalid": []
};
if (!_.isEqual(obj, expected)) {
console.error(JSON.stringify(obj, null, ' '));
console.error(JSON.stringify(expected, null, ' '));
throw new Error("parse got incorrect results");
}
console.log('[parse] PASS');
};