-
Notifications
You must be signed in to change notification settings - Fork 77
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: PostPolicyV4 classes could be improved #442
Conversation
Codecov Report
@@ Coverage Diff @@
## master #442 +/- ##
============================================
+ Coverage 63.17% 64.12% +0.95%
- Complexity 619 623 +4
============================================
Files 32 32
Lines 5133 5177 +44
Branches 489 498 +9
============================================
+ Hits 3243 3320 +77
+ Misses 1726 1693 -33
Partials 164 164
Continue to review full report at Codecov.
|
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.
Tests should be written before the model code and absolutely in the same PR.
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.
Comment changes don't need tests but this PR changes behavior. Every behavioral change should be proceeded by a test that fails and only passes after the model code is added.
google-cloud-storage/src/main/java/com/google/cloud/storage/PostPolicyV4.java
Show resolved
Hide resolved
google-cloud-storage/src/main/java/com/google/cloud/storage/PostPolicyV4.java
Show resolved
Hide resolved
google-cloud-storage/src/main/java/com/google/cloud/storage/PostPolicyV4.java
Show resolved
Hide resolved
All the tests have been developed. Will much appreciate if you take a look. |
*/ | ||
public final class PostPolicyV4 { | ||
private final String url; | ||
private final Map<String, String> fields; | ||
|
||
private PostPolicyV4(String url, Map<String, String> fields) { | ||
try { | ||
new URL(url); |
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.
What URLs do you really want to allow and not allow here? java.net.URL is based on java protocol handlers, and is likely to be either too lenient or too strict depending on what you need.
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.
I want to allow strings that could be used to construct an URL object and reject strings like 'google.com' given by mistake instead of 'https://google.com'. Catching 'ftp://google.com' is not the goal.
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.
sounds like new URI(url).isAbsolute()
is your best bet then
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.
agree, fixed.
Fixes #440
(new tests will be suggested in a separate PR)