diff options
-rwxr-xr-x | bin/swift | 17 | ||||
-rw-r--r-- | tests/test_swiftclient.py | 54 | ||||
-rw-r--r-- | tests/utils.py | 3 | ||||
-rw-r--r-- | tox.ini | 2 |
4 files changed, 41 insertions, 35 deletions
@@ -1166,8 +1166,15 @@ Commands: %(st_download_help)s %(st_delete_help)s -Example: +Examples: %%prog -A https://auth.api.rackspacecloud.com/v1.0 -U user -K key stat + + %%prog --os-auth-url https://api.example.com/v2.0 --os-tenant-name tenant \\ + --os-usernameuser --os-password password list + + %%prog --os-auth-token 6ee5eb33efad4e45ab46806eac010566 \\ + --os-storage-url https://10.1.5.2:8080/v1/AUTH_ced809b6a4baea7aeab61a \\ + list '''.strip('\n') % globals()) parser.add_option('-s', '--snet', action='store_true', dest='snet', default=False, help='Use SERVICENET internal network') @@ -1228,14 +1235,18 @@ Example: parser.add_option('--os-auth-token', metavar='<auth-token>', default=environ.get('OS_AUTH_TOKEN'), - help='Openstack token. Defaults to env[OS_AUTH_TOKEN]') + help='Openstack token. Defaults to env[OS_AUTH_TOKEN]. ' + 'Used with --os-storage-url to bypass the ' + 'usual username/password authentication.') parser.add_option('--os_auth_token', help=SUPPRESS_HELP) parser.add_option('--os-storage-url', metavar='<storage-url>', default=environ.get('OS_STORAGE_URL'), help='Openstack storage URL. ' - 'Defaults to env[OS_STORAGE_URL]') + 'Defaults to env[OS_STORAGE_URL]. ' + 'Used with --os-auth-token to bypass the ' + 'usual username/password authentication.') parser.add_option('--os_storage_url', help=SUPPRESS_HELP) parser.add_option('--os-region-name', diff --git a/tests/test_swiftclient.py b/tests/test_swiftclient.py index 3a22515..5fd1e28 100644 --- a/tests/test_swiftclient.py +++ b/tests/test_swiftclient.py @@ -47,7 +47,7 @@ class TestClientException(testtools.TestCase): ) for value in test_kwargs: kwargs = { - 'http_%s' % value: value, + 'http_%s' % value: value, } exc = c.ClientException('test', **kwargs) self.assertTrue(value in str(exc)) @@ -71,7 +71,6 @@ class TestJsonImport(testtools.TestCase): reload(simplejson) super(TestJsonImport, self).tearDown() - def test_any(self): self.assertTrue(hasattr(c, 'json_loads')) @@ -119,7 +118,6 @@ class MockHttpTest(testtools.TestCase): def setUp(self): super(MockHttpTest, self).setUp() - def fake_http_connection(*args, **kwargs): _orig_http_connection = c.http_connection return_read = kwargs.get('return_read') @@ -213,7 +211,7 @@ class TestGetAuth(MockHttpTest): self.assertEquals(token, None) def test_auth_v2(self): - os_options={'tenant_name': 'asdf'} + os_options = {'tenant_name': 'asdf'} c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0(os_options) url, token = c.get_auth('http://www.test.com', 'asdf', 'asdf', os_options=os_options, @@ -248,9 +246,9 @@ class TestGetAuth(MockHttpTest): self.assertTrue(token) def test_auth_v2_with_os_options(self): - os_options={'service_type': 'object-store', - 'endpoint_type': 'internalURL', - 'tenant_name': 'asdf'} + os_options = {'service_type': 'object-store', + 'endpoint_type': 'internalURL', + 'tenant_name': 'asdf'} c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0(os_options) url, token = c.get_auth('http://www.test.com', 'asdf', 'asdf', os_options=os_options, @@ -262,13 +260,13 @@ class TestGetAuth(MockHttpTest): tenant_option = {'tenant_name': 'foo'} c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0(tenant_option) url, token = c.get_auth('http://www.test.com', 'foo:bar', 'asdf', - auth_version="2.0") + auth_version="2.0") self.assertTrue(url.startswith("http")) self.assertTrue(token) def test_auth_v2_with_os_region_name(self): - os_options={'region_name': 'good-region', - 'tenant_name': 'asdf'} + os_options = {'region_name': 'good-region', + 'tenant_name': 'asdf'} c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0(os_options) url, token = c.get_auth('http://www.test.com', 'asdf', 'asdf', os_options=os_options, @@ -277,19 +275,17 @@ class TestGetAuth(MockHttpTest): self.assertTrue(token) def test_auth_v2_no_endpoint(self): - os_options={'region_name': 'unknown_region', - 'tenant_name': 'asdf'} + os_options = {'region_name': 'unknown_region', + 'tenant_name': 'asdf'} c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0( - os_options, - c.ClientException) + os_options, c.ClientException) self.assertRaises(c.ClientException, c.get_auth, 'http://www.tests.com', 'asdf', 'asdf', os_options=os_options, auth_version='2.0') def test_auth_v2_ks_exception(self): c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0( - {}, - c.ClientException) + {}, c.ClientException) self.assertRaises(c.ClientException, c.get_auth, 'http://www.tests.com', 'asdf', 'asdf', os_options={}, @@ -298,10 +294,9 @@ class TestGetAuth(MockHttpTest): def test_auth_v2_cacert(self): os_options = {'tenant_name': 'foo'} c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0( - os_options, - None) + os_options, None) - auth_url_secure = 'https://www.tests.com' + auth_url_secure = 'https://www.tests.com' auth_url_insecure = 'https://www.tests.com/self-signed-certificate' url, token = c.get_auth(auth_url_secure, 'asdf', 'asdf', @@ -327,10 +322,9 @@ class TestGetAuth(MockHttpTest): def test_auth_v2_insecure(self): os_options = {'tenant_name': 'foo'} c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0( - os_options, - None) + os_options, None) - auth_url_secure = 'https://www.tests.com' + auth_url_secure = 'https://www.tests.com' auth_url_insecure = 'https://www.tests.com/invalid-certificate' url, token = c.get_auth(auth_url_secure, 'asdf', 'asdf', @@ -397,8 +391,8 @@ class TestHeadContainer(MockHttpTest): body = 'c' * 60 c.http_connection = self.fake_http_connection(500, body=body) self.assertRaises(c.ClientException, c.head_container, - 'http://www.test.com', 'asdf', 'asdf', - ) + 'http://www.test.com', 'asdf', 'asdf', + ) try: value = c.head_container('http://www.test.com', 'asdf', 'asdf') except c.ClientException as e: @@ -416,8 +410,8 @@ class TestPutContainer(MockHttpTest): body = 'c' * 60 c.http_connection = self.fake_http_connection(500, body=body) self.assertRaises(c.ClientException, c.put_container, - 'http://www.test.com', 'asdf', 'asdf', - ) + 'http://www.test.com', 'asdf', 'asdf', + ) try: value = c.put_container('http://www.test.com', 'asdf', 'asdf') except c.ClientException as e: @@ -480,7 +474,7 @@ class TestPutObject(MockHttpTest): self.assertTrue(isinstance(value, basestring)) # Test for RFC-2616 encoded symbols self.assertTrue("a-b: .x:yz mn:fg:lp" in resp.buffer[0], - "[a-b: .x:yz mn:fg:lp] header is missing") + "[a-b: .x:yz mn:fg:lp] header is missing") def test_chunk_warning(self): conn = c.http_connection('http://www.test.com/') @@ -540,7 +534,7 @@ class TestPostObject(MockHttpTest): c.post_object(*args, headers=headers, http_conn=conn) # Test for RFC-2616 encoded symbols self.assertTrue("a-b: .x:yz mn:kl:qr" in resp.buffer[0], - "[a-b: .x:yz mn:kl:qr] header is missing") + "[a-b: .x:yz mn:kl:qr] header is missing") def test_server_error(self): body = 'c' * 60 @@ -650,7 +644,7 @@ class TestConnection(MockHttpTest): conn = c.Connection('http://www.test.com', 'asdf', 'asdf', preauthurl='http://www.old.com', preauthtoken='old', - ) + ) self.assertEquals(conn.attempts, 0) self.assertEquals(conn.url, 'http://www.old.com') @@ -756,7 +750,7 @@ class TestConnection(MockHttpTest): exc = err self.assertEquals(contents.seeks, []) self.assertEquals(str(exc), "put_object('c', 'o', ...) failure " - "and no ability to reset contents for reupload.") + "and no ability to reset contents for reupload.") finally: c.http_connection = orig_conn diff --git a/tests/utils.py b/tests/utils.py index 414920e..4da8f3a 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -16,6 +16,7 @@ from httplib import HTTPException from eventlet import Timeout, sleep + def fake_get_keystoneclient_2_0(os_options, exc=None, **kwargs): def fake_get_keystoneclient_2_0(auth_url, user, @@ -78,7 +79,7 @@ def fake_http_connect(*code_iter, **kwargs): 'last-modified': self.timestamp, 'x-object-meta-test': 'testing', 'etag': - self.etag or '"68b329da9893e34099c7d8ad5cb9c940"', + self.etag or '"68b329da9893e34099c7d8ad5cb9c940"', 'x-works': 'yes', 'x-account-container-count': 12345} if not self.timestamp: @@ -13,7 +13,7 @@ commands = python setup.py testr --testr-args="{posargs}" [testenv:pep8] deps = pep8 -commands = pep8 --repeat --show-source --exclude=openstack swiftclient setup.py +commands = pep8 --repeat --show-source --exclude=openstack swiftclient setup.py tests [testenv:venv] commands = {posargs} |