diff options
author | Jordon Phillips <JordonPhillips@users.noreply.github.com> | 2017-02-15 09:52:04 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-15 09:52:04 -0800 |
commit | 88652d50b938adf737e718ede57440c0378d28c2 (patch) | |
tree | 3f6dfd852d27c38db6d92da0e9b34d062c6b63fa | |
parent | f8222dd104ffea9b17c35601a1ebefdd6d991d0d (diff) | |
parent | 2729048ebd243e03725a3b38e444fa5ad01619cb (diff) | |
download | boto-endpoints-v2.tar.gz |
Merge pull request #3677 from JordonPhillips/fix-s3-integrationendpoints-v2
Fix some s3 integration tests
-rw-r--r-- | tests/integration/s3/test_bucket.py | 11 | ||||
-rw-r--r-- | tests/integration/s3/test_https_cert_validation.py | 40 |
2 files changed, 29 insertions, 22 deletions
diff --git a/tests/integration/s3/test_bucket.py b/tests/integration/s3/test_bucket.py index 8d7fdcce..5bd3e6cc 100644 --- a/tests/integration/s3/test_bucket.py +++ b/tests/integration/s3/test_bucket.py @@ -169,10 +169,11 @@ class S3BucketTest (unittest.TestCase): t.add_tag_set(tag_set) self.bucket.set_tags(t) response = self.bucket.get_tags() - self.assertEqual(response[0][0].key, 'akey') - self.assertEqual(response[0][0].value, 'avalue') - self.assertEqual(response[0][1].key, 'anotherkey') - self.assertEqual(response[0][1].value, 'anothervalue') + tags = sorted(response[0], key=lambda tag: tag.key) + self.assertEqual(tags[0].key, 'akey') + self.assertEqual(tags[0].value, 'avalue') + self.assertEqual(tags[1].key, 'anotherkey') + self.assertEqual(tags[1].value, 'anothervalue') def test_website_configuration(self): response = self.bucket.configure_website('index.html') @@ -214,7 +215,7 @@ class S3BucketTest (unittest.TestCase): self.assertEqual(actual_lifecycle.id, 'myid') self.assertEqual(actual_lifecycle.prefix, '') self.assertEqual(actual_lifecycle.status, 'Enabled') - self.assertEqual(actual_lifecycle.transition, None) + self.assertEqual(actual_lifecycle.transition, []) def test_lifecycle_with_glacier_transition(self): lifecycle = Lifecycle() diff --git a/tests/integration/s3/test_https_cert_validation.py b/tests/integration/s3/test_https_cert_validation.py index d55303c1..2931eeab 100644 --- a/tests/integration/s3/test_https_cert_validation.py +++ b/tests/integration/s3/test_https_cert_validation.py @@ -38,10 +38,12 @@ Note that this test assumes two external dependencies are available: import os import ssl import unittest +import mock from nose.plugins.attrib import attr import boto +from boto.pyami.config import Config from boto import exception, https_connection from boto.gs.connection import GSConnection from boto.s3.connection import S3Connection @@ -66,26 +68,30 @@ INVALID_HOSTNAME_HOST = os.environ.get('INVALID_HOSTNAME_HOST', 'www') @attr('notdefault', 'ssl') class CertValidationTest(unittest.TestCase): def setUp(self): - # Clear config - for section in boto.config.sections(): - boto.config.remove_section(section) + self.config = Config() # Enable https_validate_certificates. - boto.config.add_section('Boto') - boto.config.setbool('Boto', 'https_validate_certificates', True) + self.config.add_section('Boto') + self.config.setbool('Boto', 'https_validate_certificates', True) # Set up bogus credentials so that the auth module is willing to go # ahead and make a request; the request should fail with a service-level # error if it does get to the service (S3 or GS). - boto.config.add_section('Credentials') - boto.config.set('Credentials', 'gs_access_key_id', 'xyz') - boto.config.set('Credentials', 'gs_secret_access_key', 'xyz') - boto.config.set('Credentials', 'aws_access_key_id', 'xyz') - boto.config.set('Credentials', 'aws_secret_access_key', 'xyz') + self.config.add_section('Credentials') + self.config.set('Credentials', 'gs_access_key_id', 'xyz') + self.config.set('Credentials', 'gs_secret_access_key', 'xyz') + self.config.set('Credentials', 'aws_access_key_id', 'xyz') + self.config.set('Credentials', 'aws_secret_access_key', 'xyz') + + self._config_patch = mock.patch('boto.config', self.config) + self._config_patch.start() + + def tearDown(self): + self._config_patch.stop() def enableProxy(self): - boto.config.set('Boto', 'proxy', PROXY_HOST) - boto.config.set('Boto', 'proxy_port', PROXY_PORT) + self.config.set('Boto', 'proxy', PROXY_HOST) + self.config.set('Boto', 'proxy_port', PROXY_PORT) def assertConnectionThrows(self, connection_class, error): conn = connection_class('fake_id', 'fake_secret') @@ -107,7 +113,7 @@ class CertValidationTest(unittest.TestCase): self.do_test_valid_cert() def do_test_invalid_signature(self): - boto.config.set('Boto', 'ca_certificates_file', DEFAULT_CA_CERTS_FILE) + self.config.set('Boto', 'ca_certificates_file', DEFAULT_CA_CERTS_FILE) self.assertConnectionThrows(S3Connection, ssl.SSLError) self.assertConnectionThrows(GSConnection, ssl.SSLError) @@ -119,14 +125,14 @@ class CertValidationTest(unittest.TestCase): self.do_test_invalid_signature() def do_test_invalid_host(self): - boto.config.set('Credentials', 'gs_host', INVALID_HOSTNAME_HOST) - boto.config.set('Credentials', 's3_host', INVALID_HOSTNAME_HOST) + self.config.set('Credentials', 'gs_host', INVALID_HOSTNAME_HOST) + self.config.set('Credentials', 's3_host', INVALID_HOSTNAME_HOST) self.assertConnectionThrows(S3Connection, ssl.SSLError) self.assertConnectionThrows(GSConnection, ssl.SSLError) def do_test_invalid_host(self): - boto.config.set('Credentials', 'gs_host', INVALID_HOSTNAME_HOST) - boto.config.set('Credentials', 's3_host', INVALID_HOSTNAME_HOST) + self.config.set('Credentials', 'gs_host', INVALID_HOSTNAME_HOST) + self.config.set('Credentials', 's3_host', INVALID_HOSTNAME_HOST) self.assertConnectionThrows( S3Connection, https_connection.InvalidCertificateException) self.assertConnectionThrows( |