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(templates): Throw 400 when posting unexpected file upload name #602

Merged
merged 4 commits into from
Jul 26, 2021

Conversation

jan-law
Copy link
Contributor

@jan-law jan-law commented Jul 26, 2021

Fixes #601

When posting a file upload with a form attribute that doesn't match the name template, the TemplatesPostHandler will return an HTTP 400.

@jan-law
Copy link
Contributor Author

jan-law commented Jul 26, 2021

The unit tests shouldSendNotifcationOnTemplateDeletion and shouldProcessGoodRequest are failing because the requests include "unused" file uploads. My patch is stricter than the original implementation and doesn't allow extra form attributes in the request. Can I safely remove the following lines from those tests?

        FileUpload upload2 = Mockito.mock(FileUpload.class);
        Mockito.when(upload2.name()).thenReturn("unused");
        Mockito.when(upload2.uploadedFileName()).thenReturn("/file-uploads/wxyz-9999");

@andrewazores
Copy link
Member

That seems fine.

@jan-law jan-law requested a review from andrewazores July 26, 2021 16:08
andrewazores
andrewazores previously approved these changes Jul 26, 2021
@andrewazores andrewazores merged commit 25456c6 into cryostatio:main Jul 26, 2021
@jan-law jan-law deleted the unexpected-template-name branch July 26, 2021 19:55
tthvo pushed a commit to tthvo/cryostat-legacy that referenced this pull request Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Posting an invalid XML file as a template results in HTTP 200
2 participants