mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-24 14:43:08 +03:00
Deleted mail/
Admin API endpoint
refs https://github.com/TryGhost/Toolbox/issues/308 - this endpoint isn't used by Admin, nor Ghost, and isn't documented publicly - we are nuking it in v5 so the easiest step to achieve that is by removing the API route mounts - there's plenty of cleanup here, including refactoring other API controllers to avoid using the `mail` API controller, but this is the easiest way to achieve what we want
This commit is contained in:
parent
b788604e15
commit
10874100ef
@ -201,10 +201,6 @@ module.exports = function apiRoutes() {
|
||||
http(api.db.backupContent)
|
||||
);
|
||||
|
||||
// ## Mail
|
||||
router.post('/mail', mw.authAdminApi, http(api.mail.send));
|
||||
router.post('/mail/test', mw.authAdminApi, http(api.mail.sendTest));
|
||||
|
||||
// ## Slack
|
||||
router.post('/slack/test', mw.authAdminApi, http(api.slack.sendTest));
|
||||
|
||||
|
@ -1,48 +0,0 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Mail API Can send a test mail 1: [body] 1`] = `
|
||||
Object {
|
||||
"message": "sent",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Mail API Can send a test mail 2: [headers] 1`] = `
|
||||
Object {
|
||||
"access-control-allow-origin": "http://127.0.0.1:2369",
|
||||
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||
"content-length": "18",
|
||||
"content-type": "application/json; charset=utf-8",
|
||||
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||
"vary": "Origin, Accept-Encoding",
|
||||
"x-powered-by": "Express",
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Mail API Can send mail 1: [body] 1`] = `
|
||||
Object {
|
||||
"mail": Array [
|
||||
Object {
|
||||
"message": Object {
|
||||
"html": "<p>This</p>",
|
||||
"subject": "testemail",
|
||||
"to": "joe@example.com",
|
||||
},
|
||||
"status": Object {
|
||||
"message": "sent",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`Mail API Can send mail 2: [headers] 1`] = `
|
||||
Object {
|
||||
"access-control-allow-origin": "http://127.0.0.1:2369",
|
||||
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||
"content-length": "118",
|
||||
"content-type": "application/json; charset=utf-8",
|
||||
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||
"vary": "Origin, Accept-Encoding",
|
||||
"x-powered-by": "Express",
|
||||
}
|
||||
`;
|
@ -1,60 +0,0 @@
|
||||
const {agentProvider, fixtureManager, matchers, mockManager} = require('../../utils/e2e-framework');
|
||||
const {anyEtag} = matchers;
|
||||
|
||||
describe('Mail API', function () {
|
||||
let agent;
|
||||
|
||||
before(async function () {
|
||||
agent = await agentProvider.getAdminAPIAgent();
|
||||
await fixtureManager.init('invites');
|
||||
await agent.loginAsOwner();
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
mockManager.mockMail({message: 'sent'});
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
mockManager.restore();
|
||||
});
|
||||
|
||||
it('Can send mail', async function () {
|
||||
await agent
|
||||
.post('mail/')
|
||||
.body({
|
||||
mail: [{
|
||||
message: {
|
||||
to: 'joe@example.com',
|
||||
subject: 'testemail',
|
||||
html: '<p>This</p>'
|
||||
}
|
||||
}]
|
||||
})
|
||||
.expectStatus(200)
|
||||
.matchBodySnapshot()
|
||||
.matchHeaderSnapshot({
|
||||
etag: anyEtag
|
||||
});
|
||||
|
||||
mockManager.assert.sentEmail({
|
||||
to: 'joe@example.com',
|
||||
subject: 'testemail'
|
||||
});
|
||||
});
|
||||
|
||||
it('Can send a test mail', async function () {
|
||||
// @TODO: either remove this endpoint or fix its response body
|
||||
await agent
|
||||
.post('mail/test')
|
||||
.expectStatus(200)
|
||||
.matchBodySnapshot()
|
||||
.matchHeaderSnapshot({
|
||||
etag: anyEtag
|
||||
});
|
||||
|
||||
mockManager.assert.sentEmail({
|
||||
to: 'jbloggs@example.com',
|
||||
subject: 'Test Ghost Email'
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user