0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Commented out flaky webmention test

refs https://ghost.slack.com/archives/C02G9E68C/p1675934676146349

- Commented out the rate limiter test as it proves to be flaky on CI,
  till we find a better way of implementing it.
This commit is contained in:
Ronald Langeveld 2023-02-09 21:35:15 +08:00
parent 4e8af72305
commit 4096571b8d

View file

@ -175,41 +175,43 @@ describe('Webmentions (receiving)', function () {
emailMockReceiver.sentEmailCount(0);
});
// @TODO this test is flaky, needs to find a better way to test rate limiting.
// No issues locally, and sometimes passes on CI, but is not reliable.
it('is rate limited against spamming mention requests', async function () {
await dbUtils.truncate('brute');
const webmentionBlock = configUtils.config.get('spam').webmentions_block;
const targetUrl = new URL(urlUtils.getSiteUrl());
const sourceUrl = new URL('http://testpage.com/external-article-2/');
const html = `
<html><head><title>Test Page</title><meta name="description" content="Test description"><meta name="author" content="John Doe"></head><body></body></html>
`;
nock(targetUrl.origin)
.head(targetUrl.pathname)
.reply(200);
// it('is rate limited against spamming mention requests', async function () {
// await dbUtils.truncate('brute');
// const webmentionBlock = configUtils.config.get('spam').webmentions_block;
// const targetUrl = new URL(urlUtils.getSiteUrl());
// const sourceUrl = new URL('http://testpage.com/external-article-2/');
// const html = `
// <html><head><title>Test Page</title><meta name="description" content="Test description"><meta name="author" content="John Doe"></head><body></body></html>
// `;
// nock(targetUrl.origin)
// .head(targetUrl.pathname)
// .reply(200);
nock(sourceUrl.origin)
.get(sourceUrl.pathname)
.reply(200, html, {'Content-Type': 'text/html'});
// nock(sourceUrl.origin)
// .get(sourceUrl.pathname)
// .reply(200, html, {'Content-Type': 'text/html'});
// +1 because this is a retry count, so we have one request + the retries, then blocked
for (let i = 0; i < webmentionBlock.freeRetries + 1; i++) {
await agent.post('/receive/')
.body({
source: sourceUrl.href,
target: targetUrl.href,
payload: {}
})
.expectStatus(202);
}
// // +1 because this is a retry count, so we have one request + the retries, then blocked
// for (let i = 0; i < webmentionBlock.freeRetries + 1; i++) {
// await agent.post('/receive/')
// .body({
// source: sourceUrl.href,
// target: targetUrl.href,
// payload: {}
// })
// .expectStatus(202);
// }
await agent
.post('/receive/')
.body({
source: sourceUrl.href,
target: targetUrl.href,
payload: {}
})
.expectStatus(429);
});
// await agent
// .post('/receive/')
// .body({
// source: sourceUrl.href,
// target: targetUrl.href,
// payload: {}
// })
// .expectStatus(429);
// });
});