How to use test_base_url_with_unversioned_endpoint method in tempest

Best Python code snippet using tempest_python

test_auth.py

Source:test_auth.py Github

copy

Full Screen

...309 'skip_path': True310 }311 expected = 'http://fake_url/'312 self._test_base_url_helper(expected, self.filters)313 def test_base_url_with_unversioned_endpoint(self):314 auth_data = {315 'serviceCatalog': [316 {317 'type': 'identity',318 'endpoints': [319 {320 'region': 'FakeRegion',321 'publicURL': 'http://fake_url'322 }323 ]324 }325 ]326 }327 filters = {328 'service': 'identity',329 'endpoint_type': 'publicURL',330 'region': 'FakeRegion',331 'api_version': 'v2.0'332 }333 expected = 'http://fake_url/v2.0'334 self._test_base_url_helper(expected, filters, ('token', auth_data))335 def test_token_not_expired(self):336 expiry_data = datetime.datetime.utcnow() + datetime.timedelta(days=1)337 self._verify_expiry(expiry_data=expiry_data, should_be_expired=False)338 def test_token_expired(self):339 expiry_data = datetime.datetime.utcnow() - datetime.timedelta(hours=1)340 self._verify_expiry(expiry_data=expiry_data, should_be_expired=True)341 def test_token_not_expired_to_be_renewed(self):342 expiry_data = (datetime.datetime.utcnow() +343 self.auth_provider.token_expiry_threshold / 2)344 self._verify_expiry(expiry_data=expiry_data, should_be_expired=True)345 def _verify_expiry(self, expiry_data, should_be_expired):346 for expiry_format in self.auth_provider.EXPIRY_DATE_FORMATS:347 auth_data = self._auth_data_with_expiry(348 expiry_data.strftime(expiry_format))349 self.assertEqual(self.auth_provider.is_expired(auth_data),350 should_be_expired)351class TestKeystoneV3AuthProvider(TestKeystoneV2AuthProvider):352 _endpoints = fake_identity.IDENTITY_V3_RESPONSE['token']['catalog']353 _auth_provider_class = auth.KeystoneV3AuthProvider354 credentials = fake_credentials.FakeKeystoneV3Credentials()355 def setUp(self):356 super(TestKeystoneV3AuthProvider, self).setUp()357 self.stubs.Set(v3_client.V3TokenClient, 'raw_request',358 fake_identity._fake_v3_response)359 def _get_fake_identity(self):360 return fake_identity.IDENTITY_V3_RESPONSE['token']361 def _get_fake_alt_identity(self):362 return fake_identity.ALT_IDENTITY_V3['token']363 def _get_result_url_from_endpoint(self, ep, replacement=None):364 if replacement:365 return ep['url'].replace('v3', replacement)366 return ep['url']367 def _auth_data_with_expiry(self, date_as_string):368 token, access = self.auth_provider.auth_data369 access['expires_at'] = date_as_string370 return token, access371 def _get_from_fake_identity(self, attr):372 token = fake_identity.IDENTITY_V3_RESPONSE['token']373 if attr == 'user_id':374 return token['user']['id']375 elif attr == 'project_id':376 return token['project']['id']377 elif attr == 'user_domain_id':378 return token['user']['domain']['id']379 elif attr == 'project_domain_id':380 return token['project']['domain']['id']381 def test_check_credentials_missing_attribute(self):382 # reset credentials to fresh ones383 self.credentials.reset()384 for attr in ['username', 'password', 'user_domain_name',385 'project_domain_name']:386 cred = copy.copy(self.credentials)387 del cred[attr]388 self.assertFalse(self.auth_provider.check_credentials(cred),389 "Credentials should be invalid without %s" % attr)390 def test_check_domain_credentials_missing_attribute(self):391 # reset credentials to fresh ones392 self.credentials.reset()393 domain_creds = fake_credentials.FakeKeystoneV3DomainCredentials()394 for attr in ['username', 'password', 'user_domain_name']:395 cred = copy.copy(domain_creds)396 del cred[attr]397 self.assertFalse(self.auth_provider.check_credentials(cred),398 "Credentials should be invalid without %s" % attr)399 def test_fill_credentials(self):400 self.auth_provider.fill_credentials()401 creds = self.auth_provider.credentials402 for attr in ['user_id', 'project_id', 'user_domain_id',403 'project_domain_id']:404 self.assertEqual(self._get_from_fake_identity(attr),405 getattr(creds, attr))406 # Overwrites v2 test407 def test_base_url_to_get_admin_endpoint(self):408 self.filters = {409 'service': 'compute',410 'endpoint_type': 'admin',411 'region': 'MiddleEarthRegion'412 }413 expected = self._get_result_url_from_endpoint(414 self._endpoints[0]['endpoints'][2])415 self._test_base_url_helper(expected, self.filters)416 # Overwrites v2 test417 def test_base_url_with_unversioned_endpoint(self):418 auth_data = {419 'catalog': [420 {421 'type': 'identity',422 'endpoints': [423 {424 'region': 'FakeRegion',425 'url': 'http://fake_url',426 'interface': 'public'427 }428 ]429 }430 ]431 }...

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