How to use _apply_credentials method in tempest

Best Python code snippet using tempest_python

auth.py

Source: auth.py Github

copy

Full Screen

...465 Additional attributes can still be set afterwards if tests need466 to do so.467 """468 self._initial = kwargs469 self._apply_credentials(kwargs)470 def _apply_credentials(self, attr):471 for key in attr.keys():472 if key in self.ATTRIBUTES:473 setattr(self, key, attr[key])474 else:475 msg = '%s is not a valid attr for %s' % (key, self.__class__)476 raise exceptions.InvalidCredentials(msg)477 def __str__(self):478 """Represent only attributes included in self.ATTRIBUTES"""479 attrs = [attr for attr in self.ATTRIBUTES if attr is not 'password']480 _repr = dict((k, getattr(self, k)) for k in attrs)481 return str(_repr)482 def __eq__(self, other):483 """Credentials are equal if attributes in self.ATTRIBUTES are equal"""484 return str(self) == str(other)485 def __getattr__(self, key):486 # If an attribute is set, __getattr__ is not invoked487 # If an attribute is not set, and it is a known one, return None488 if key in self.ATTRIBUTES:489 return None490 else:491 raise AttributeError492 def __delitem__(self, key):493 # For backwards compatibility, support dict behaviour494 if key in self.ATTRIBUTES:495 delattr(self, key)496 else:497 raise AttributeError498 def get(self, item, default=None):499 # In this patch act as dict for backward compatibility500 try:501 return getattr(self, item)502 except AttributeError:503 return default504 def get_init_attributes(self):505 return self._initial.keys()506 def is_valid(self):507 raise NotImplementedError508 def reset(self):509 # First delete all known attributes510 for key in self.ATTRIBUTES:511 if getattr(self, key) is not None:512 delattr(self, key)513 # Then re-apply initial setup514 self._apply_credentials(self._initial)515class KeystoneV2Credentials(Credentials):516 ATTRIBUTES = ['username', 'password', 'tenant_name', 'user_id',517 'tenant_id']518 def is_valid(self):519 """Check of credentials (no API call)520 Minimum set of valid credentials, are username and password.521 Tenant is optional.522 """523 return None not in (self.username, self.password)524COLLISIONS = [('project_name', 'tenant_name'), ('project_id', 'tenant_id')]525class KeystoneV3Credentials(Credentials):526 """Credentials suitable for the Keystone Identity V3 API"""527 ATTRIBUTES = ['domain_id', 'domain_name', 'password', 'username',528 'project_domain_id', 'project_domain_name', 'project_id',529 'project_name', 'tenant_id', 'tenant_name', 'user_domain_id',530 'user_domain_name', 'user_id']531 def _apply_credentials(self, attr):532 for (key1, key2) in COLLISIONS:533 val1 = attr.get(key1)534 val2 = attr.get(key2)535 if val1 and val2 and val1 != val2:536 msg = ('Cannot have conflicting values for %s and %s' %537 (key1, key2))538 raise exceptions.InvalidCredentials(msg)539 super(KeystoneV3Credentials, self)._apply_credentials(attr)540 def __setattr__(self, key, value):541 parent = super(KeystoneV3Credentials, self)542 # for tenant_* set both project and tenant543 if key == 'tenant_id':544 parent.__setattr__('project_id', value)545 elif key == 'tenant_name':546 parent.__setattr__('project_name', value)547 # for project_* set both project and tenant548 if key == 'project_id':549 parent.__setattr__('tenant_id', value)550 elif key == 'project_name':551 parent.__setattr__('tenant_name', value)552 # for *_domain_* set both user and project if not set yet553 if key == 'user_domain_id':...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Rebuild Confidence in Your Test Automation

These days, development teams depend heavily on feedback from automated tests to evaluate the quality of the system they are working on.

What will come after “agile”?

I think that probably most development teams describe themselves as being “agile” and probably most development teams have standups, and meetings called retrospectives.There is also a lot of discussion about “agile”, much written about “agile”, and there are many presentations about “agile”. A question that is often asked is what comes after “agile”? Many testers work in “agile” teams so this question matters to us.

Test strategy and how to communicate it

I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.

Do you possess the necessary characteristics to adopt an Agile testing mindset?

To understand the agile testing mindset, we first need to determine what makes a team “agile.” To me, an agile team continually focuses on becoming self-organized and cross-functional to be able to complete any challenge they may face during a project.

How To Refresh Page Using Selenium C# [Complete Tutorial]

When working on web automation with Selenium, I encountered scenarios where I needed to refresh pages from time to time. When does this happen? One scenario is that I needed to refresh the page to check that the data I expected to see was still available even after refreshing. Another possibility is to clear form data without going through each input individually.

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