Skip to content

Commit

Permalink
fix: check for state.info (#779)
Browse files Browse the repository at this point in the history
fixes #778
  • Loading branch information
tripodsan authored Jan 1, 2025
1 parent 927631c commit 57a1818
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/forms-pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ export async function formsPipe(state, req) {
res.headers.set('x-error', 'contentBusId missing');
return res;
}
if (!state.info) {
res.status = 400;
res.headers.set('x-error', 'no valid path');
return res;
}

await fetchConfigAll(state, req, res);
await authenticate(state, req, res);
Expand Down
16 changes: 16 additions & 0 deletions test/forms-pipe.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,22 @@ describe('Form POST Requests', () => {
assert.strictEqual(resp.status, 405);
});

it('POST request with trailing dot', async () => {
const req = new PipelineRequest('https://helix-pipeline.com/', defaultRequest);
const state = new PipelineState({
owner: 'owner',
repo: 'repo',
ref: 'ref',
partition: 'live',
path: '/somepath/.',
log: console,
s3Loader: mockHelixConfig(new StaticS3Loader()),
});

const resp = await formsPipe(state, req);
assert.strictEqual(resp.status, 400);
});

it('no post body', async () => {
const req = new PipelineRequest('https://helix-pipeline.com/', {
...defaultRequest,
Expand Down

0 comments on commit 57a1818

Please sign in to comment.