def test_auth_v2_ks_exception(self): c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0( {}, c.ClientException) self.assertRaises(c.ClientException, c.get_auth, 'http://www.tests.com', 'asdf', 'asdf', os_options={}, auth_version='2.0')
def test_auth_v2_with_tenant_user_in_user_no_os_options(self): 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") self.assertTrue(url.startswith("http")) self.assertTrue(token)
def test_auth_v2_insecure(self): os_options = {'tenant_name': 'foo'} c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0( os_options, None) 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', os_options=os_options, auth_version='2.0') self.assertTrue(url.startswith("http")) self.assertTrue(token) url, token = c.get_auth(auth_url_insecure, 'asdf', 'asdf', os_options=os_options, auth_version='2.0', insecure=True) self.assertTrue(url.startswith("http")) self.assertTrue(token) self.assertRaises(c.ClientException, c.get_auth, auth_url_insecure, 'asdf', 'asdf', os_options=os_options, auth_version='2.0') self.assertRaises(c.ClientException, c.get_auth, auth_url_insecure, 'asdf', 'asdf', os_options=os_options, auth_version='2.0', insecure=False)
def test_auth_v2(self): 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, auth_version="2.0") self.assertTrue(url.startswith("http")) self.assertTrue(token)
def test_auth_v2_tenant_name_no_os_options(self): tenant_option = {"tenant_name": "asdf"} c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0(tenant_option) url, token = c.get_auth( "http://www.test.com", "asdf", "asdf", tenant_name="asdf", os_options={}, auth_version="2.0" ) self.assertTrue(url.startswith("http")) self.assertTrue(token)
def test_auth_v2_no_endpoint(self): os_options = {'region_name': 'unknown_region', 'tenant_name': 'asdf'} c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0( 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_no_tenant_name(self): c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0({}) self.assertRaises(c.ClientException, c.get_auth, 'http://www.tests.com', 'asdf', 'asdf', os_options={}, auth_version='2.0')
def test_auth_v2_with_os_options(self): 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, 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'} 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, auth_version="2.0") self.assertTrue(url.startswith("http")) self.assertTrue(token)
def test_auth_v2_no_endpoint(self): os_options = {"region_name": "unknown_region", "tenant_name": "asdf"} c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0(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_with_os_options(self): 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, auth_version="2.0") self.assertTrue(url.startswith("http")) self.assertTrue(token)
def test_auth_v2_cacert(self): os_options = {'tenant_name': 'foo'} c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0( os_options, None) 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', os_options=os_options, auth_version='2.0', insecure=False) self.assertTrue(url.startswith("http")) self.assertTrue(token) url, token = c.get_auth(auth_url_insecure, 'asdf', 'asdf', os_options=os_options, auth_version='2.0', cacert='ca.pem', insecure=False) self.assertTrue(url.startswith("http")) self.assertTrue(token) self.assertRaises(c.ClientException, c.get_auth, auth_url_insecure, 'asdf', 'asdf', os_options=os_options, auth_version='2.0') self.assertRaises(c.ClientException, c.get_auth, auth_url_insecure, 'asdf', 'asdf', os_options=os_options, auth_version='2.0', insecure=False)
def test_auth_v2_with_os_options(self): 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, auth_version="2.0") self.assertTrue(url.startswith("http")) self.assertTrue(token)
def test_auth_v2_no_tenant_name(self): c.get_keystoneclient_2_0 = fake_get_keystoneclient_2_0({}) self.assertRaises( c.ClientException, c.get_auth, "http://www.tests.com", "asdf", "asdf", os_options={}, auth_version="2.0" )
def test_auth_v2_with_os_region_name(self): 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, auth_version="2.0") self.assertTrue(url.startswith("http")) self.assertTrue(token)