def test_with_multiple_mechanisms(self): self.stub_auth(json=self.TEST_RESPONSE_DICT) p = v3.PasswordMethod(username=self.TEST_USER, password=self.TEST_PASS) t = v3.TokenMethod(token='foo') a = v3.Auth(self.TEST_URL, [p, t], trust_id='trust') self.assertTrue(a.has_scope_parameters) s = session.Session(auth=a) self.assertEqual({'X-Auth-Token': self.TEST_TOKEN}, s.get_auth_headers()) req = { 'auth': { 'identity': { 'methods': ['password', 'token'], 'password': { 'user': { 'name': self.TEST_USER, 'password': self.TEST_PASS } }, 'token': { 'id': 'foo' } }, 'scope': { 'OS-TRUST:trust': { 'id': 'trust' } } } } self.assertRequestBodyIs(json=req) self.assertEqual(s.auth.auth_ref.auth_token, self.TEST_TOKEN)
def __init__(self, name, password, heat_template, heat_params, os_auth_url, os_username, os_password, os_project_domain_id, os_project_name, os_region_name, os_identity_api_version, **kwargs): # flake8: noqa super(HeatLatentWorker, self).__init__(name, password, **kwargs) self.heat_template = heat_template self.heat_params = heat_params or {} self.stack_id = None if os_identity_api_version == '3': password = v3.PasswordMethod(username=os_username, password=os_password, user_domain_id=os_project_domain_id) auth = v3.Auth(auth_url=os_auth_url, auth_methods=[password]) else: loader = loading.get_plugin_loader('password') auth = loader.load_from_options(auth_url=os_auth_url, username=os_username, password=os_password, project_name=os_project_name) sess = session.Session(auth=auth) self.heat_client = heatclient.client.Client('1', session=sess, region_name=os_region_name)
def auth(self): if 'v2' in self.auth_url: token = v2.Token(token=self.token, auth_url=self.auth_url, tenant_id=self.tenant_id) return token # if 'v3' in self.auth_url: else: token = v3.TokenMethod(token=self.token) return v3.Auth(auth_url=self.auth_url, auth_methods=[token], project_id=self.tenant_id )