summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMatt Houglum <houglum@google.com>2017-06-12 17:02:19 -0700
committerMatt Houglum <houglum@google.com>2017-06-13 14:23:22 -0700
commit221699bc561cc867f62f279d2ce9ed154b1b4369 (patch)
tree955baa6b8c2e898900c90c2307b4eb67aa64c918 /tests
parentaf045f93d70fbb4cdac2a8e57d040ce59935d45b (diff)
downloadboto-221699bc561cc867f62f279d2ce9ed154b1b4369.tar.gz
Allow specifying s3 host from boto config file.
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/s3/test_key.py5
-rw-r--r--tests/unit/s3/test_connection.py31
2 files changed, 32 insertions, 4 deletions
diff --git a/tests/integration/s3/test_key.py b/tests/integration/s3/test_key.py
index 16f0220b..471857a7 100644
--- a/tests/integration/s3/test_key.py
+++ b/tests/integration/s3/test_key.py
@@ -419,7 +419,10 @@ class S3KeyTest(unittest.TestCase):
remote_metadata = check._get_remote_metadata()
# TODO: investigate whether encoding ' ' as '%20' makes sense
- self.assertEqual(check.cache_control, 'public,%20max-age=500')
+ self.assertIn(
+ check.cache_control,
+ ('public,%20max-age=500', 'public, max-age=500')
+ )
self.assertEqual(remote_metadata['cache-control'], 'public,%20max-age=500')
self.assertEqual(check.get_metadata('test-plus'), 'A plus (+)')
self.assertEqual(check.content_disposition, 'filename=Sch%C3%B6ne%20Zeit.txt')
diff --git a/tests/unit/s3/test_connection.py b/tests/unit/s3/test_connection.py
index 5304cf5e..a1d43231 100644
--- a/tests/unit/s3/test_connection.py
+++ b/tests/unit/s3/test_connection.py
@@ -84,6 +84,8 @@ class TestSigV4HostError(MockServiceWithConfigTestCase):
self.assertEqual(self.service_connection.host, 's3.amazonaws.com')
def test_sigv4_opt_in(self):
+ host_value = 's3.cn-north-1.amazonaws.com.cn'
+
# Switch it at the config, so we can check to see how the host is
# handled.
self.config = {
@@ -92,6 +94,8 @@ class TestSigV4HostError(MockServiceWithConfigTestCase):
}
}
+ # Should raise an error if no host is given in either the config or
+ # in connection arguments.
with self.assertRaises(HostRequiredError):
# No host+SigV4 == KABOOM
self.connection_class(
@@ -99,11 +103,32 @@ class TestSigV4HostError(MockServiceWithConfigTestCase):
aws_secret_access_key='more'
)
- # Ensure passing a ``host`` still works.
+ # Ensure passing a ``host`` in the connection args still works.
conn = self.connection_class(
aws_access_key_id='less',
aws_secret_access_key='more',
- host='s3.cn-north-1.amazonaws.com.cn'
+ host=host_value
+ )
+ self.assertEqual(
+ conn._required_auth_capability(),
+ ['hmac-v4-s3']
+ )
+ self.assertEqual(
+ conn.host,
+ host_value
+ )
+
+ # Ensure that the host is populated from our config if one is not
+ # provided when creating a connection.
+ self.config = {
+ 's3': {
+ 'host': host_value,
+ 'use-sigv4': True,
+ }
+ }
+ conn = self.connection_class(
+ aws_access_key_id='less',
+ aws_secret_access_key='more'
)
self.assertEqual(
conn._required_auth_capability(),
@@ -111,7 +136,7 @@ class TestSigV4HostError(MockServiceWithConfigTestCase):
)
self.assertEqual(
conn.host,
- 's3.cn-north-1.amazonaws.com.cn'
+ host_value
)