def _init_via_supernova(env_name): env, auth = auth_client.authenticate(env_name) self.token = auth['access']['token']['id'] # Get NOVA API URL: nova_service_name = env["NOVA_SERVICE_NAME"] catalog = auth['access']['serviceCatalog'] nova_service = None nova_endpoint = None for service in catalog: if service['name'] == nova_service_name: nova_service = service break if not nova_service: raise Exception("No Nova service in catalog") #print nova_service # prune to configured region: region_name = env["NOVA_REGION_NAME"] for endpoint in nova_service['endpoints']: #print endpoint if endpoint['region'] == region_name: nova_endpoint = endpoint break if not nova_endpoint: raise Exception("Can't find correct region %s" % region_name) self.nova_url = nova_endpoint['publicURL'] self.tenant = env["NOVA_PROJECT_ID"]
def test_authenticate_raises_exception_if_message_not_ok(self, post): post.return_value.status_code = 200 post.return_value.text = "OK" self.assertTrue(auth_client.authenticate("yellow", "password"))
def test_authenticate_successful_returns_true(self, post): post.return_value.status_code = 200 post.return_value.text = "OK" self.assertTrue(auth_client.authenticate("yellow", "password"))
def test_authenticate_fails_with_bad_password(self, post): post.return_value.status_code = 400 post.return_value.text = "Bad username or password" with self.assertRaises(auth_client.BadCredentialsException): auth_client.authenticate("yellow", "")
def test_authenticate_bad_domain_raises_exception(self, post): with self.assertRaises(auth_client.BadUrlException): auth_client.authenticate("yellow", "password", "www.google")
def test_authenticate_bad_scheme_raises_exception(self, post): with self.assertRaises(auth_client.BadUrlException): auth_client.authenticate("yellow", "password", "www.google.com") with self.assertRaises(auth_client.BadUrlException): auth_client.authenticate("yellow", "password", "ftp://google.com")