Remove scope from users.get

This commit is contained in:
Girish Ramakrishnan
2018-06-17 15:25:41 -07:00
parent db8b6838bb
commit 156ffb40c9
7 changed files with 33 additions and 54 deletions

View File

@@ -25,29 +25,9 @@ describe('scopes middleware', function () {
passport.authenticate = passportAuthenticateSave;
});
it('fails due to missing authInfo', function (done) {
it('fails due to empty scope in request', function (done) {
var mw = accesscontrol.scope('admin')[1];
var req = {};
mw(req, null, function (error) {
expect(error).to.be.a(HttpError);
done();
});
});
it('fails due to missing scope property in authInfo', function (done) {
var mw = accesscontrol.scope('admin')[1];
var req = { authInfo: {} };
mw(req, null, function (error) {
expect(error).to.be.a(HttpError);
done();
});
});
it('fails due to missing scope in request', function (done) {
var mw = accesscontrol.scope('admin')[1];
var req = { authInfo: { scope: '' } };
var req = { authInfo: { authorizedScope: '' } };
mw(req, null, function (error) {
expect(error).to.be.a(HttpError);
@@ -57,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: { scope: 'foobar,something' } };
var req = { authInfo: { authorizedScope: 'foobar,something' } };
mw(req, null, function (error) {
expect(error).to.be.a(HttpError);
@@ -67,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: { scope: 'foobar,admin' } };
var req = { authInfo: { authorizedScope: 'foobar,admin' } };
mw(req, null, function (error) {
expect(error).to.be.a(HttpError);
@@ -77,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: { scope: 'admin' } };
var req = { authInfo: { authorizedScope: 'admin' } };
mw(req, null, function (error) {
expect(error).to.not.be.ok();
@@ -87,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: { scope: 'foobar,admin' } };
var req = { authInfo: { authorizedScope: 'foobar,admin' } };
mw(req, null, function (error) {
expect(error).to.not.be.ok();
@@ -97,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: { scope: 'foobar,admin' } };
var req = { authInfo: { authorizedScope: 'foobar,admin' } };
mw(req, null, function (error) {
expect(error).to.not.be.ok();
@@ -107,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: { scope: '*' } };
var req = { authInfo: { authorizedScope: '*' } };
mw(req, null, function (error) {
expect(error).to.not.be.ok();

View File

@@ -106,6 +106,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('apps,clients,cloudron,domains,mail,profile,settings,users');
user_0 = result.body;
@@ -144,6 +145,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('apps,clients,cloudron,domains,mail,profile,settings,users');
done();
});
});