Skip to content

Commit

Permalink
test(nginx): assert 404 on known scraping targets
Browse files Browse the repository at this point in the history
  • Loading branch information
thekaveman committed Apr 14, 2023
1 parent a1586a2 commit 08dc906
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/cypress/specs/scrapers.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const endpoints = ["auth", "cgi", "eligibility/app", "login", "sample/api"];
const files = [".env", "wp-admin/login.php", "data.json", "secrets/prod.yaml"];

const visit = (partial_path) => {
return cy.request({
method: "GET",
url: `/${partial_path}`,
// allow cypress to continue on 404
failOnStatusCode: false,
});
};

const NOT_FOUND = 404;

describe("Scraper filtering spec", () => {
endpoints.forEach((endpoint) => {
it(`404s known scraper endpoint pattern: /${endpoint}`, () => {
visit(endpoint).then((res) => {
expect(res.status).to.eq(NOT_FOUND);
});
});
});

files.forEach((file) => {
it(`404s known scraper file pattern: /${file}`, () => {
visit(file).then((res) => {
expect(res.status).to.eq(NOT_FOUND);
});
});
});
});

0 comments on commit 08dc906

Please sign in to comment.