Skip to content

Commit

Permalink
test(post-deploy): make eslint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
trieloff committed Dec 11, 2024
1 parent 6296a38 commit 6f8b0a2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ export async function main(req, ctx) {
}

// Block access to sensitive files
if (pathname.toLowerCase().includes('package.json') ||
pathname.toLowerCase().includes('changelog.md')) {
if (pathname.toLowerCase().includes('package.json')
|| pathname.toLowerCase().includes('changelog.md')) {
return respondError('Not Found', 404, undefined, req);
}

Expand Down
29 changes: 18 additions & 11 deletions test/post-deploy.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -265,19 +265,26 @@ import assert from 'assert';
if (!process.env.TEST_INTEGRATION) {
this.skip();
}
const sensitiveUrls = [
'/.rum/@adobe/helix-rum-js@^2/package.json',
'/.rum/@adobe/helix-rum-js@^2/CHANGELOG.md'
];
const url = '/.rum/@adobe/helix-rum-js@^2/package.json';
const response = await fetch(`https://${domain}${url}`, {
method: 'GET',
});
assert.strictEqual(response.status, 404, `Expected 404 for ${url}`);
const text = await response.text();
assert.match(text, /Not Found/);
});

for (const url of sensitiveUrls) {
const response = await fetch(`https://${domain}${url}`, {
method: 'GET'
});
assert.strictEqual(response.status, 404, `Expected 404 for ${url}`);
const text = await response.text();
assert.match(text, /Not Found/);
it('Sensitive files return 404 - CHANGELOG.md', async function test() {
if (!process.env.TEST_INTEGRATION) {
this.skip();
}
const url = '/.rum/@adobe/helix-rum-js@^2/CHANGELOG.md';
const response = await fetch(`https://${domain}${url}`, {
method: 'GET',
});
assert.strictEqual(response.status, 404, `Expected 404 for ${url}`);
const text = await response.text();
assert.match(text, /Not Found/);
});
});
});

0 comments on commit 6f8b0a2

Please sign in to comment.