Conversation
in addition to just "data:*base64" prefix, also 1. check image size 2. verify that the base64 part is a valid parseable image data 3. validate XML format in case of SVG images
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1694 +/- ##
============================================
- Coverage 92.36% 92.24% -0.13%
+ Complexity 3418 3414 -4
============================================
Files 334 334
Lines 6760 6758 -2
Branches 671 670 -1
============================================
- Hits 6244 6234 -10
- Misses 352 356 +4
- Partials 164 168 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| import java.awt.Color; | ||
| import java.awt.*; | ||
| import java.awt.Color; |
There was a problem hiding this comment.
I'm not sure why we have one specific import for colour and one for the entire package. Could you do away with the wildcard and use all specific imports?
| byte[] bytes = Base64.getDecoder().decode(content); | ||
| try { | ||
| String xml = new String(bytes); | ||
| assertThat(xml).matches("<svg xmlns=\".+\" width=\"256\" height=\"256\">.*"); |
There was a problem hiding this comment.
Ends with a closing svg tag?
There was a problem hiding this comment.
Or will the assert at 76 catch this if there isn't a closing tag?
There was a problem hiding this comment.
good point, added </svg> (though - yes, 76 line also checks the same thing).
| @Test | ||
| void tiff() { | ||
| assertThat(faker.image().base64TIFF()).startsWith("data:image/tiff;base64,"); | ||
| assertThatImage(faker.image().base64TIFF()).is(TIFF, 256, 256); |
There was a problem hiding this comment.
Since these are all using 256x256 make a method that just takes the image type as a parameter?
There was a problem hiding this comment.
thanks. Created method is(type) which by default assumes 256x256.
There was a problem hiding this comment.
Wouldn't it be better to use a custom assert here? Like:
assertThat(image).is(TIFF, 256, 256);
There was a problem hiding this comment.
Yes, and this is the custom assert :)
Method assertThatImage returns the custom assert.
in addition to just "data:*base64" prefix, also