-
Notifications
You must be signed in to change notification settings - Fork 31
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(multipart): accept multipart/form-data with boundary #1499
Conversation
Test image available:
|
src/main/java/io/cryostat/net/web/http/api/v2/RulesPostHandler.java
Outdated
Show resolved
Hide resolved
src/test/java/io/cryostat/net/web/http/api/v2/RulesPostHandlerTest.java
Outdated
Show resolved
Hide resolved
Test image available:
|
src/test/java/io/cryostat/net/web/http/api/v2/RulesPostHandlerTest.java
Outdated
Show resolved
Hide resolved
src/test/java/io/cryostat/net/web/http/api/v2/RulesPostHandlerTest.java
Outdated
Show resolved
Hide resolved
Test image available:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
If you're interested, I can also walk you through how to add an integration test so we can be really sure that this is working as intended when the whole application is deployed and interacting over a real network stack with a real HTTP client.
yes that will be great. |
In this case there is already an existing integration test exercising most of the same code, it just missed this particular case. https://github.com/cryostatio/cryostat/blob/main/src/test/java/itest/RulesPostFormIT.java Generally, just creating a new file in that directory with the name pattern When the unit tests run it is only testing the direct code under test, just the methods being called in the compiled bytecode. In the integration test harness an actual Cryostat server instance is brought up within a container, and there are tools for adding additional target applications for testing functionality. Rather than calling methods directly like in a unit test, you interact with the server using an HTTP client in a separate process, so it's a lot like the manual testing you have been doing with |
To build the server and run the integration tests you can do Any requests you make to the server in the integration tests should be carefully cleaned up afterward, so that those changes do not affect tests that run later. So for example since your test will be attempting to create a new Automated Rule definition, you should also have an Once the integration test run finishes (whether tests pass or fail), the database, storage directories, etc. will be dropped, and the next integration test run will use fresh copies of everything. So at least in between test runs things are guaranteed to start from a clean slate, it is only in between individual tests or test classes that cleanup has to be done manually. |
Test image available:
|
Test image available:
|
Test image available:
|
…ed a code to split the contentType
Signed-off-by: Atif Ali <atali@rehat.com>
217d02d
to
37fdf47
Compare
Test image available:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! Congrats on your first PR approval :-)
Signed-off-by: Atif Ali <atali@rehat.com> Co-authored-by: Atif Ali <atali@rehat.com> (cherry picked from commit 3f191a7)
Thank you so much @andrewazores for the guidance and help! |
Welcome to Cryostat! 👋
Before contributing, make sure you have:
main
branch[chore, ci, docs, feat, fix, test]
git commit --amend --signoff
Fixes: #1490
Description of the change:
Accept multipart forms with boundaries when creating automated rules
Motivation for the change:
This change is helpful because user may send requests with multiple Content-Type header entries including delimiters like semicolons ':' . The automated rule will not fail i.e the content type will discard anything that comes after multipart/form and the semicolon.
How to manually test:
$ curl -vk -F name="firstRule" -F matchExpression="target.labels[\"app\"]==\"jfr-sb-app\"" -F eventSpecifier="template=Profiling,type=TARGET" https://localhost:8181/api/v2/rules -H 'Accept: application/json' -H 'Content-Type: multipart/form-data'