Merge "clearer error when authenticate called without auth_url"
This commit is contained in:
@@ -173,6 +173,8 @@ class Client(httpclient.HTTPClient):
|
||||
to a tenant.
|
||||
"""
|
||||
headers = {}
|
||||
if auth_url is None:
|
||||
raise ValueError("Cannot authenticate without a valid auth_url")
|
||||
url = auth_url + "/tokens"
|
||||
if token:
|
||||
headers['X-Auth-Token'] = token
|
||||
|
@@ -170,6 +170,8 @@ class Client(httpclient.HTTPClient):
|
||||
project_id=None, project_name=None, project_domain_id=None,
|
||||
project_domain_name=None, token=None, trust_id=None):
|
||||
headers = {}
|
||||
if auth_url is None:
|
||||
raise ValueError("Cannot authenticate without a valid auth_url")
|
||||
url = auth_url + "/auth/tokens"
|
||||
body = {'auth': {'identity': {}}}
|
||||
ident = body['auth']['identity']
|
||||
|
@@ -3,6 +3,7 @@ import mock
|
||||
|
||||
import requests
|
||||
|
||||
from keystoneclient import exceptions
|
||||
from keystoneclient.v2_0 import client
|
||||
from tests import utils
|
||||
from tests.v2_0 import client_fixtures
|
||||
@@ -90,3 +91,9 @@ class KeystoneClientTest(utils.TestCase):
|
||||
self.assertIsNone(new_client.password)
|
||||
self.assertEqual(new_client.management_url,
|
||||
'http://admin:35357/v2.0')
|
||||
|
||||
def test_init_err_no_auth_url(self):
|
||||
self.assertRaises(exceptions.AuthorizationFailure,
|
||||
client.Client,
|
||||
username='exampleuser',
|
||||
password='password')
|
||||
|
@@ -3,6 +3,7 @@ import mock
|
||||
|
||||
import requests
|
||||
|
||||
from keystoneclient import exceptions
|
||||
from keystoneclient.v3 import client
|
||||
|
||||
from tests import utils
|
||||
@@ -140,3 +141,9 @@ class KeystoneClientTest(utils.TestCase):
|
||||
self.assertEqual(c.auth_ref.trust_id, 'fe0aef')
|
||||
self.assertTrue(c.auth_ref.trust_scoped)
|
||||
self.assertEquals(c.auth_user_id, '0ca8f6')
|
||||
|
||||
def test_init_err_no_auth_url(self):
|
||||
self.assertRaises(exceptions.AuthorizationFailure,
|
||||
client.Client,
|
||||
username='exampleuser',
|
||||
password='password')
|
||||
|
Reference in New Issue
Block a user