0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-08 02:52:39 -05:00

Removed unused leftover spec in acceptance test suite

refs https://github.com/TryGhost/Team/issues/856

- These tests were created during work on v4 without a particular goal behind them. Because they don't do anything extra comparing to the existing tests there is no sense to keep them around
This commit is contained in:
Naz 2021-07-07 13:54:49 +04:00
parent e7b80e50dc
commit 09283bd151
3 changed files with 0 additions and 251 deletions

View file

@ -1,133 +0,0 @@
const should = require('should');
const Promise = require('bluebird');
const supertest = require('supertest');
const testUtils = require('../../utils');
const localUtils = require('./utils');
const config = require('../../../core/shared/config');
describe('Actions API', function () {
let request;
before(async function () {
await testUtils.startGhost();
request = supertest.agent(config.get('url'));
await localUtils.doAuth(request, 'integrations', 'api_keys');
});
// @NOTE: This test runs a little slower, because we store Dates without milliseconds.
it('Can request actions for resource', async function () {
let postUpdatedAt;
const res = await request
.post(localUtils.API.getApiQuery('posts/'))
.set('Origin', config.get('url'))
.send({
posts: [{
title: 'test post'
}]
})
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(201);
const postId = res.body.posts[0].id;
postUpdatedAt = res.body.posts[0].updated_at;
const res2 = await request
.get(localUtils.API.getApiQuery(`actions/?filter=resource_id:${postId}&include=actor`))
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(200);
localUtils.API.checkResponse(res2.body, 'actions');
localUtils.API.checkResponse(res2.body.actions[0], 'action');
res2.body.actions.length.should.eql(1);
res2.body.actions[0].resource_type.should.eql('post');
res2.body.actions[0].actor_type.should.eql('user');
res2.body.actions[0].event.should.eql('added');
Object.keys(res2.body.actions[0].actor).length.should.eql(4);
res2.body.actions[0].actor.id.should.eql(testUtils.DataGenerator.Content.users[0].id);
res2.body.actions[0].actor.image.should.eql(testUtils.DataGenerator.Content.users[0].profile_image);
res2.body.actions[0].actor.name.should.eql(testUtils.DataGenerator.Content.users[0].name);
res2.body.actions[0].actor.slug.should.eql(testUtils.DataGenerator.Content.users[0].slug);
await Promise.delay(1000);
const res3 = await request
.put(localUtils.API.getApiQuery(`posts/${postId}/`))
.set('Origin', config.get('url'))
.send({
posts: [{
slug: 'new-slug',
updated_at: postUpdatedAt
}]
})
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(200);
postUpdatedAt = res3.body.posts[0].updated_at;
const res4 = await request
.get(localUtils.API.getApiQuery(`actions/?filter=resource_id:${postId}&include=actor`))
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(200);
localUtils.API.checkResponse(res4.body, 'actions');
localUtils.API.checkResponse(res4.body.actions[0], 'action');
res4.body.actions.length.should.eql(2);
res4.body.actions[0].resource_type.should.eql('post');
res4.body.actions[0].actor_type.should.eql('user');
res4.body.actions[0].event.should.eql('edited');
Object.keys(res4.body.actions[0].actor).length.should.eql(4);
res4.body.actions[0].actor.id.should.eql(testUtils.DataGenerator.Content.users[0].id);
res4.body.actions[0].actor.image.should.eql(testUtils.DataGenerator.Content.users[0].profile_image);
res4.body.actions[0].actor.name.should.eql(testUtils.DataGenerator.Content.users[0].name);
res4.body.actions[0].actor.slug.should.eql(testUtils.DataGenerator.Content.users[0].slug);
await Promise.delay(1000);
const integrationRequest = supertest.agent(config.get('url'));
await integrationRequest
.put(localUtils.API.getApiQuery(`posts/${postId}/`))
.set('Origin', config.get('url'))
.set('Authorization', `Ghost ${localUtils.getValidAdminToken('/v3/admin/')}`)
.send({
posts: [{
featured: true,
updated_at: postUpdatedAt
}]
})
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(200);
const res5 = await request
.get(localUtils.API.getApiQuery(`actions/?filter=resource_id:${postId}&include=actor`))
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(200);
localUtils.API.checkResponse(res5.body, 'actions');
localUtils.API.checkResponse(res5.body.actions[0], 'action');
res5.body.actions.length.should.eql(3);
res5.body.actions[0].resource_type.should.eql('post');
res5.body.actions[0].actor_type.should.eql('integration');
res5.body.actions[0].event.should.eql('edited');
Object.keys(res5.body.actions[0].actor).length.should.eql(4);
res5.body.actions[0].actor.id.should.eql(testUtils.DataGenerator.Content.integrations[0].id);
should.equal(res5.body.actions[0].actor.image, null);
res5.body.actions[0].actor.name.should.eql(testUtils.DataGenerator.Content.integrations[0].name);
res5.body.actions[0].actor.slug.should.eql(testUtils.DataGenerator.Content.integrations[0].slug);
});
});

