Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const events = require('../../../lib/common/events');
const localUtils = require('../utils');
const PostScheduler = require('./PostScheduler');
const getSchedulerIntegration = require('./scheduler-intergation');
const getSchedulerIntegration = require('./scheduler-integration');
const {sequence} = require('@tryghost/promise');

/**
Expand Down Expand Up @@ -32,7 +32,7 @@ const loadScheduledResources = async function () {

const init = async (options) => {
const integration = await getSchedulerIntegration();
const adapter = await localUtils.createAdapter();
const adapter = localUtils.createAdapter();

let scheduledResources;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ const jwt = require('jsonwebtoken');
* @param {Object} options
* @param {string} options.publishedAt - ISO date
* @param {string} options.apiUrl - url of the JWT's audience
* @param {string} options.key - integration key
* @param {object} options.key - integration key
* @param {string} options.key.id - key ID
* @param {string} options.key.secret - key secret
*
* @return {string} the JSON Web Token
*/
const getSignedAdminToken = function ({publishedAt, apiUrl, key}) {
const JWT_OPTIONS = {
const JWT_OPTIONS = /** @type {const} */ ({
keyid: key.id,
algorithm: 'HS256',
audience: apiUrl,
noTimestamp: true
};
});

// Default token expiry is till 6 hours after scheduled time
// or if published_at is in past then till 6 hours after blog start
Expand Down
2 changes: 1 addition & 1 deletion ghost/core/core/server/adapters/scheduling/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const adapterManager = require('../../services/adapter-manager');

async function createAdapter() {
function createAdapter() {
return adapterManager.getAdapter('scheduling');
}

Expand Down
32 changes: 16 additions & 16 deletions ghost/core/test/unit/server/adapters/scheduling/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ describe('Scheduling: utils', function () {
});

describe('success', function () {
it('create good adapter', function (done) {
schedulingUtils.createAdapter().then(function (adapter) {
assertExists(adapter);
done();
}).catch(done);
it('create good adapter', function () {
const adapter = schedulingUtils.createAdapter();
assertExists(adapter);
});

it('create good adapter from custom file', function (done) {
it('create good adapter from custom file', function () {
scope.adapter = schedulingPath + 'another-scheduler.js';

configUtils.set({
Expand All @@ -53,15 +51,13 @@ describe('Scheduling: utils', function () {

fs.writeFileSync(scope.adapter, jsFile);

schedulingUtils.createAdapter().then(function (adapter) {
assertExists(adapter);
done();
}).catch(done);
const adapter = schedulingUtils.createAdapter();
assertExists(adapter);
});
});

describe('error', function () {
it('create with adapter, but missing fn\'s', function (done) {
it('create with adapter, but missing fn\'s', function () {
scope.adapter = schedulingPath + 'bad-adapter.js';
const jsFile = '' +
'var util = require(\'util\');' +
Expand All @@ -78,11 +74,15 @@ describe('Scheduling: utils', function () {
active: 'bad-adapter'
}
});
schedulingUtils.createAdapter().catch(function (err) {
assertExists(err);
assert.equal(err.errorType, 'IncorrectUsageError');
done();
});

assert.throws(
() => schedulingUtils.createAdapter(),
(err) => {
assertExists(err);
assert.equal(err.errorType, 'IncorrectUsageError');
return true;
}
);
});
});
});
Loading