Skip to content

Commit dddaec0

Browse files
romainrhuebuild
authored andcommitted
[lib] Change boto2 to not override the User Agent if already present
This enables to reuse the boto HttpRequest client with Raz signed URLs. The Raz URLs are signed and the User Agent is part of the signature, so this one should not be changed.
1 parent db2ecc8 commit dddaec0

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

desktop/libs/aws/src/aws/s3/s3connection_test.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ def test_list_buckets(self):
5252
with patch('aws.s3.s3connection.S3RazClient.get_url') as get_url:
5353
with patch('aws.s3.s3connection.RazS3Connection._mexe') as _mexe:
5454

55-
get_url.return_value = 'https://gethue-test.s3.amazonaws.com/?' + \
56-
'AWSAccessKeyId=AKIA23E77ZX2HVY76YGL' + \
57-
'&Signature=3lhK%2BwtQ9Q2u5VDIqb4MEpoY3X4%3D&Expires=1617207304'
55+
get_url.return_value = {
56+
'AWSAccessKeyId': 'AKIA23E77ZX2HVY76YGL',
57+
'Signature': '3lhK%2BwtQ9Q2u5VDIqb4MEpoY3X4%3D',
58+
'Expires': '1617207304'
59+
}
5860
_mexe.return_value = ['<Bucket: demo-gethue>', '<Bucket: gethue-test>']
5961

6062
client = RazS3Connection(host='s3-us-west-1.amazonaws.com')
@@ -73,12 +75,15 @@ def test_list_buckets(self):
7375
's3-us-west-1.amazonaws.com:443' if sys.version_info[0] > 2 else 's3-us-west-1.amazonaws.com',
7476
http_request.host
7577
)
76-
assert_equal(
77-
'/?AWSAccessKeyId=AKIA23E77ZX2HVY76YGL&Signature=3lhK%2BwtQ9Q2u5VDIqb4MEpoY3X4%3D&Expires=1617207304',
78-
http_request.path
79-
)
78+
assert_equal('/', http_request.path)
8079
assert_equal('/', http_request.auth_path)
81-
assert_equal({}, http_request.headers )
80+
assert_equal({
81+
'AWSAccessKeyId': 'AKIA23E77ZX2HVY76YGL',
82+
'Signature': '3lhK%2BwtQ9Q2u5VDIqb4MEpoY3X4%3D',
83+
'Expires': '1617207304'
84+
},
85+
http_request.headers
86+
)
8287
assert_equal({}, http_request.params)
8388
assert_equal('', http_request.body)
8489

0 commit comments

Comments
 (0)