Esempio n. 1
0
    def test_init(self):
        authuser1 = UserGroup(user='******', group='admin')
        self.assertIsNotNone(authuser1)
        self.assertEqual("<UserGroup(id='n/a', user='******', group='admin')>", str(authuser1))

        authuser2 = UserGroup(id=1, user='******', group='admin')
        self.assertIsNotNone(authuser2)
        self.assertEqual("<UserGroup(id='1', user='******', group='admin')>", str(authuser2))
Esempio n. 2
0
    def _upload_users(self, yaml_data, verbose=False):
        if 'users' in yaml_data:
            for user_name in yaml_data['users'].keys():

                auth_user = AuthoriseUser(name=user_name)
                result = self.storage_engine.session.add(auth_user)

                yaml_obj = yaml_data['users'][user_name]
                if 'roles' in yaml_obj:
                    roles_list = yaml_obj['roles']
                    splits = roles_list.split(",")
                    for role_name in splits:
                        role_name = role_name.strip()
                        user_role = UserRole(user=user_name, role=role_name)
                        if verbose is True:
                            outputLog(self, user_role)
                        self.storage_engine.session.add(user_role)

                if 'groups' in yaml_obj:
                    groups_list = yaml_obj['groups']
                    splits = groups_list.split(",")
                    for group_name in splits:
                        group_name = group_name.strip()
                        user_group = UserGroup(user=user_name,
                                               group=group_name)
                        if verbose is True:
                            outputLog(self, user_group)
                        self.storage_engine.session.add(user_group)