How to use get_configured_admin_credentials method in tempest

Best Python code snippet using tempest_python

credentials_factory.py

Source:credentials_factory.py Github

copy

Full Screen

...55 # In case admin credentials are not available for the account creation,56 # the test should be skipped else it would fail.57 identity_version = identity_version or CONF.identity.auth_version58 if CONF.auth.use_dynamic_credentials or force_tenant_isolation:59 admin_creds = get_configured_admin_credentials(60 fill_in=True, identity_version=identity_version)61 return dynamic_creds.DynamicCredentialProvider(62 name=name,63 network_resources=network_resources,64 identity_version=identity_version,65 admin_creds=admin_creds,66 **_get_dynamic_provider_params())67 else:68 if CONF.auth.test_accounts_file:69 # Most params are not relevant for pre-created accounts70 return preprov_creds.PreProvisionedCredentialProvider(71 name=name, identity_version=identity_version,72 **_get_preprov_provider_params())73 else:74 raise exceptions.InvalidConfiguration(75 'A valid credential provider is needed')76# We want a helper function here to check and see if admin credentials77# are available so we can do a single call from skip_checks if admin78# creds area available.79# This depends on identity_version as there may be admin credentials80# available for v2 but not for v3.81def is_admin_available(identity_version):82 is_admin = True83 # If dynamic credentials is enabled admin will be available84 if CONF.auth.use_dynamic_credentials:85 return is_admin86 # Check whether test accounts file has the admin specified or not87 elif CONF.auth.test_accounts_file:88 check_accounts = preprov_creds.PreProvisionedCredentialProvider(89 identity_version=identity_version, name='check_admin',90 **_get_preprov_provider_params())91 if not check_accounts.admin_available():92 is_admin = False93 else:94 try:95 get_configured_admin_credentials(fill_in=False,96 identity_version=identity_version)97 except exceptions.InvalidConfiguration:98 is_admin = False99 return is_admin100# We want a helper function here to check and see if alt credentials101# are available so we can do a single call from skip_checks if alt102# creds area available.103# This depends on identity_version as there may be alt credentials104# available for v2 but not for v3.105def is_alt_available(identity_version):106 # If dynamic credentials is enabled alt will be available107 if CONF.auth.use_dynamic_credentials:108 return True109 # Check whether test accounts file has the admin specified or not110 if CONF.auth.test_accounts_file:111 check_accounts = preprov_creds.PreProvisionedCredentialProvider(112 identity_version=identity_version, name='check_alt',113 **_get_preprov_provider_params())114 else:115 raise exceptions.InvalidConfiguration(116 'A valid credential provider is needed')117 try:118 if not check_accounts.is_multi_user():119 return False120 else:121 return True122 except exceptions.InvalidConfiguration:123 return False124# === Credentials125# Type of credentials available from configuration126CREDENTIAL_TYPES = {127 'identity_admin': ('auth', 'admin'),128 'user': ('identity', None),129 'alt_user': ('identity', 'alt')130}131DEFAULT_PARAMS = {132 'disable_ssl_certificate_validation':133 CONF.identity.disable_ssl_certificate_validation,134 'ca_certs': CONF.identity.ca_certificates_file,135 'trace_requests': CONF.debug.trace_requests136}137# Read credentials from configuration, builds a Credentials object138# based on the specified or configured version139def get_configured_admin_credentials(fill_in=True, identity_version=None):140 identity_version = identity_version or CONF.identity.auth_version141 if identity_version not in ('v2', 'v3'):142 raise exceptions.InvalidConfiguration(143 'Unsupported auth version: %s' % identity_version)144 conf_attributes = ['username', 'password',145 'project_name']146 if identity_version == 'v3':147 conf_attributes.append('domain_name')148 # Read the parts of credentials from config149 params = DEFAULT_PARAMS.copy()150 for attr in conf_attributes:151 params[attr] = getattr(CONF.auth, 'admin_' + attr)152 # Build and validate credentials. We are reading configured credentials,153 # so validate them even if fill_in is False154 credentials = get_credentials(fill_in=fill_in,155 identity_version=identity_version, **params)156 if not fill_in:157 if not credentials.is_valid():158 msg = ("The admin credentials are incorrectly set in the config "159 "file for identity version %s. Double check that all "160 "required values are assigned.")161 raise exceptions.InvalidConfiguration(msg % identity_version)162 return credentials163# Wrapper around auth.get_credentials to use the configured identity version164# is none is specified165def get_credentials(fill_in=True, identity_version=None, **kwargs):166 params = dict(DEFAULT_PARAMS, **kwargs)167 identity_version = identity_version or CONF.identity.auth_version168 # In case of "v3" add the domain from config if not specified169 if identity_version == 'v3':170 domain_fields = set(x for x in auth.KeystoneV3Credentials.ATTRIBUTES171 if 'domain' in x)172 if not domain_fields.intersection(kwargs.keys()):173 domain_name = CONF.auth.default_credentials_domain_name174 params['user_domain_name'] = domain_name175 auth_url = CONF.identity.uri_v3176 else:177 auth_url = CONF.identity.uri178 return auth.get_credentials(auth_url,179 fill_in=fill_in,180 identity_version=identity_version,181 **params)182# === Credential / client managers183class AdminManager(clients.Manager):184 """Manager that uses admin credentials for its managed client objects"""185 def __init__(self, service=None):186 super(AdminManager, self).__init__(187 credentials=get_configured_admin_credentials(),...

Full Screen

Full Screen

clients.py

Source:clients.py Github

copy

Full Screen

...18 import application_catalog_client19from murano_tempest_tests.services.service_broker import service_broker_client20class Manager(clients.Manager):21 def __init__(self,22 credentials=common_creds.get_configured_admin_credentials(23 'identity_admin'),24 service=None):25 super(Manager, self).__init__(credentials, service)26 self.service_broker_client = service_broker_client.ServiceBrokerClient(27 self.auth_provider)28 self.application_catalog_client = \29 application_catalog_client.ApplicationCatalogClient(30 self.auth_provider)31class AltManager(Manager):32 def __init__(self, service=None):33 super(AltManager, self).__init__(...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful