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 16
16
17
17
import base64
18
18
import binascii
19
+ import collections
19
20
import datetime
20
21
import functools
21
22
import json
@@ -972,7 +973,14 @@ def generate_signed_post_policy_v4(
972
973
973
974
# encode policy for signing
974
975
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
+ ),
976
984
separators = ("," , ":" ),
977
985
)
978
986
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):
1762
1762
scheme = in_data .get ("scheme" ),
1763
1763
)
1764
1764
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" ]
1765
1769
1766
1770
for field in (
1767
1771
"x-goog-algorithm" ,
@@ -1771,9 +1775,6 @@ def test_conformance_post_policy(test_data):
1771
1775
):
1772
1776
assert fields [field ] == test_data ["policyOutput" ]["fields" ][field ]
1773
1777
1774
- out_data = test_data ["policyOutput" ]
1775
- decoded_policy = base64 .b64decode (fields ["policy" ]).decode ("unicode_escape" )
1776
- assert decoded_policy == out_data ["expectedDecodedPolicy" ]
1777
1778
assert policy ["url" ] == out_data ["url" ]
1778
1779
1779
1780
You can’t perform that action at this time.
0 commit comments