Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check for state.info #779

Merged
merged 1 commit into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading