Merge "Raise IdentityError if auth_url doesn't exist"
This commit is contained in:
commit
ef27fd2d10
@ -28,6 +28,9 @@ class TokenClient(rest_client.RestClient):
|
|||||||
None, None, None, disable_ssl_certificate_validation=dscv,
|
None, None, None, disable_ssl_certificate_validation=dscv,
|
||||||
ca_certs=ca_certs, trace_requests=trace_requests)
|
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.
|
# Normalize URI to ensure /tokens is in it.
|
||||||
if 'tokens' not in auth_url:
|
if 'tokens' not in auth_url:
|
||||||
auth_url = auth_url.rstrip('/') + '/tokens'
|
auth_url = auth_url.rstrip('/') + '/tokens'
|
||||||
|
@ -28,6 +28,9 @@ class V3TokenClient(rest_client.RestClient):
|
|||||||
None, None, None, disable_ssl_certificate_validation=dscv,
|
None, None, None, disable_ssl_certificate_validation=dscv,
|
||||||
ca_certs=ca_certs, trace_requests=trace_requests)
|
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:
|
if 'auth/tokens' not in auth_url:
|
||||||
auth_url = auth_url.rstrip('/') + '/auth/tokens'
|
auth_url = auth_url.rstrip('/') + '/auth/tokens'
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ import httplib2
|
|||||||
from oslotest import mockpatch
|
from oslotest import mockpatch
|
||||||
|
|
||||||
from tempest_lib.common import rest_client
|
from tempest_lib.common import rest_client
|
||||||
|
from tempest_lib import exceptions
|
||||||
from tempest_lib.services.identity.v2 import token_client
|
from tempest_lib.services.identity.v2 import token_client
|
||||||
from tempest_lib.tests import base
|
from tempest_lib.tests import base
|
||||||
from tempest_lib.tests import fake_http
|
from tempest_lib.tests import fake_http
|
||||||
@ -29,6 +30,10 @@ class TestTokenClientV2(base.TestCase):
|
|||||||
super(TestTokenClientV2, self).setUp()
|
super(TestTokenClientV2, self).setUp()
|
||||||
self.fake_200_http = fake_http.fake_httplib2(return_type=200)
|
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):
|
def test_auth(self):
|
||||||
token_client_v2 = token_client.TokenClient('fake_url')
|
token_client_v2 = token_client.TokenClient('fake_url')
|
||||||
post_mock = self.useFixture(mockpatch.PatchObject(
|
post_mock = self.useFixture(mockpatch.PatchObject(
|
||||||
|
@ -18,6 +18,7 @@ import httplib2
|
|||||||
from oslotest import mockpatch
|
from oslotest import mockpatch
|
||||||
|
|
||||||
from tempest_lib.common import rest_client
|
from tempest_lib.common import rest_client
|
||||||
|
from tempest_lib import exceptions
|
||||||
from tempest_lib.services.identity.v3 import token_client
|
from tempest_lib.services.identity.v3 import token_client
|
||||||
from tempest_lib.tests import base
|
from tempest_lib.tests import base
|
||||||
from tempest_lib.tests import fake_http
|
from tempest_lib.tests import fake_http
|
||||||
@ -29,6 +30,10 @@ class TestTokenClientV2(base.TestCase):
|
|||||||
super(TestTokenClientV2, self).setUp()
|
super(TestTokenClientV2, self).setUp()
|
||||||
self.fake_201_http = fake_http.fake_httplib2(return_type=201)
|
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):
|
def test_auth(self):
|
||||||
token_client_v3 = token_client.V3TokenClient('fake_url')
|
token_client_v3 = token_client.V3TokenClient('fake_url')
|
||||||
post_mock = self.useFixture(mockpatch.PatchObject(
|
post_mock = self.useFixture(mockpatch.PatchObject(
|
||||||
|
Loading…
Reference in New Issue
Block a user