diff --git a/core/server/web/api/app.js b/core/server/web/api/app.js index 6f49b9db5e..13006b2011 100644 --- a/core/server/web/api/app.js +++ b/core/server/web/api/app.js @@ -25,9 +25,6 @@ module.exports = function setupApiApp() { apiApp.lazyUse(urlUtils.getVersionPath({version: 'canary', type: 'content'}), require('./canary/content/app')); apiApp.lazyUse(urlUtils.getVersionPath({version: 'canary', type: 'admin'}), require('./canary/admin/app')); - apiApp.lazyUse('/content/', require('./canary/content/app')); - apiApp.lazyUse('/admin/', require('./canary/admin/app')); - // Error handling for requests to non-existent API versions apiApp.use(errorHandler.resourceNotFound); apiApp.use(errorHandler.handleJSONResponse(sentry)); diff --git a/core/shared/config/overrides.json b/core/shared/config/overrides.json index 96f6a8d3fc..6141994769 100644 --- a/core/shared/config/overrides.json +++ b/core/shared/config/overrides.json @@ -79,11 +79,15 @@ }, "api": { "versions": { - "all": ["v2", "v3", "v4", "canary"], + "all": ["v2", "v3", "v4", "v5", "canary"], "default": "v4", "canary": { - "admin": "canary/admin", - "content": "canary/content" + "admin": "admin", + "content": "content" + }, + "v5": { + "admin": "admin", + "content": "content" }, "v4": { "admin": "v4/admin", diff --git a/test/e2e-api/admin/actions.test.js b/test/e2e-api/admin/actions.test.js index 2252afb437..cc4c1057e7 100644 --- a/test/e2e-api/admin/actions.test.js +++ b/test/e2e-api/admin/actions.test.js @@ -98,7 +98,7 @@ describe('Actions API', function () { await integrationRequest .put(localUtils.API.getApiQuery(`posts/${postId}/`)) .set('Origin', config.get('url')) - .set('Authorization', `Ghost ${localUtils.getValidAdminToken('/canary/admin/')}`) + .set('Authorization', `Ghost ${localUtils.getValidAdminToken('/admin/')}`) .send({ posts: [{ featured: true, diff --git a/test/e2e-api/admin/key_authentication.test.js b/test/e2e-api/admin/key_authentication.test.js index 69b0770951..d872c8dec3 100644 --- a/test/e2e-api/admin/key_authentication.test.js +++ b/test/e2e-api/admin/key_authentication.test.js @@ -32,7 +32,7 @@ describe('Admin API key authentication', function () { it('Can access browse endpoint with correct token', async function () { await request.get(localUtils.API.getApiQuery('posts/')) - .set('Authorization', `Ghost ${localUtils.getValidAdminToken('/canary/admin/')}`) + .set('Authorization', `Ghost ${localUtils.getValidAdminToken('/admin/')}`) .expect('Content-Type', /json/) .expect('Cache-Control', testUtils.cacheRules.private) .expect(200); @@ -46,7 +46,7 @@ describe('Admin API key authentication', function () { const res = await request .post(localUtils.API.getApiQuery('posts/?include=authors')) .set('Origin', config.get('url')) - .set('Authorization', `Ghost ${localUtils.getValidAdminToken('/canary/admin/')}`) + .set('Authorization', `Ghost ${localUtils.getValidAdminToken('/admin/')}`) .send({ posts: [post] }) @@ -62,7 +62,7 @@ describe('Admin API key authentication', function () { const res = await request .get(localUtils.API.getApiQuery('users/')) .set('Origin', config.get('url')) - .set('Authorization', `Ghost ${localUtils.getValidAdminToken('/canary/admin/')}`) + .set('Authorization', `Ghost ${localUtils.getValidAdminToken('/admin/')}`) .expect('Content-Type', /json/) .expect('Cache-Control', testUtils.cacheRules.private) .expect(200); @@ -88,7 +88,7 @@ describe('Admin API key authentication', function () { await testUtils.initFixtures('api_keys'); const response = await request.get(localUtils.API.getApiQuery('posts/')) - .set('Authorization', `Ghost ${localUtils.getValidAdminToken('/canary/admin/')}`) + .set('Authorization', `Ghost ${localUtils.getValidAdminToken('/admin/')}`) .expect('Content-Type', /json/) .expect('Cache-Control', testUtils.cacheRules.private) .expect(403); diff --git a/test/regression/api/admin/db.test.js b/test/regression/api/admin/db.test.js index af9067f378..c87f707901 100644 --- a/test/regression/api/admin/db.test.js +++ b/test/regression/api/admin/db.test.js @@ -129,7 +129,7 @@ describe('DB API (canary)', function () { const fsStub = sinon.stub(fs, 'writeFile').resolves(); return request.post(localUtils.API.getApiQuery(`db/backup${backupQuery}`)) - .set('Authorization', `Ghost ${localUtils.getValidAdminToken('/canary/admin/', backupKey)}`) + .set('Authorization', `Ghost ${localUtils.getValidAdminToken('/admin/', backupKey)}`) .set('Origin', config.get('url')) .expect('Content-Type', /json/) .expect(200) @@ -144,7 +144,7 @@ describe('DB API (canary)', function () { const fsStub = sinon.stub(fs, 'writeFile').resolves(); return request.post(localUtils.API.getApiQuery(`db/backup`)) - .set('Authorization', `Ghost ${localUtils.getValidAdminToken('/canary/admin/', schedulerKey)}`) + .set('Authorization', `Ghost ${localUtils.getValidAdminToken('/admin/', schedulerKey)}`) .set('Origin', config.get('url')) .expect('Content-Type', /json/) .expect(403) diff --git a/test/regression/api/admin/schedules.test.js b/test/regression/api/admin/schedules.test.js index f6fabe5524..0d8c7bdb80 100644 --- a/test/regression/api/admin/schedules.test.js +++ b/test/regression/api/admin/schedules.test.js @@ -89,7 +89,7 @@ describe('Canary Schedules API', function () { before(function () { const schedulerKey = _.find(testUtils.getExistingData().apiKeys, {integration: {slug: 'ghost-scheduler'}}); - token = localUtils.getValidAdminToken('/canary/admin/', schedulerKey); + token = localUtils.getValidAdminToken('/admin/', schedulerKey); }); it('publishes posts', async function () { @@ -123,7 +123,7 @@ describe('Canary Schedules API', function () { it('no access', function () { const zapierKey = _.find(testUtils.getExistingData().apiKeys, {integration: {slug: 'ghost-backup'}}); - const zapierToken = localUtils.getValidAdminToken('/canary/admin/', zapierKey); + const zapierToken = localUtils.getValidAdminToken('/admin/', zapierKey); return request .put(localUtils.API.getApiQuery(`schedules/posts/${resources[0].id}/?token=${zapierToken}`)) diff --git a/test/regression/api/admin/utils.js b/test/regression/api/admin/utils.js index eb74f13fae..efb5f57cce 100644 --- a/test/regression/api/admin/utils.js +++ b/test/regression/api/admin/utils.js @@ -1,7 +1,7 @@ const url = require('url'); const testUtils = require('../../../utils'); -const API_URL = '/ghost/api/canary/admin/'; +const API_URL = '/ghost/api/admin/'; const expectedProperties = { posts: ['posts', 'meta'], diff --git a/test/regression/api/admin/webhooks.test.js b/test/regression/api/admin/webhooks.test.js index c629662420..eaf552dd98 100644 --- a/test/regression/api/admin/webhooks.test.js +++ b/test/regression/api/admin/webhooks.test.js @@ -27,7 +27,7 @@ describe('Webhooks API (canary)', function () { }; return request.post(localUtils.API.getApiQuery('webhooks/')) - .set('Authorization', `Ghost ${localUtils.getValidAdminToken('/canary/admin/', testUtils.DataGenerator.Content.api_keys[0])}`) + .set('Authorization', `Ghost ${localUtils.getValidAdminToken('/admin/', testUtils.DataGenerator.Content.api_keys[0])}`) .send({webhooks: [webhookData]}) .expect('Content-Type', /json/) .expect('Cache-Control', testUtils.cacheRules.private) @@ -134,7 +134,7 @@ describe('Webhooks API (canary)', function () { [createdWebhook] = body.webhooks; return request.put(localUtils.API.getApiQuery(`webhooks/${createdWebhook.id}/`)) - .set('Authorization', `Ghost ${localUtils.getValidAdminToken('/canary/admin/', testUtils.DataGenerator.Content.api_keys[0])}`) + .set('Authorization', `Ghost ${localUtils.getValidAdminToken('/admin/', testUtils.DataGenerator.Content.api_keys[0])}`) .send({ webhooks: [{ name: 'Edit Test', @@ -146,14 +146,14 @@ describe('Webhooks API (canary)', function () { }) .then(() => { return request.del(localUtils.API.getApiQuery(`webhooks/${createdWebhook.id}/`)) - .set('Authorization', `Ghost ${localUtils.getValidAdminToken('/canary/admin/', testUtils.DataGenerator.Content.api_keys[0])}`) + .set('Authorization', `Ghost ${localUtils.getValidAdminToken('/admin/', testUtils.DataGenerator.Content.api_keys[0])}`) .expect(403); }); }); it('Integration editing non-existing webhook returns 404', function () { return request.put(localUtils.API.getApiQuery(`webhooks/5f27d0287c75da744d8615da/`)) - .set('Authorization', `Ghost ${localUtils.getValidAdminToken('/canary/admin/', testUtils.DataGenerator.Content.api_keys[0])}`) + .set('Authorization', `Ghost ${localUtils.getValidAdminToken('/admin/', testUtils.DataGenerator.Content.api_keys[0])}`) .send({ webhooks: [{ name: 'Edit Test' @@ -164,7 +164,7 @@ describe('Webhooks API (canary)', function () { it('Integration deleting non-existing webhook returns 404', function () { return request.delete(localUtils.API.getApiQuery(`webhooks/5f27d0287c75da744d8615db/`)) - .set('Authorization', `Ghost ${localUtils.getValidAdminToken('/canary/admin/', testUtils.DataGenerator.Content.api_keys[0])}`) + .set('Authorization', `Ghost ${localUtils.getValidAdminToken('/admin/', testUtils.DataGenerator.Content.api_keys[0])}`) .expect(404); }); @@ -175,7 +175,7 @@ describe('Webhooks API (canary)', function () { }; return request.post(localUtils.API.getApiQuery('webhooks/')) - .set('Authorization', `Ghost ${localUtils.getValidAdminToken('/canary/admin/', testUtils.DataGenerator.Content.api_keys[1])}`) + .set('Authorization', `Ghost ${localUtils.getValidAdminToken('/admin/', testUtils.DataGenerator.Content.api_keys[1])}`) .send({webhooks: [webhookData]}) .expect('Content-Type', /json/) .expect('Cache-Control', testUtils.cacheRules.private) diff --git a/test/regression/api/content/posts.test.js b/test/regression/api/content/posts.test.js index 5afd6576c2..bf2cf41abe 100644 --- a/test/regression/api/content/posts.test.js +++ b/test/regression/api/content/posts.test.js @@ -220,7 +220,7 @@ describe('api/canary/content/posts', function () { } res.headers.vary.should.eql('Accept, Accept-Encoding'); - res.headers.location.should.eql(`http://localhost:9999/ghost/api/canary/content/posts/?key=${validKey}`); + res.headers.location.should.eql(`http://localhost:9999/ghost/api/content/posts/?key=${validKey}`); should.exist(res.headers['access-control-allow-origin']); should.not.exist(res.headers['x-cache-invalidate']); done(); diff --git a/test/regression/api/content/utils.js b/test/regression/api/content/utils.js index 6830928fd1..6ee3385c48 100644 --- a/test/regression/api/content/utils.js +++ b/test/regression/api/content/utils.js @@ -2,7 +2,7 @@ const url = require('url'); const _ = require('lodash'); const testUtils = require('../../../utils'); const schema = require('../../../../core/server/data/schema').tables; -const API_URL = '/ghost/api/canary/content/'; +const API_URL = '/ghost/api/content/'; const expectedProperties = { // API top level diff --git a/test/regression/mock-express-style/parent-app-vhosts.test.js b/test/regression/mock-express-style/parent-app-vhosts.test.js index f5c1a8248b..f3c1de893e 100644 --- a/test/regression/mock-express-style/parent-app-vhosts.test.js +++ b/test/regression/mock-express-style/parent-app-vhosts.test.js @@ -9,7 +9,7 @@ const themeEngine = require('../../../core/frontend/services/theme-engine'); describe('Integration - Web - vhosts', function () { let app; - const ADMIN_API_URL = '/ghost/api/canary/admin'; + const ADMIN_API_URL = '/ghost/api/admin'; before(testUtils.teardownDb); diff --git a/test/unit/frontend/services/theme-engine/engines/create.test.js b/test/unit/frontend/services/theme-engine/engines/create.test.js index eba63a677c..6321d48874 100644 --- a/test/unit/frontend/services/theme-engine/engines/create.test.js +++ b/test/unit/frontend/services/theme-engine/engines/create.test.js @@ -56,7 +56,7 @@ describe('Themes: engines', function () { it('not supported upcoming version falls back to default version', function () { const engines = themeEngines.create({ engines: { - 'ghost-api': 'v5' + 'ghost-api': 'v6' } }); diff --git a/test/unit/server/services/auth/api-key/admin.test.js b/test/unit/server/services/auth/api-key/admin.test.js index abae5ab3e1..56e82e3620 100644 --- a/test/unit/server/services/auth/api-key/admin.test.js +++ b/test/unit/server/services/auth/api-key/admin.test.js @@ -6,7 +6,7 @@ const apiKeyAuth = require('../../../../../../core/server/services/auth/api-key' const models = require('../../../../../../core/server/models'); describe('Admin API Key Auth', function () { - const ADMIN_API_URL = '/ghost/api/canary/admin/'; + const ADMIN_API_URL = '/ghost/api/v4/admin/'; const ADMIN_API_URL_NON_VERSIONED = '/ghost/api/admin/'; before(models.init); @@ -32,13 +32,13 @@ describe('Admin API Key Auth', function () { sinon.restore(); }); - it('should authenticate known+valid canary API key', function (done) { + it('should authenticate known+valid v4 API key', function (done) { const token = jwt.sign({ }, this.secret, { keyid: this.fakeApiKey.id, algorithm: 'HS256', expiresIn: '5m', - audience: '/canary/admin/', + audience: '/v4/admin/', issuer: this.fakeApiKey.id }); @@ -153,7 +153,7 @@ describe('Admin API Key Auth', function () { keyid: this.fakeApiKey.id, algorithm: 'HS256', expiresIn: '5m', - audience: '/canary/admin/', + audience: '/v4/admin/', issuer: this.fakeApiKey.id }); @@ -183,7 +183,7 @@ describe('Admin API Key Auth', function () { keyid: this.fakeApiKey.id, algorithm: 'HS256', expiresIn: '10m', - audience: '/canary/admin/', + audience: '/v4/admin/', issuer: this.fakeApiKey.id }); @@ -211,7 +211,7 @@ describe('Admin API Key Auth', function () { keyid: this.fakeApiKey.id, algorithm: 'HS256', expiresIn: '5m', - audience: '/canary/admin/', + audience: 'v4/admin/', issuer: this.fakeApiKey.id }); diff --git a/test/unit/server/services/members/config.test.js b/test/unit/server/services/members/config.test.js index 0043dda692..f18bb5925b 100644 --- a/test/unit/server/services/members/config.test.js +++ b/test/unit/server/services/members/config.test.js @@ -49,8 +49,8 @@ function createUrlUtilsMock() { apiVersions: { all: ['canary'], canary: { - admin: 'canary/admin', - content: 'canary/content' + admin: 'admin', + content: 'content' } }, defaultApiVersion: 'canary', diff --git a/test/unit/server/services/stripe/config.test.js b/test/unit/server/services/stripe/config.test.js index dcbc79064a..8cac7712ea 100644 --- a/test/unit/server/services/stripe/config.test.js +++ b/test/unit/server/services/stripe/config.test.js @@ -50,8 +50,8 @@ function createUrlUtilsMock() { apiVersions: { all: ['canary'], canary: { - admin: 'canary/admin', - content: 'canary/content' + admin: 'admin', + content: 'content' } }, defaultApiVersion: 'canary', diff --git a/test/utils/e2e-framework.js b/test/utils/e2e-framework.js index b88f68b632..038b1fbdab 100644 --- a/test/utils/e2e-framework.js +++ b/test/utils/e2e-framework.js @@ -155,7 +155,7 @@ const getContentAPIAgent = async () => { const originURL = configUtils.config.get('url'); return new ContentAPITestAgent(app, { - apiURL: '/ghost/api/canary/content/', + apiURL: '/ghost/api/content/', originURL }); } catch (error) { @@ -185,7 +185,7 @@ const getAdminAPIAgent = async (options = {}) => { const originURL = configUtils.config.get('url'); return new AdminAPITestAgent(app, { - apiURL: '/ghost/api/canary/admin/', + apiURL: '/ghost/api/admin/', originURL }); } catch (error) { @@ -240,7 +240,7 @@ const getAgentsForMembers = async () => { originURL }); adminAgent = new AdminAPITestAgent(app, { - apiURL: '/ghost/api/canary/admin/', + apiURL: '/ghost/api/admin/', originURL }); } catch (error) {