Ejemplo n.º 1
0
 def test_get_hash(self):
     self.stubs.Set(token_client.TokenClientJSON, "raw_request", fake_identity._fake_v2_response)
     test_account_class = accounts.Accounts("v2", "test_name")
     hash_list = self._get_hash_list(self.test_accounts)
     test_cred_dict = self.test_accounts[3]
     test_creds = auth.get_credentials(fake_identity.FAKE_AUTH_URL, **test_cred_dict)
     results = test_account_class.get_hash(test_creds)
     self.assertEqual(hash_list[3], results)
Ejemplo n.º 2
0
 def get_credentials(self, user, project, password):
     # User and project already include both ID and name here,
     # so there's no need to use the fill_in mode
     return auth.get_credentials(
         auth_url=None,
         fill_in=False,
         identity_version='v2',
         username=user['name'], user_id=user['id'],
         tenant_name=project['name'], tenant_id=project['id'],
         password=password)
Ejemplo n.º 3
0
 def test_get_hash(self):
     self.stubs.Set(token_client.TokenClient, 'raw_request',
                    fake_identity._fake_v2_response)
     test_account_class = accounts.Accounts('v2', 'test_name')
     hash_list = self._get_hash_list(self.test_accounts)
     test_cred_dict = self.test_accounts[3]
     test_creds = auth.get_credentials(fake_identity.FAKE_AUTH_URL,
                                       **test_cred_dict)
     results = test_account_class.get_hash(test_creds)
     self.assertEqual(hash_list[3], results)
Ejemplo n.º 4
0
 def get_credentials(self, user, project, password):
     # User and project already include both ID and name here,
     # so there's no need to use the fill_in mode
     return auth.get_credentials(auth_url=None,
                                 fill_in=False,
                                 identity_version='v2',
                                 username=user['name'],
                                 user_id=user['id'],
                                 tenant_name=project['name'],
                                 tenant_id=project['id'],
                                 password=password)
 def test_get_hash(self):
     self.stubs.Set(token_client.TokenClient, 'raw_request',
                    fake_identity._fake_v2_response)
     test_account_class = preprov_creds.PreProvisionedCredentialProvider(
         **self.fixed_params)
     hash_list = self._get_hash_list(self.test_accounts)
     test_cred_dict = self.test_accounts[3]
     test_creds = auth.get_credentials(fake_identity.FAKE_AUTH_URL,
                                       **test_cred_dict)
     results = test_account_class.get_hash(test_creds)
     self.assertEqual(hash_list[3], results)
Ejemplo n.º 6
0
 def test_get_hash(self):
     self.stubs.Set(token_client.TokenClient, 'raw_request',
                    fake_identity._fake_v2_response)
     test_account_class = preprov_creds.PreProvisionedCredentialProvider(
         **self.fixed_params)
     hash_list = self._get_hash_list(self.test_accounts)
     test_cred_dict = self.test_accounts[3]
     test_creds = auth.get_credentials(fake_identity.FAKE_AUTH_URL,
                                       **test_cred_dict)
     results = test_account_class.get_hash(test_creds)
     self.assertEqual(hash_list[3], results)
Ejemplo n.º 7
0
 def get_credentials(self, user, project, password):
     # User, project and domain already include both ID and name here,
     # so there's no need to use the fill_in mode.
     return auth.get_credentials(
         auth_url=None,
         fill_in=False,
         identity_version='v3',
         username=user['name'], user_id=user['id'],
         project_name=project['name'], project_id=project['id'],
         password=password,
         project_domain_id=self.creds_domain['id'],
         project_domain_name=self.creds_domain['name'])
Ejemplo n.º 8
0
 def get_credentials(self, user, project, password):
     # User, project and domain already include both ID and name here,
     # so there's no need to use the fill_in mode.
     return auth.get_credentials(
         auth_url=None,
         fill_in=False,
         identity_version='v3',
         username=user['name'],
         user_id=user['id'],
         project_name=project['name'],
         project_id=project['id'],
         password=password,
         project_domain_id=self.creds_domain['id'],
         project_domain_name=self.creds_domain['name'])
