Best Python code snippet using tempest_python
test_application_credentials.py
Source:test_application_credentials.py
...17from oslo_utils import timeutils18from tempest.api.identity import base19from tempest.lib import decorators20class ApplicationCredentialsV3Test(base.BaseApplicationCredentialsV3Test):21 def _list_app_creds(self, name=None):22 kwargs = dict(user_id=self.user_id)23 if name:24 kwargs.update(name=name)25 return self.non_admin_app_creds_client.list_application_credentials(26 **kwargs)['application_credentials']27 @decorators.idempotent_id('8080c75c-eddc-4786-941a-c2da7039ae61')28 def test_create_application_credential(self):29 app_cred = self.create_application_credential()30 # Check that the secret appears in the create response31 secret = app_cred['secret']32 # Check that the secret is not retrievable after initial create33 app_cred = self.non_admin_app_creds_client.show_application_credential(34 user_id=self.user_id,35 application_credential_id=app_cred['id']36 )['application_credential']37 self.assertNotIn('secret', app_cred)38 # Check that the application credential is functional39 token_id, resp = self.non_admin_token.get_token(40 app_cred_id=app_cred['id'],41 app_cred_secret=secret,42 auth_data=True43 )44 self.assertEqual(resp['project']['id'], self.project_id)45 @decorators.idempotent_id('852daf0c-42b5-4239-8466-d193d0543ed3')46 def test_create_application_credential_expires(self):47 expires_at = timeutils.utcnow() + datetime.timedelta(hours=1)48 app_cred = self.create_application_credential(expires_at=expires_at)49 expires_str = expires_at.isoformat()50 self.assertEqual(expires_str, app_cred['expires_at'])51 @decorators.idempotent_id('ff0cd457-6224-46e7-b79e-0ada4964a8a6')52 def test_list_application_credentials(self):53 self.create_application_credential()54 self.create_application_credential()55 app_creds = self._list_app_creds()56 self.assertEqual(2, len(app_creds))57 @decorators.idempotent_id('9bb5e5cc-5250-493a-8869-8b665f6aa5f6')58 def test_query_application_credentials(self):59 self.create_application_credential()60 app_cred_two = self.create_application_credential()61 app_cred_two_name = app_cred_two['name']62 app_creds = self._list_app_creds(name=app_cred_two_name)63 self.assertEqual(1, len(app_creds))...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!