Make hasScopes take an array
This commit is contained in:
@@ -27,7 +27,7 @@ describe('scopes middleware', function () {
|
||||
|
||||
it('fails due to empty scope in request', function (done) {
|
||||
var mw = accesscontrol.scope('admin')[1];
|
||||
var req = { authInfo: { authorizedScope: '' } };
|
||||
var req = { authInfo: { authorizedScopes: [ ] } };
|
||||
|
||||
mw(req, null, function (error) {
|
||||
expect(error).to.be.a(HttpError);
|
||||
@@ -37,7 +37,7 @@ describe('scopes middleware', function () {
|
||||
|
||||
it('fails due to wrong scope in request', function (done) {
|
||||
var mw = accesscontrol.scope('admin')[1];
|
||||
var req = { authInfo: { authorizedScope: 'foobar,something' } };
|
||||
var req = { authInfo: { authorizedScopes: [ 'foobar', 'something' ] } };
|
||||
|
||||
mw(req, null, function (error) {
|
||||
expect(error).to.be.a(HttpError);
|
||||
@@ -47,7 +47,7 @@ describe('scopes middleware', function () {
|
||||
|
||||
it('fails due to wrong scope in request', function (done) {
|
||||
var mw = accesscontrol.scope('admin,users')[1];
|
||||
var req = { authInfo: { authorizedScope: 'foobar,admin' } };
|
||||
var req = { authInfo: { authorizedScopes: [ 'foobar', 'admin' ] } };
|
||||
|
||||
mw(req, null, function (error) {
|
||||
expect(error).to.be.a(HttpError);
|
||||
@@ -57,7 +57,7 @@ describe('scopes middleware', function () {
|
||||
|
||||
it('succeeds with one requested scope and one provided scope', function (done) {
|
||||
var mw = accesscontrol.scope('admin')[1];
|
||||
var req = { authInfo: { authorizedScope: 'admin' } };
|
||||
var req = { authInfo: { authorizedScopes: [ 'admin' ] } };
|
||||
|
||||
mw(req, null, function (error) {
|
||||
expect(error).to.not.be.ok();
|
||||
@@ -67,7 +67,7 @@ describe('scopes middleware', function () {
|
||||
|
||||
it('succeeds with one requested scope and two provided scopes', function (done) {
|
||||
var mw = accesscontrol.scope('admin')[1];
|
||||
var req = { authInfo: { authorizedScope: 'foobar,admin' } };
|
||||
var req = { authInfo: { authorizedScopes: [ 'foobar', 'admin' ] } };
|
||||
|
||||
mw(req, null, function (error) {
|
||||
expect(error).to.not.be.ok();
|
||||
@@ -77,7 +77,7 @@ describe('scopes middleware', function () {
|
||||
|
||||
it('succeeds with two requested scope and two provided scopes', function (done) {
|
||||
var mw = accesscontrol.scope('admin,foobar')[1];
|
||||
var req = { authInfo: { authorizedScope: 'foobar,admin' } };
|
||||
var req = { authInfo: { authorizedScopes: [ 'foobar', 'admin' ] } };
|
||||
|
||||
mw(req, null, function (error) {
|
||||
expect(error).to.not.be.ok();
|
||||
@@ -87,7 +87,7 @@ describe('scopes middleware', function () {
|
||||
|
||||
it('succeeds with two requested scope and provided wildcard scope', function (done) {
|
||||
var mw = accesscontrol.scope('admin,foobar')[1];
|
||||
var req = { authInfo: { authorizedScope: '*' } };
|
||||
var req = { authInfo: { authorizedScopes: [ '*' ] } };
|
||||
|
||||
mw(req, null, function (error) {
|
||||
expect(error).to.not.be.ok();
|
||||
|
||||
@@ -105,7 +105,7 @@ describe('Profile API', function () {
|
||||
expect(result.body.displayName).to.be.a('string');
|
||||
expect(result.body.password).to.not.be.ok();
|
||||
expect(result.body.salt).to.not.be.ok();
|
||||
expect(result.body.tokenScope).to.be(accesscontrol.VALID_SCOPES.join(','));
|
||||
expect(result.body.tokenScope).to.eql(accesscontrol.VALID_SCOPES);
|
||||
|
||||
user_0 = result.body;
|
||||
|
||||
@@ -143,7 +143,7 @@ describe('Profile API', function () {
|
||||
expect(result.body.displayName).to.be.a('string');
|
||||
expect(result.body.password).to.not.be.ok();
|
||||
expect(result.body.salt).to.not.be.ok();
|
||||
expect(result.body.tokenScope).to.be(accesscontrol.VALID_SCOPES.join(','));
|
||||
expect(result.body.tokenScope).to.eql(accesscontrol.VALID_SCOPES);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -196,7 +196,7 @@ describe('Profile API', function () {
|
||||
expect(res.body.username).to.equal(USERNAME_0.toLowerCase());
|
||||
expect(res.body.email).to.equal(EMAIL_0_NEW.toLowerCase());
|
||||
expect(res.body.fallbackEmail).to.equal(EMAIL_0_NEW_FALLBACK.toLowerCase());
|
||||
expect(res.body.tokenScope).to.be(accesscontrol.VALID_SCOPES.join(','));
|
||||
expect(res.body.tokenScope).to.eql(accesscontrol.VALID_SCOPES);
|
||||
expect(res.body.displayName).to.equal('');
|
||||
|
||||
done();
|
||||
@@ -217,7 +217,7 @@ describe('Profile API', function () {
|
||||
expect(res.statusCode).to.equal(200);
|
||||
expect(res.body.username).to.equal(USERNAME_0.toLowerCase());
|
||||
expect(res.body.email).to.equal(EMAIL_0_NEW.toLowerCase());
|
||||
expect(res.body.tokenScope).to.be(accesscontrol.VALID_SCOPES.join(','));
|
||||
expect(res.body.tokenScope).to.eql(accesscontrol.VALID_SCOPES);
|
||||
expect(res.body.displayName).to.equal(DISPLAY_NAME_0_NEW);
|
||||
|
||||
done();
|
||||
|
||||
Reference in New Issue
Block a user