Ejemplo n.º 9
0
def get_credentials(fill_in=True, identity_version=None, **kwargs):
    params = dict(DEFAULT_PARAMS, **kwargs)
    identity_version = identity_version or CONF.identity.auth_version
    # In case of "v3" add the domain from config if not specified
    if identity_version == 'v3':
        domain_fields = set(x for x in auth.KeystoneV3Credentials.ATTRIBUTES
                            if 'domain' in x)
        if not domain_fields.intersection(kwargs.keys()):
            domain_name = CONF.auth.default_credentials_domain_name
            params['user_domain_name'] = domain_name

        auth_url = CONF.identity.uri_v3
    else:
        auth_url = CONF.identity.uri
    return auth.get_credentials(auth_url,
                                fill_in=fill_in,
                                identity_version=identity_version,
                                **params)
Ejemplo n.º 10
0
def get_credentials(fill_in=True, identity_version=None, **kwargs):
    params = dict(DEFAULT_PARAMS, **kwargs)
    identity_version = identity_version or CONF.identity.auth_version
    # In case of "v3" add the domain from config if not specified
    if identity_version == 'v3':
        domain_fields = set(x for x in auth.KeystoneV3Credentials.ATTRIBUTES
                            if 'domain' in x)
        if not domain_fields.intersection(kwargs.keys()):
            # TODO(andreaf) It might be better here to use a dedicated config
            # option such as CONF.auth.tenant_isolation_domain_name
            params['user_domain_name'] = CONF.identity.admin_domain_name
        auth_url = CONF.identity.uri_v3
    else:
        auth_url = CONF.identity.uri
    return auth.get_credentials(auth_url,
                                fill_in=fill_in,
                                identity_version=identity_version,
                                **params)
Ejemplo n.º 11
0
 def _wrap_creds_with_network(self, hash):
     creds_dict = self.hash_dict['creds'][hash]
     # Make sure a domain scope if defined for users in case of V3
     creds_dict = self._extend_credentials(creds_dict)
     # This just builds a Credentials object, it does not validate
     # nor fill  with missing fields.
     credential = auth.get_credentials(
         auth_url=None, fill_in=False,
         identity_version=self.identity_version, **creds_dict)
     net_creds = cred_provider.TestResources(credential)
     net_clients = clients.Manager(credentials=credential)
     compute_network_client = net_clients.compute_networks_client
     net_name = self.hash_dict['networks'].get(hash, None)
     try:
         network = fixed_network.get_network_from_name(
             net_name, compute_network_client)
     except exceptions.InvalidConfiguration:
         network = {}
     net_creds.set_resources(network=network)
     return net_creds
Ejemplo n.º 12
0
 def _wrap_creds_with_network(self, hash):
     creds_dict = self.hash_dict['creds'][hash]
     # Make sure a domain scope if defined for users in case of V3
     creds_dict = self._extend_credentials(creds_dict)
     # This just builds a Credentials object, it does not validate
     # nor fill  with missing fields.
     credential = auth.get_credentials(
         auth_url=None, fill_in=False,
         identity_version=self.identity_version, **creds_dict)
     net_creds = cred_provider.TestResources(credential)
     net_clients = clients.Manager(credentials=credential)
     compute_network_client = net_clients.compute_networks_client
     net_name = self.hash_dict['networks'].get(hash, None)
     try:
         network = fixed_network.get_network_from_name(
             net_name, compute_network_client)
     except exceptions.InvalidTestResource:
         network = {}
     net_creds.set_resources(network=network)
     return net_creds
Ejemplo n.º 13
0
 def _verify_credentials(self, credentials_class, creds_dict, filled=True):
     creds = auth.get_credentials(fake_identity.FAKE_AUTH_URL,
                                  fill_in=filled,
                                  identity_version=self.identity_version,
                                  **creds_dict)
     self._check(creds, credentials_class, filled)
Ejemplo n.º 14
0
 def _verify_credentials(self, credentials_class, creds_dict, filled=True):
     creds = auth.get_credentials(fake_identity.FAKE_AUTH_URL,
                                  fill_in=filled,
                                  identity_version=self.identity_version,
                                  **creds_dict)
     self._check(creds, credentials_class, filled)