How to use list_virtual_mfa_devices method in localstack

Best Python code snippet using localstack_python

test_list_virtual_mfa_devices.py

Source:test_list_virtual_mfa_devices.py Github

copy

Full Screen

...33 # mock response API list_virtual_mfa_devices34 with patch.object(client_connect_iam,35 'list_virtual_mfa_devices') as mock_method:36 mock_method.return_value = expected_list_virtual_mfa_devices37 actual_list_virtual_mfa_devices = IAMUtils.list_virtual_mfa_devices(38 trace_id, session, aws_account)39 # check response40 self.assertEqual(41 expected_list_virtual_mfa_devices['VirtualMFADevices'],42 actual_list_virtual_mfa_devices)43 # check connect client44 mock_method_client.assert_any_call(service_name="iam")45 @mock_iam46 def test_list_virtual_mfa_devices_success_response_is_truncate_true(self):47 # connect client48 client_connect_iam = iam_utils.client_connect()49 expected_list_virtual_mfa_devices = copy.deepcopy(50 DataTestIAM.LIST_VIRTUAL_MFA_DEVICES_DATA)51 # mock client52 with patch.object(session, 'client') as mock_method_client:53 mock_method_client.return_value = client_connect_iam54 # mock response API list_virtual_mfa_devices55 with patch.object(client_connect_iam,56 'list_virtual_mfa_devices') as mock_method:57 mock_method.side_effect = iam_utils.side_effect_list_virtual_mfa_devices58 actual_list_virtual_mfa_devices = IAMUtils.list_virtual_mfa_devices(59 trace_id, session, aws_account)60 # check response61 self.assertEqual(expected_list_virtual_mfa_devices,62 actual_list_virtual_mfa_devices)63 # check connect client64 mock_method_client.assert_any_call(service_name="iam")65 def test_list_virtual_mfa_devices_error_connect_iam(self):66 expected_error_response = copy.deepcopy(DataCommon.ERROR_RESPONSE)67 expected_operation_name = copy.deepcopy(DataCommon.OPERATION_NAME)68 # mock error client69 with patch.object(session, 'client') as mock_method:70 mock_method.side_effect = ClientError(71 error_response=expected_error_response,72 operation_name=expected_operation_name)73 with patch.object(74 PmLogAdapter, 'error',75 return_value=None) as mock_method_error:76 with self.assertRaises(PmError) as exception:77 IAMUtils.list_virtual_mfa_devices(trace_id, session,78 aws_account)79 # check error80 actual_cause_error = exception.exception.cause_error81 self.assertEqual(expected_error_response['Error'],82 actual_cause_error.response['Error'])83 self.assertEqual(expected_operation_name,84 actual_cause_error.operation_name)85 # check message log error86 mock_method_error.assert_any_call("[%s] IAMクライアント作成に失敗しました。",87 aws_account)88 def test_list_virtual_mfa_devices_error_call_list_virtual_mfa_devices(self):89 # connect client90 client_connect_iam = iam_utils.client_connect()91 expected_error_response = copy.deepcopy(DataCommon.ERROR_RESPONSE)92 expected_operation_name = copy.deepcopy(DataCommon.OPERATION_NAME)93 # mock client94 with patch.object(session, 'client') as mock_client:95 mock_client.return_value = client_connect_iam96 # mock error call API list_virtual_mfa_devices97 with patch.object(client_connect_iam,98 'list_virtual_mfa_devices') as mock_method:99 mock_method.side_effect = ClientError(100 error_response=expected_error_response,101 operation_name=expected_operation_name)102 with patch.object(103 PmLogAdapter, 'error',104 return_value=None) as mock_method_error:105 with self.assertRaises(PmError) as exception:106 IAMUtils.list_virtual_mfa_devices(107 trace_id, session, aws_account)108 # check error109 actual_cause_error = exception.exception.cause_error110 self.assertEqual(expected_error_response['Error'],111 actual_cause_error.response['Error'])112 self.assertEqual(expected_operation_name,113 actual_cause_error.operation_name)114 # check message log error115 mock_method_error.assert_any_call("[%s]仮想MFAデバイスリストの取得に失敗しました。",...

Full Screen

Full Screen

list_mfa_sno.py

Source:list_mfa_sno.py Github

copy

Full Screen

...22 return users.users23class Getmfa(Resource):24 def put(self,user_name):25 paginator = client.get_paginator('list_virtual_mfa_devices')26 response = client.list_virtual_mfa_devices(AssignmentStatus='Any')27 sno=''28 print '$$$$$$$$$$$$$$$$$$$$$$$$',user_name29 for key, value in response.items():30 if key=='VirtualMFADevices':31 for i in value:32 for k,v in i.items():33 if k=='SerialNumber':34 sno=v35 if k == 'User':36 for u,uv in v.items():37 if u =='UserName' and uv == user_name:38 serial_number=sno39 print serial_number,sno40 return serial_number...

Full Screen

Full Screen

mfa_disassociate.py

Source:mfa_disassociate.py Github

copy

Full Screen

...7 response = client.deactivate_mfa_device(UserName=user_name,SerialNumber=serial_number)8 print "done"9def get_mfa_serial_number(user_name):10 paginator = client.get_paginator('list_virtual_mfa_devices')11 response = client.list_virtual_mfa_devices(AssignmentStatus='Any')12 sno=''13 for key, value in response.items():14 if key=='VirtualMFADevices':15 for i in value:16 for k,v in i.items():17 if k=='SerialNumber':18 sno=v19 if k == 'User':20 for u,uv in v.items():21 if u =='UserName' and uv == user_name:22 serial_number=sno23 return sno...

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 localstack 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