File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 1616
1717import base64
1818import binascii
19+ import collections
1920import datetime
2021import functools
2122import json
@@ -972,7 +973,14 @@ def generate_signed_post_policy_v4(
972973
973974 # encode policy for signing
974975 policy = json .dumps (
975- {"conditions" : conditions , "expiration" : policy_expires .isoformat () + "Z" },
976+ collections .OrderedDict (
977+ sorted (
978+ {
979+ "conditions" : conditions ,
980+ "expiration" : policy_expires .isoformat () + "Z" ,
981+ }.items ()
982+ )
983+ ),
976984 separators = ("," , ":" ),
977985 )
978986 str_to_sign = base64 .b64encode (policy .encode ("utf-8" ))
Original file line number Diff line number Diff line change @@ -1762,6 +1762,10 @@ def test_conformance_post_policy(test_data):
17621762 scheme = in_data .get ("scheme" ),
17631763 )
17641764 fields = policy ["fields" ]
1765+ out_data = test_data ["policyOutput" ]
1766+
1767+ decoded_policy = base64 .b64decode (fields ["policy" ]).decode ("unicode_escape" )
1768+ assert decoded_policy == out_data ["expectedDecodedPolicy" ]
17651769
17661770 for field in (
17671771 "x-goog-algorithm" ,
@@ -1771,9 +1775,6 @@ def test_conformance_post_policy(test_data):
17711775 ):
17721776 assert fields [field ] == test_data ["policyOutput" ]["fields" ][field ]
17731777
1774- out_data = test_data ["policyOutput" ]
1775- decoded_policy = base64 .b64decode (fields ["policy" ]).decode ("unicode_escape" )
1776- assert decoded_policy == out_data ["expectedDecodedPolicy" ]
17771778 assert policy ["url" ] == out_data ["url" ]
17781779
17791780
You can’t perform that action at this time.
0 commit comments