diff options
author | Dan Prince <dprince@redhat.com> | 2012-06-06 18:38:08 +0200 |
---|---|---|
committer | Chmouel Boudjnah <chmouel@chmouel.com> | 2012-06-06 19:07:08 +0200 |
commit | b13823ef1847131399d69789738e0fe2aaac1ac6 (patch) | |
tree | 0a2da873af37692cf8fe7bd12727538b66f99884 | |
parent | 7bbb5c72cad5148c0b0231f659aa9220e1987ea0 (diff) | |
download | python-swiftclient-b13823ef1847131399d69789738e0fe2aaac1ac6.tar.gz |
Raise ClientException for invalid auth version.
- Fixes LP Bug #1008667.
- Fix a pep8 error along the way to pass jenkins.
- Update openstack.swift.common to get jenkins passing for 1.2 pep8
error.
Change-Id: I4ce86a94e1c799807a2ad8e7e1c502b1eb8a51c7
-rw-r--r-- | swiftclient/client.py | 5 | ||||
-rw-r--r-- | swiftclient/openstack/common/setup.py | 25 | ||||
-rw-r--r-- | tests/test_swiftclient.py | 6 |
3 files changed, 31 insertions, 5 deletions
diff --git a/swiftclient/client.py b/swiftclient/client.py index bf0bd32..5993628 100644 --- a/swiftclient/client.py +++ b/swiftclient/client.py @@ -245,7 +245,7 @@ def _get_auth_v2_0(url, user, tenant_name, key, snet): url = service['endpoints'][0]['publicURL'] token_id = body['access']['token']['id'] if not url: - raise ClientException("There is no object-store endpoint " \ + raise ClientException("There is no object-store endpoint " "on this auth server.") except(KeyError, IndexError): raise ClientException("Error while getting answers from auth server") @@ -285,6 +285,9 @@ def get_auth(url, user, key, snet=False, tenant_name=None, auth_version="1.0"): if not tenant_name: raise ClientException('No tenant specified') return _get_auth_v2_0(url, user, tenant_name, key, snet) + else: + raise ClientException('Unknown auth_version %s specified.' % + auth_version) def get_account(url, token, marker=None, limit=None, prefix=None, diff --git a/swiftclient/openstack/common/setup.py b/swiftclient/openstack/common/setup.py index 4017890..79b5a62 100644 --- a/swiftclient/openstack/common/setup.py +++ b/swiftclient/openstack/common/setup.py @@ -33,8 +33,8 @@ def parse_mailmap(mailmap='.mailmap'): for l in fp: l = l.strip() if not l.startswith('#') and ' ' in l: - canonical_email, alias = [x for x in l.split(' ') \ - if x.startswith('<')] + canonical_email, alias = [x for x in l.split(' ') + if x.startswith('<')] mapping[alias] = canonical_email return mapping @@ -61,9 +61,19 @@ def parse_requirements(requirements_files=['requirements.txt', 'tools/pip-requires']): requirements = [] for line in get_reqs_from_files(requirements_files): + # For the requirements list, we need to inject only the portion + # after egg= so that distutils knows the package it's looking for + # such as: + # -e git://github.com/openstack/nova/master#egg=nova if re.match(r'\s*-e\s+', line): requirements.append(re.sub(r'\s*-e\s+.*#egg=(.*)$', r'\1', line)) + # such as: + # http://github.com/openstack/nova/zipball/master#egg=nova + elif re.match(r'\s*https?:', line): + requirements.append(re.sub(r'\s*https?:.*#egg=(.*)$', r'\1', + line)) + # -f lines are for index locations, and don't get used here elif re.match(r'\s*-f\s+', line): pass else: @@ -75,11 +85,18 @@ def parse_requirements(requirements_files=['requirements.txt', def parse_dependency_links(requirements_files=['requirements.txt', 'tools/pip-requires']): dependency_links = [] + # dependency_links inject alternate locations to find packages listed + # in requirements for line in get_reqs_from_files(requirements_files): + # skip comments and blank lines if re.match(r'(\s*#)|(\s*$)', line): continue + # lines with -e or -f need the whole line, minus the flag if re.match(r'\s*-[ef]\s+', line): dependency_links.append(re.sub(r'\s*-[ef]\s+', '', line)) + # lines that are only urls can go in unmolested + elif re.match(r'\s*https?:', line): + dependency_links.append(line) return dependency_links @@ -137,8 +154,8 @@ def generate_authors(): new_authors = 'AUTHORS' if os.path.isdir('.git'): # don't include jenkins email address in AUTHORS file - git_log_cmd = "git log --format='%aN <%aE>' | sort -u | " \ - "grep -v " + jenkins_email + git_log_cmd = ("git log --format='%aN <%aE>' | sort -u | " + "grep -v " + jenkins_email) changelog = _run_shell_command(git_log_cmd) mailmap = parse_mailmap() with open(new_authors, 'w') as new_authors_fh: diff --git a/tests/test_swiftclient.py b/tests/test_swiftclient.py index bef08c1..bf8adb9 100644 --- a/tests/test_swiftclient.py +++ b/tests/test_swiftclient.py @@ -161,6 +161,12 @@ class TestGetAuth(MockHttpTest): self.assertEquals(url, None) self.assertEquals(token, None) + def test_invalid_auth(self): + c.http_connection = self.fake_http_connection(200) + self.assertRaises(c.ClientException, c.get_auth, + 'http://www.tests.com', 'asdf', 'asdf', + auth_version="foo") + def test_auth_v1(self): c.http_connection = self.fake_http_connection(200) url, token = c.get_auth('http://www.test.com', 'asdf', 'asdf', |