How to use get_access_key_last_used method in localstack

Best Python code snippet using localstack_python

aws-user-analyzer_v2.py

Source: aws-user-analyzer_v2.py Github

copy

Full Screen

...58 """59 get_access_key_last_used60 https:/​/​boto3.amazonaws.com/​v1/​documentation/​api/​latest/​reference/​services/​iam.html#IAM.Client.get_access_key_last_used61 """62 r = IAMc.get_access_key_last_used(AccessKeyId=k)63 # R["get_access_key_last_used"][u["UserName"]] = r64 # USERS[u["UserName"]]["access_keys"][state][k].update(r["AccessKeyLastUsed"])65 return r66def ORGANIZE_ACCESS_KEYS(K):67 """68 Concise organization for user keys69 """70 if K:71 DATA = {"active":{}, "inactive":{}}72 for k in K:73 if k["Status"] == "Active":74 DATA["active"].update({k["AccessKeyId"]: {"CreateDate":k["CreateDate"]}})75 elif k["Status"] == "Inactive":76 DATA["inactive"].update({k["AccessKeyId"]: {"CreateDate":k["CreateDate"]}})...

Full Screen

Full Screen

test_aws_iam_client_for_audit_access_keys.py

Source: test_aws_iam_client_for_audit_access_keys.py Github

copy

Full Screen

...71 assert len(caplog.records) == 172 assert caplog.records[0].levelname == "WARNING"73 assert "unable to list access keys" in caplog.text74 assert "boom" in caplog.text75def test_get_access_key_last_used() -> None:76 last_used = datetime.now()77 mock_boto_iam = Mock(get_access_key_last_used=Mock(return_value={"AccessKeyLastUsed": {"LastUsedDate": last_used}}))78 key_id = "keyId"79 key = AccessKey(user_name="user", id=key_id, created=datetime.now())80 assert last_used == AwsIamAuditClient(mock_boto_iam).get_access_key_last_used(key)81 mock_boto_iam.get_access_key_last_used.assert_called_with(AccessKeyId=key_id)82def test_get_access_key_last_used_none() -> None:83 mock_boto_iam = Mock(get_access_key_last_used=Mock(return_value={"AccessKeyLastUsed": {}}))84 key = AccessKey(user_name="user", id="keyId", created=datetime.now())85 assert AwsIamAuditClient(mock_boto_iam).get_access_key_last_used(key) is None86def test_get_access_key_last_used_exception_returns_none(caplog: Any) -> None:87 mock_boto_iam = Mock(88 get_access_key_last_used=Mock(side_effect=client_error("GetAccessKeyLastUsed", "bad stuff", "error"))89 )90 key = AccessKey(user_name="user", id="keyId", created=datetime.now())91 with caplog.at_level(logging.INFO):92 assert AwsIamAuditClient(mock_boto_iam).get_access_key_last_used(key) is None93 assert len(caplog.records) == 194 assert caplog.records[0].levelname == "WARNING"95 assert "unable to get access key last used for key: keyId" in caplog.text...

Full Screen

Full Screen

EnsureSingleAccessKeyPerUser.py

Source: EnsureSingleAccessKeyPerUser.py Github

copy

Full Screen

...15 return True #Here as a default case, code should never reach this point16#Disables the access key not used most recently.17def disable_key(keys, username, client):18 #Covers null last used date19 if 'LastUsedDate' in client.get_access_key_last_used(AccessKeyId=keys[0]['AccessKeyId'])['AccessKeyLastUsed']:20 time0 = client.get_access_key_last_used(AccessKeyId=keys[0]['AccessKeyId'])['AccessKeyLastUsed']['LastUsedDate']21 else:22 time0 = 023 if 'LastUsedDate' in client.get_access_key_last_used(AccessKeyId=keys[1]['AccessKeyId'])['AccessKeyLastUsed']:24 time1 = client.get_access_key_last_used(AccessKeyId=keys[1]['AccessKeyId'])['AccessKeyLastUsed']['LastUsedDate']25 else:26 time1 = 027 #Compares last used dates and disables keys28 if compare_times(time0, time1):29 client.update_access_key(AccessKeyId=keys[1]['AccessKeyId'], UserName=username, Status='Inactive')30 else:31 client.update_access_key(AccessKeyId=keys[0]['AccessKeyId'], UserName=username, Status='Inactive')32#Determines if multiple access keys are active for a single user33def multiple_active_keys(user_keys, name, client):34 if len(user_keys) < 2:35 return False36 count = 037 for key in user_keys:38 if key['Status'] == 'Active':...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

13 Best Java Testing Frameworks For 2023

The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.

QA Innovation &#8211; Using the senseshaping concept to discover customer needs

QA Innovation - Using the senseshaping concept to discover customer needsQA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.

Best 23 Web Design Trends To Follow In 2023

Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.

Acquiring Employee Support for Change Management Implementation

Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.

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