How to use get_credential_provider method in tempest

Best Python code snippet using tempest_python

tests.py

Source:tests.py Github

copy

Full Screen

...35 with patch('aws.client.Client.get_s3_connection'):36 get_conf.return_value = {}37 client1 = get_client(name='default', fs='s3a')38 client2 = get_client(name='default', fs='s3a', user='test')39 provider = get_credential_provider('default', 'hue')40 assert_equal(provider.get_credentials().get('AccessKeyId'), conf.AWS_ACCOUNTS['default'].ACCESS_KEY_ID.get())41 assert_equal(client1, client2) # Should be the same as no support for user based client with credentials & no Expiration42 finally:43 finish()44 clear_cache()45 conf.clear_cache()46 def test_with_idbroker(self):47 try:48 finish = conf.AWS_ACCOUNTS.set_for_testing({}) # Set empty to test when no configs are set49 with patch('aws.client.conf_idbroker.get_conf') as get_conf:50 with patch('aws.client.Client.get_s3_connection'):51 with patch('aws.client.IDBroker.get_cab') as get_cab:52 with patch('aws.client.aws_conf.has_iam_metadata') as has_iam_metadata:53 get_conf.return_value = {54 'fs.s3a.ext.cab.address': 'address'55 }56 get_cab.return_value = {57 'Credentials': {'AccessKeyId': 'AccessKeyId', 'Expiration': 0}58 }59 has_iam_metadata.return_value = True60 provider = get_credential_provider('default', 'hue')61 assert_equal(provider.get_credentials().get('AccessKeyId'), 'AccessKeyId')62 client1 = get_client(name='default', fs='s3a', user='hue')63 client2 = get_client(name='default', fs='s3a', user='hue')64 assert_not_equal(client1, client2) # Test that with Expiration 0 clients not equal65 get_cab.return_value = {66 'Credentials': {'AccessKeyId': 'AccessKeyId', 'Expiration': int(current_ms_from_utc()) + 10*1000}67 }68 client3 = get_client(name='default', fs='s3a', user='hue')69 client4 = get_client(name='default', fs='s3a', user='hue')70 client5 = get_client(name='default', fs='s3a', user='test')71 assert_equal(client3, client4) # Test that with 10 sec expiration, clients equal72 assert_not_equal(client4, client5) # Test different user have different clients73 finally:74 finish()75 clear_cache()76 conf.clear_cache()77 def test_with_idbroker_and_config(self):78 try:79 finish = conf.AWS_ACCOUNTS.set_for_testing({'default': {'region': 'ap-northeast-1'}})80 with patch('aws.client.conf_idbroker.get_conf') as get_conf:81 with patch('aws.client.Client.get_s3_connection'):82 with patch('aws.client.IDBroker.get_cab') as get_cab:83 with patch('aws.client.aws_conf.has_iam_metadata') as has_iam_metadata:84 get_conf.return_value = {85 'fs.s3a.ext.cab.address': 'address'86 }87 get_cab.return_value = {88 'Credentials': {'AccessKeyId': 'AccessKeyId', 'Expiration': 0}89 }90 has_iam_metadata.return_value = True91 provider = get_credential_provider('default', 'hue')92 assert_equal(provider.get_credentials().get('AccessKeyId'), 'AccessKeyId')93 client = Client.from_config(conf.AWS_ACCOUNTS['default'], get_credential_provider('default', 'hue'))94 assert_equal(client._region, 'ap-northeast-1')95 finally:96 finish()97 clear_cache()98 conf.clear_cache()99 def test_with_idbroker_on_ec2(self):100 try:101 finish = conf.AWS_ACCOUNTS.set_for_testing({}) # Set empty to test when no configs are set102 with patch('aws.client.aws_conf.get_region') as get_region:103 with patch('aws.client.conf_idbroker.get_conf') as get_conf:104 with patch('aws.client.Client.get_s3_connection'):105 with patch('aws.client.IDBroker.get_cab') as get_cab:106 with patch('aws.client.aws_conf.has_iam_metadata') as has_iam_metadata:107 get_region.return_value = 'us-west-1'108 get_conf.return_value = {109 'fs.s3a.ext.cab.address': 'address'110 }111 get_cab.return_value = {112 'Credentials': {'AccessKeyId': 'AccessKeyId', 'Expiration': 0}113 }114 has_iam_metadata.return_value = True115 client = Client.from_config(None, get_credential_provider('default', 'hue'))116 assert_equal(client._region, 'us-west-1') # Test different user have different clients117 finally:118 finish()119 clear_cache()...

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