@@ -25,6 +25,38 @@ pub fn create_upload_request(
2525 request
2626}
2727
28+ #[ tokio:: test]
29+ async fn test_config_enforced_max_image_size_plus_one_fails ( ) {
30+ let setup = TestSetup :: new ( None ) . await ;
31+
32+ // Fetch media config
33+ let response = setup
34+ . send_get_request ( "/v1/media/config" )
35+ . await
36+ . expect ( "Failed to send GET /v1/media/config" ) ;
37+ assert_eq ! ( response. status( ) , StatusCode :: OK ) ;
38+ let body = parse_response_body ( response) . await ;
39+
40+ let max_image_size_bytes = body[ "max_image_size_bytes" ]
41+ . as_i64 ( )
42+ . expect ( "max_image_size_bytes should be an integer" ) ;
43+
44+ // Prepare an upload one byte larger than allowed
45+ let content_digest_sha256 = create_valid_sha256 ( ) ;
46+ let payload = create_upload_request (
47+ content_digest_sha256,
48+ max_image_size_bytes + 1 ,
49+ Some ( "image/png" . to_string ( ) ) ,
50+ ) ;
51+
52+ let response = setup
53+ . send_post_request ( "/v1/media/presigned-urls" , payload)
54+ . await
55+ . expect ( "Failed to send POST /v1/media/presigned-urls" ) ;
56+
57+ assert_eq ! ( response. status( ) , StatusCode :: BAD_REQUEST ) ;
58+ }
59+
2860// Happy path tests
2961
3062#[ tokio:: test]
@@ -413,6 +445,21 @@ async fn test_upload_media_extra_fields() {
413445async fn test_e2e_upload_happy_path ( ) {
414446 let setup = TestSetup :: new ( None ) . await ;
415447
448+ // Fetch config to validate CDN URL
449+ let response = setup
450+ . send_get_request ( "/v1/media/config" )
451+ . await
452+ . expect ( "Failed to send GET /v1/media/config" ) ;
453+ assert_eq ! ( response. status( ) , StatusCode :: OK ) ;
454+ let response_body = setup
455+ . parse_response_body ( response)
456+ . await
457+ . expect ( "Failed to parse response body" ) ;
458+ let trusted_cdn_url = response_body[ "trusted_cdn_url" ]
459+ . as_str ( )
460+ . expect ( "Missing trusted_cdn_url in response" ) ;
461+ println ! ( "Trusted CDN URL: {}" , trusted_cdn_url) ;
462+
416463 // Step 1: Generate test image data with known SHA-256
417464 let ( image_data, sha256) = generate_test_encrypted_image ( 2048 ) ;
418465 println ! (
@@ -460,6 +507,11 @@ async fn test_e2e_upload_happy_path() {
460507 . as_str ( )
461508 . expect ( "Missing asset_url in response" ) ;
462509
510+ assert ! (
511+ asset_url. starts_with( trusted_cdn_url) ,
512+ "Asset URL should start with trusted CDN URL"
513+ ) ;
514+
463515 // Verify response format
464516 assert ! (
465517 presigned_url. contains( "localhost:4566" ) ,
0 commit comments