diff --git a/ghost/core/test/e2e-api/webmentions/webmentions.test.js b/ghost/core/test/e2e-api/webmentions/webmentions.test.js index 37b22bb2e3..989505d47c 100644 --- a/ghost/core/test/e2e-api/webmentions/webmentions.test.js +++ b/ghost/core/test/e2e-api/webmentions/webmentions.test.js @@ -153,8 +153,7 @@ describe('Webmentions (receiving)', function () { `; nock(sourceUrl.origin) .get(sourceUrl.pathname) - .reply(200, html, {'Content-Type': 'text/html'}) - .persist(); + .reply(200, html, {'Content-Type': 'text/html'}); testCreatingTheMention: { const processWebmentionJob = jobsService.awaitCompletion('processWebmention'); @@ -352,4 +351,97 @@ describe('Webmentions (receiving)', function () { }) .expectStatus(429); }); + + it('can verify a webmention link', async function () { + const processWebmentionJob = jobsService.awaitCompletion('processWebmention'); + const targetUrl = new URL(urlUtils.getSiteUrl()); + const sourceUrl = new URL('http://testpage.com/external-article-2/'); + const html = ` + Test Pageyour cool website mentioned + `; + nock(targetUrl.origin) + .head(targetUrl.pathname) + .reply(200); + + nock(sourceUrl.origin) + .persist() + .get(sourceUrl.pathname) + .reply(200, html, {'Content-Type': 'text/html'}); + + await agent.post('/receive') + .body({ + source: sourceUrl.href, + target: targetUrl.href + }) + .expectStatus(202); + + await processWebmentionJob; + + const mention = await models.Mention.findOne({source: 'http://testpage.com/external-article-2/'}); + + assert(mention); + assert.equal(mention.get('verified'), true); + }); + + it('can verifiy a webmention link', async function () { + const processWebmentionJob = jobsService.awaitCompletion('processWebmention'); + const targetUrl = new URL(urlUtils.getSiteUrl()); + const sourceUrl = new URL('http://testpage.com/external-article-2/'); + const html = ` + Test Page + `; + nock(targetUrl.origin) + .head(targetUrl.pathname) + .reply(200); + + nock(sourceUrl.origin) + .persist() + .get(sourceUrl.pathname) + .reply(200, html, {'Content-Type': 'text/html'}); + + await agent.post('/receive') + .body({ + source: sourceUrl.href, + target: targetUrl.href + }) + .expectStatus(202); + + await processWebmentionJob; + + const mention = await models.Mention.findOne({source: 'http://testpage.com/external-article-2/'}); + + assert(mention); + assert.equal(mention.get('verified'), true); + }); + + it('can verify a webmention