View file

@ -1,71 +0,0 @@
const should = require('should');
const supertest = require('supertest');
const testUtils = require('../../utils');
const config = require('../../../core/shared/config');
const localUtils = require('./utils');
describe('Admin API key authentication', function () {
let request;
before(async function () {
await testUtils.startGhost();
request = supertest.agent(config.get('url'));
await testUtils.initFixtures('api_keys');
});
it('Can not access endpoint without a token header', async function () {
await request.get(localUtils.API.getApiQuery('posts/'))
.set('Authorization', `Ghost`)
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(401);
});
it('Can not access endpoint with a wrong endpoint token', async function () {
await request.get(localUtils.API.getApiQuery('posts/'))
.set('Authorization', `Ghost ${localUtils.getValidAdminToken('https://wrong.com')}`)
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(401);
});
it('Can access browse endpoint with correct token', async function () {
await request.get(localUtils.API.getApiQuery('posts/'))
.set('Authorization', `Ghost ${localUtils.getValidAdminToken('/v3/admin/')}`)
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(200);
});
it('Can create post', async function () {
const post = {
title: 'Post created with api_key'
};
const res = await request
.post(localUtils.API.getApiQuery('posts/?include=authors'))
.set('Origin', config.get('url'))
.set('Authorization', `Ghost ${localUtils.getValidAdminToken('/v3/admin/')}`)
.send({
posts: [post]
})
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(201);
// falls back to owner user
res.body.posts[0].authors.length.should.eql(1);
});
it('Can read users', async function () {
const res = await request
.get(localUtils.API.getApiQuery('users/'))
.set('Origin', config.get('url'))
.set('Authorization', `Ghost ${localUtils.getValidAdminToken('/v3/admin/')}`)
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(200);
localUtils.API.checkResponse(res.body.users[0], 'user');
});
});

View file

@ -1,47 +0,0 @@
const path = require('path');
const should = require('should');
const supertest = require('supertest');
const sinon = require('sinon');
const testUtils = require('../../utils');
const localUtils = require('../../regression/api/v3/admin/utils');
const config = require('../../../core/shared/config');
describe('Labels API', function () {
let request;
after(function () {
sinon.restore();
});
before(async function () {
await testUtils.startGhost();
request = supertest.agent(config.get('url'));
await localUtils.doAuth(request);
});
it('Can add', async function () {
const label = {
name: 'test'
};
const res = await request
.post(localUtils.API.getApiQuery(`labels/`))
.send({labels: [label]})
.set('Origin', config.get('url'))
.expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private)
.expect(201);
should.not.exist(res.headers['x-cache-invalidate']);
const jsonResponse = res.body;
should.exist(jsonResponse);
should.exist(jsonResponse.labels);
jsonResponse.labels.should.have.length(1);
jsonResponse.labels[0].name.should.equal(label.name);
jsonResponse.labels[0].slug.should.equal(label.name);
should.exist(res.headers.location);
res.headers.location.should.equal(`http://127.0.0.1:2369${localUtils.API.getApiQuery('labels/')}${res.body.labels[0].id}/`);
});
});