How to use list_groups_for_user method in localstack

Best Python code snippet using localstack_python

test_ldap_livetest.py

Source:test_ldap_livetest.py Github

copy

Full Screen

...119 test_users.append(new_user)120 positive_user = test_users[0]121 negative_user = test_users[1]122 for x in range(0, USER_COUNT):123 group_refs = self.identity_api.list_groups_for_user(124 test_users[x]['id'])125 self.assertEqual(0, len(group_refs))126 for x in range(0, GROUP_COUNT):127 new_group = unit.new_group_ref(domain_id=domain['id'])128 new_group = self.identity_api.create_group(new_group)129 test_groups.append(new_group)130 group_refs = self.identity_api.list_groups_for_user(131 positive_user['id'])132 self.assertEqual(x, len(group_refs))133 self.identity_api.add_user_to_group(134 positive_user['id'],135 new_group['id'])136 group_refs = self.identity_api.list_groups_for_user(137 positive_user['id'])138 self.assertEqual(x + 1, len(group_refs))139 group_refs = self.identity_api.list_groups_for_user(140 negative_user['id'])141 self.assertEqual(0, len(group_refs))142 driver = self.identity_api._select_identity_driver(143 CONF.identity.default_domain_id)144 driver.group.ldap_filter = '(dn=xx)'145 group_refs = self.identity_api.list_groups_for_user(146 positive_user['id'])147 self.assertEqual(0, len(group_refs))148 group_refs = self.identity_api.list_groups_for_user(149 negative_user['id'])150 self.assertEqual(0, len(group_refs))151 driver.group.ldap_filter = '(objectclass=*)'152 group_refs = self.identity_api.list_groups_for_user(153 positive_user['id'])154 self.assertEqual(GROUP_COUNT, len(group_refs))155 group_refs = self.identity_api.list_groups_for_user(156 negative_user['id'])157 self.assertEqual(0, len(group_refs))158 def test_user_enable_attribute_mask(self):159 self.config_fixture.config(160 group='ldap',161 user_enabled_emulation=False,162 user_enabled_attribute='employeeType')163 super(LiveLDAPIdentity, self).test_user_enable_attribute_mask()164 def test_create_project_case_sensitivity(self):165 # The attribute used for the live LDAP tests is case insensitive.166 def call_super():167 (super(LiveLDAPIdentity, self).168 test_create_project_case_sensitivity())169 self.assertRaises(exception.Conflict, call_super)...

Full Screen

Full Screen

PolicyHelper.py

Source:PolicyHelper.py Github

copy

Full Screen

...43 :return: The users.44 """45 r = self.iam.list_users()46 return r['Users']47 def list_groups_for_user(self, user_name):48 """49 Get the groups of a user.50 :param user_name: The user name.51 :return: The groups.52 """53 r = self.iam.list_groups_for_user(UserName=user_name)54 groups = r['Groups']55 return groups56 def policy_names_for_group(self, group_name):57 """58 Get the attached policies for a group.59 :param group_name: The group name.60 :return: The policy names.61 """62 r = self.iam.list_attached_group_policies(GroupName=group_name)63 attached_policies = r['AttachedPolicies']64 policy_names = []65 for attached_policy in attached_policies:66 policy_names.append(attached_policy['PolicyName'])67 return policy_names68 def user_has_policy(self, user_name, policy_name):69 """70 Has a given user got a given policy.71 :param user_name: The user name.72 :param policy_name: The policy name.73 :return:74 """75 logger.info('Determining if user %s has policy %s', user_name, policy_name)76 has_policy = False77 groups = self.list_groups_for_user(user_name)78 for group in groups:79 group_name = group['GroupName']80 policy_names = self.policy_names_for_group(group_name)81 for found_policy_name in policy_names:82 if found_policy_name == policy_name:83 has_policy = True...

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