File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,7 @@ impl OperatorMetadata {
107
107
if path. extension ( ) . map ( |ext| ext != "png" ) . unwrap_or ( true ) {
108
108
return Err ( LogoUrlInvalidImageExtension ) ;
109
109
}
110
+ // Check the server returns content with a "image/png" mime type
110
111
let response = reqwest:: get ( & self . logo ) . await . unwrap ( ) ;
111
112
let body = response. bytes ( ) . await . unwrap ( ) ;
112
113
@@ -270,13 +271,21 @@ mod tests {
270
271
}
271
272
272
273
#[ tokio:: test]
273
- async fn test_invalid_wrong_image_format ( ) {
274
+ async fn test_invalid_logo_wrong_image_format ( ) {
274
275
let mut metadata = get_default_metadata ( ) ;
275
276
metadata. logo = "https://test.com/test.svg" . to_string ( ) ;
276
277
let err = metadata. validate ( ) . await . unwrap_err ( ) ;
277
278
assert_eq ! ( err, OperatorMetadataError :: LogoUrlInvalidImageExtension ) ;
278
279
}
279
280
281
+ #[ tokio:: test]
282
+ async fn test_invalid_logo_invalid_mime_type ( ) {
283
+ let mut metadata = get_default_metadata ( ) ;
284
+ metadata. logo = "https://goerli-operator-metadata.s3.amazonaws.com/cat.png" . to_string ( ) ;
285
+ let err = metadata. validate ( ) . await . unwrap_err ( ) ;
286
+ assert_eq ! ( err, OperatorMetadataError :: LogoUrlInvalidMimeType ) ;
287
+ }
288
+
280
289
#[ tokio:: test]
281
290
async fn test_invalid_website_url_1 ( ) {
282
291
let mut metadata = get_default_metadata ( ) ;
You can’t perform that action at this time.
0 commit comments