Merge "Raise IdentityError if auth_url doesn't exist"

This commit is contained in:
Jenkins 2016-01-26 14:55:03 +00:00 committed by Gerrit Code Review
commit ef27fd2d10
4 changed files with 16 additions and 0 deletions

View File

@ -28,6 +28,9 @@ class TokenClient(rest_client.RestClient):
None, None, None, disable_ssl_certificate_validation=dscv,
ca_certs=ca_certs, trace_requests=trace_requests)
if auth_url is None:
raise exceptions.IdentityError("Couldn't determine auth_url")
# Normalize URI to ensure /tokens is in it.
if 'tokens' not in auth_url:
auth_url = auth_url.rstrip('/') + '/tokens'

View File

@ -28,6 +28,9 @@ class V3TokenClient(rest_client.RestClient):
None, None, None, disable_ssl_certificate_validation=dscv,
ca_certs=ca_certs, trace_requests=trace_requests)
if auth_url is None:
raise exceptions.IdentityError("Couldn't determine auth_url")
if 'auth/tokens' not in auth_url:
auth_url = auth_url.rstrip('/') + '/auth/tokens'

View File

@ -18,6 +18,7 @@ import httplib2
from oslotest import mockpatch
from tempest_lib.common import rest_client
from tempest_lib import exceptions
from tempest_lib.services.identity.v2 import token_client
from tempest_lib.tests import base
from tempest_lib.tests import fake_http
@ -29,6 +30,10 @@ class TestTokenClientV2(base.TestCase):
super(TestTokenClientV2, self).setUp()
self.fake_200_http = fake_http.fake_httplib2(return_type=200)
def test_init_without_authurl(self):
self.assertRaises(exceptions.IdentityError,
token_client.TokenClient, None)
def test_auth(self):
token_client_v2 = token_client.TokenClient('fake_url')
post_mock = self.useFixture(mockpatch.PatchObject(

View File

@ -18,6 +18,7 @@ import httplib2
from oslotest import mockpatch
from tempest_lib.common import rest_client
from tempest_lib import exceptions
from tempest_lib.services.identity.v3 import token_client
from tempest_lib.tests import base
from tempest_lib.tests import fake_http
@ -29,6 +30,10 @@ class TestTokenClientV2(base.TestCase):
super(TestTokenClientV2, self).setUp()
self.fake_201_http = fake_http.fake_httplib2(return_type=201)
def test_init_without_authurl(self):
self.assertRaises(exceptions.IdentityError,
token_client.V3TokenClient, None)
def test_auth(self):
token_client_v3 = token_client.V3TokenClient('fake_url')
post_mock = self.useFixture(mockpatch.PatchObject(