def test_add_u_to_account(self): user_1 = User(name="1", arn="arn_1") user_2 = User(name="2", arn="arn_2") print(user_2) self.account.users.append(user_1) assert self.account.users[0] == user_1 assert len(self.account.users) == 1 self.account.users.append(user_2) assert len(self.account.users) == 2
def test_trusted_user(self): role = Role(arn=test_role_object['arn'], name=test_role_object['name'], last_used=test_role_object['last_used'], created_at=test_role_object['created_at']) user = User(name="trusted_user", arn="arn_trusted") user2 = User(name="trusted_user2", arn="arn_trusted2") role.trusted_users.append(user) role.trusted_users.append(user2) assert role.trusted_users[0] == user assert role.trusted_users[1] == user2
def setUp(self): self.user = User( arn=test_user_object['arn'], job_uuid=test_user_object['job_uuid'], created_at=test_user_object['created_at'], name=test_user_object['name'], )
def _add_trusted_users(self, trust_policy, role): users = trust_policy.get_trusted_principal_arns('user') role.trusted_users.clear() for user in users: trusted_user = User.find_or_create(user.arn, foreign=True) if trusted_user.foreign: trusted_user.account = Account.find_or_create(user.account_number, foreign=True) trusted_user.job_uuid = self.job_uuid role.trusted_users.append(trusted_user)
def _get_users_from_aws_users(self, aws_users): for aws_user in aws_users: user = User.find_or_create(aws_user["Arn"]) policies = self._get_policies_for_aws_user(aws_user['UserName']) self._fill_user(user, aws_user, policies) yield user
def test_find_or_create(self, mock_db_query): user_new = User(arn='arn') mock_db_query.return_value.filter_by.return_value.first.return_value = user_new user = User.find_or_create("arn") assert user.arn == user_new.arn assert user == user_new