Best Python code snippet using localstack_python
iamFunctions.py
Source:iamFunctions.py
...91 Tags=tags92 )93 return response["Policy"]94 except Exception as error: print(error)95def create_saml_provider(name, saml_data, tags=[]):96 try:97 response = client.create_saml_provider(98 SAMLMetadataDocument=saml_data,99 Name=name,100 Tags=tags101 )102 return response103 except Exception as error: print(error)104def create_instance_profile(name, path="/", tags=[]):105 try:106 response = client.create_instance_profile(107 InstanceProfileName=name,108 Path=path,109 Tags=tags110 )111 return response["InstanceProfile"]...
saml_provider_creator.py
Source:saml_provider_creator.py
...6import cfnresponse7iam = boto3.client("iam")8def create_provider(name, doc):9 try:10 resp = iam.create_saml_provider(SAMLMetadataDocument=doc, Name=name)11 return(True, resp['SAMLProviderArn'])12 except Exception as e:13 return (False, f"Cannot create SAML provider: {e}")14def delete_provider(arn):15 try:16 resp = iam.delete_saml_provider(SAMLProviderArn=arn)17 return (True, f"SAML provider with ARN {arn} deleted")18 except ClientError as e:19 if e.response['Error']['Code'] == "NoSuchEntity":20 # no need to delete a thing that doesn't exist21 return (True, f"SAML provider with ARN {arn} does not exist, deletion succeeded")22 else:23 return (False, f"Cannot delete SAML provider with ARN {arn}: {e}")24 except Exception as e:...
test_saml_provider.py
Source:test_saml_provider.py
...12 saml_provider_name = "foo"13 region_name = "us-east-1"14 session = boto3.Session()15 client = session.client("iam")16 saml_provider_resp = client.create_saml_provider(17 Name=saml_provider_name, SAMLMetadataDocument="a" * 102418 )19 saml_provider_arn = saml_provider_resp["SAMLProviderArn"]20 scan_accessor = AWSAccessor(session=session, account_id=account_id, region_name=region_name)21 with patch(22 "altimeter.aws.resource.iam.iam_saml_provider.IAMSAMLProviderResourceSpec.get_saml_provider_metadata_doc"23 ) as mock_get_saml_provider_metadata_doc:24 mock_get_saml_provider_metadata_doc.side_effect = ClientError(25 operation_name="GetSAMLProvider",26 error_response={27 "Error": {28 "Code": "NoSuchEntity",29 "Message": f"GetSAMLProvider operation: Manifest not found for arn {saml_provider_arn}",30 }...
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!!