How to use get_context_keys_for_principal_policy method in localstack

Best Python code snippet using localstack_python

client.py

Source:client.py Github

copy

Full Screen

...121 def get_account_summary(self) -> Dict:122 pass123 def get_context_keys_for_custom_policy(self, PolicyInputList: List) -> Dict:124 pass125 def get_context_keys_for_principal_policy(self, PolicySourceArn: str, PolicyInputList: List = None) -> Dict:126 pass127 def get_credential_report(self) -> Dict:128 pass129 def get_group(self, GroupName: str, Marker: str = None, MaxItems: int = None) -> Dict:130 pass131 def get_group_policy(self, GroupName: str, PolicyName: str) -> Dict:132 pass133 def get_instance_profile(self, InstanceProfileName: str) -> Dict:134 pass135 def get_login_profile(self, UserName: str) -> Dict:136 pass137 def get_open_id_connect_provider(self, OpenIDConnectProviderArn: str) -> Dict:138 pass139 def get_paginator(self, operation_name: str = None) -> Paginator:...

Full Screen

Full Screen

util.py

Source:util.py Github

copy

Full Screen

...139 return result140# For testing actions that require iam:PassRole permission, handles141# the iam:PassedToService context entry142def testPassRole(iamclient, passer, passed, targetservice):143 context_response = iamclient.get_context_keys_for_principal_policy(PolicySourceArn=passer.label)144 context_entries = []145 if 'iam:PassedToService' in context_response['ContextKeyNames']:146 context_entries.append({147 'ContextKeyName': 'iam:PassedToService',148 'ContextKeyValues': [targetservice],149 'ContextKeyType': 'string'150 })151 response = iamclient.simulate_principal_policy(152 PolicySourceArn=passer.label,153 ActionNames=['iam:PassRole'],154 ResourceArns=[passed.label],155 ContextEntries=context_entries156 )157 if 'EvaluationResults' in response and 'EvalDecision' in response['EvaluationResults'][0]:158 return response['EvaluationResults'][0]['EvalDecision'] == 'allowed'159# Generic test action, also accepts ResourceArns160def testAction(client, PolicySourceArn, ActionName, ResourceArn=None, ResourcePolicy=None):161 context_response = client.get_context_keys_for_principal_policy(PolicySourceArn=PolicySourceArn)162 context_entries = []163 username_key_used = False164 for key in context_response['ContextKeyNames']:165 # TODO: deal with more context keys166 if key == 'aws:username' and not username_key_used:167 tokens = PolicySourceArn.split('/')168 context_entries.append({169 'ContextKeyName': key,170 'ContextKeyValues': [tokens[len(tokens) - 1]],171 'ContextKeyType': 'string'172 })173 username_key_used = True174 # TODO: Better patch for duplicate context keys175 if ResourceArn is not None:...

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