File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed
Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -906,7 +906,8 @@ def validate_metadata_size(
906906 return wrapped (* args , ** kwargs )
907907 decoded = base64 .b64decode (application_metadata )
908908
909- if len (decoded ) <= 1024 * 1024 :
909+ max_metadata_bytes = 1024 * 1024 - 1
910+ if len (decoded ) <= max_metadata_bytes :
910911 return wrapped (* args , ** kwargs )
911912
912913 context .status_code = codes .UNPROCESSABLE_ENTITY
Original file line number Diff line number Diff line change @@ -645,11 +645,13 @@ class TestApplicationMetadata:
645645 Tests for the application metadata parameter.
646646 """
647647
648+ _MAX_METADATA_BYTES = 1024 * 1024 - 1
649+
648650 @pytest .mark .parametrize (
649651 'metadata' ,
650652 [
651653 b'a' ,
652- b'a' * ( 1024 * 1024 ) ,
654+ b'a' * _MAX_METADATA_BYTES ,
653655 ],
654656 ids = ['Short' , 'Max length' ],
655657 )
@@ -781,12 +783,12 @@ def test_metadata_too_large(
781783 png_rgb : io .BytesIO ,
782784 ) -> None :
783785 """
784- A base64 encoded string of up to 1024 * 1024 bytes is valid application
785- metadata.
786+ A base64 encoded string of greater than 1024 * 1024 bytes is too large
787+ for application metadata.
786788 """
787789 image_data = png_rgb .read ()
788790 image_data_encoded = base64 .b64encode (image_data ).decode ('ascii' )
789- metadata = b'a' * (1024 * 1024 + 1 )
791+ metadata = b'a' * (self . _MAX_METADATA_BYTES + 1 )
790792 metadata_encoded = base64 .b64encode (metadata ).decode ('ascii' )
791793
792794 data = {
You can’t perform that action at this time.
0 commit comments