Fixed tests

no issue
This commit is contained in:
kirrg001 2019-02-06 20:14:36 +01:00 committed by Katharina Irrgang
parent a8e0a173c2
commit 5f4cf42c14
3 changed files with 32 additions and 20 deletions

View File

@ -443,14 +443,14 @@ ghostBookshelf.Model = ghostBookshelf.Model.extend({
},
getActor(options = {context: {}}) {
if (options.context.integration) {
if (options.context && options.context.integration) {
return {
id: options.context.integration.id,
type: 'integration'
};
}
if (options.context.user) {
if (options.context && options.context.user) {
return {
id: options.context.user,
type: 'user'

View File

@ -606,7 +606,7 @@ describe('API Utils', function () {
describe('handlePublicPermissions', function () {
it('should return empty options if passed empty options', function (done) {
apiUtils.handlePublicPermissions('tests', 'test')({}).then(function (options) {
options.should.eql({context: {app: null, external: false, internal: false, public: true, user: null, api_key: null}});
options.should.eql({context: {integration: null, app: null, external: false, internal: false, public: true, user: null, api_key: null}});
done();
}).catch(done);
});
@ -615,7 +615,7 @@ describe('API Utils', function () {
var aPPStub = sinon.stub(apiUtils, 'applyPublicPermissions').returns(Promise.resolve({}));
apiUtils.handlePublicPermissions('tests', 'test')({}).then(function (options) {
aPPStub.calledOnce.should.eql(true);
options.should.eql({context: {app: null, external: false, internal: false, public: true, user: null, api_key: null}});
options.should.eql({context: {integration: null, app: null, external: false, internal: false, public: true, user: null, api_key: null}});
done();
}).catch(done);
});
@ -631,7 +631,7 @@ describe('API Utils', function () {
apiUtils.handlePublicPermissions('tests', 'test')({context: {user: 1}}).then(function (options) {
cTStub.calledOnce.should.eql(true);
cTMethodStub.test.test.calledOnce.should.eql(true);
options.should.eql({context: {app: null, external: false, internal: false, public: false, user: 1, api_key: null}});
options.should.eql({context: {integration: null, app: null, external: false, internal: false, public: false, user: 1, api_key: null}});
done();
}).catch(done);
});

View File

@ -10,7 +10,8 @@ describe('Permissions', function () {
user: null,
api_key: null,
app: null,
public: true
public: true,
integration: null
});
parseContext({}).should.eql({
internal: false,
@ -18,7 +19,8 @@ describe('Permissions', function () {
user: null,
api_key: null,
app: null,
public: true
public: true,
integration: null
});
});
@ -29,7 +31,8 @@ describe('Permissions', function () {
user: null,
api_key: null,
app: null,
public: true
public: true,
integration: null
});
parseContext({client: 'thing'}).should.eql({
internal: false,
@ -37,7 +40,8 @@ describe('Permissions', function () {
user: null,
api_key: null,
app: null,
public: true
public: true,
integration: null
});
});
@ -48,15 +52,16 @@ describe('Permissions', function () {
user: 1,
api_key: null,
app: null,
public: false
public: false,
integration: null
});
});
it('should return api_key and public context if content api_key provided', function () {
parseContext({api_key: {
id: 1,
type: 'content'
}}).should.eql({
type: 'content',
}, integration: {id: 2}}).should.eql({
internal: false,
external: false,
user: null,
@ -65,7 +70,8 @@ describe('Permissions', function () {
type: 'content'
},
app: null,
public: true
public: true,
integration: {id: 2}
});
});
@ -73,7 +79,7 @@ describe('Permissions', function () {
parseContext({api_key: {
id: 1,
type: 'admin'
}}).should.eql({
}, integration: {id: 3}}).should.eql({
internal: false,
external: false,
user: null,
@ -82,7 +88,8 @@ describe('Permissions', function () {
type: 'admin'
},
app: null,
public: false
public: false,
integration: {id: 3}
});
});
@ -93,7 +100,8 @@ describe('Permissions', function () {
user: null,
api_key: null,
app: 5,
public: false
public: false,
integration: null
});
});
@ -104,7 +112,8 @@ describe('Permissions', function () {
user: null,
api_key: null,
app: null,
public: false
public: false,
integration: null
});
parseContext('internal').should.eql({
@ -113,7 +122,8 @@ describe('Permissions', function () {
user: null,
api_key: null,
app: null,
public: false
public: false,
integration: null
});
});
@ -124,7 +134,8 @@ describe('Permissions', function () {
user: null,
api_key: null,
app: null,
public: false
public: false,
integration: null
});
parseContext('external').should.eql({
@ -133,7 +144,8 @@ describe('Permissions', function () {
user: null,
api_key: null,
app: null,
public: false
public: false,
integration: null
});
});
});