Ejemplo n.º 1
0
    def test_external_nopassword(self):

        userid = 'custom-user'
        password = '******'
        roles = [
            Role.of(name='data_reader', bucket='default'),
            Role.of(name='data_writer', bucket='default')
        ]

        # password with external generates argument error
        self.assertRaises(ArgumentError,
                          self.um.upsert_user,
                          User(username=userid, password=password,
                               roles=roles),
                          domain=AuthDomain.External)
        self.assertRaises(ArgumentError,
                          self.um.upsert_user,
                          User(username=userid, password=password, roles=None),
                          domain=AuthDomain.External)
        self.assertRaises(ArgumentError,
                          self.um.upsert_user,
                          User(username=userid, password=password, roles=[]),
                          domain=AuthDomain.External)
        try:
            self.um.upsert_user(User(username=userid,
                                     password=None,
                                     roles=roles),
                                domain=AuthDomain.External)
        except ArgumentError:
            raise
        except:
            pass
Ejemplo n.º 2
0
    def test_create_list_get_remove_internal_user(self):

        userid = 'custom-user'
        password = '******'
        roles = [
            Role.of(name='data_reader', bucket='default'),
            Role.of(name='data_writer', bucket='default')
        ]

        # add user
        self.um.upsert_user(User(username=userid,
                                 roles=roles,
                                 password=password),
                            domain=AuthDomain.Local)

        # get all users
        users = self.um.get_all_users(AuthDomain.Local)
        self.assertIsNotNone(users)

        # get single user
        user = self.um.get_user(userid, AuthDomain.Local)
        self.assertIsNotNone(user)

        # remove user
        self.um.drop_user(userid, AuthDomain.Local)
Ejemplo n.º 3
0
 def test_groups(self):
     fresh_group = Group(name='qweqwe', roles={Role.of(name='admin')})
     if UG_WORKING:
         self.um.upsert_group(fresh_group)
     result = self.um.get_group('qweqwe')
     admin_role = Role.of(name='admin')
     expected_roles = {admin_role}
     actual_roles = result.roles
     self.assertSetEqual(expected_roles, actual_roles)
    def test_invalid_domain_raises_argument_error(self):

        userid = 'custom-user'
        password = '******'
        roles = [Role.of(name='data_reader', bucket='default'), Role.of(name='data_writer', bucket='default')]

        # invalid domain generates argument error
        self.assertRaises(InvalidArgumentException, self.um.get_all_users, None)
        self.assertRaises(InvalidArgumentException, self.um.get_user, userid, None)
        self.assertRaises(InvalidArgumentException, self.um.upsert_user, User(username=userid, password=password, roles=roles),
                          domain=None)
        self.assertRaises(InvalidArgumentException, self.um.drop_user, userid, None)
    def setUp(self, *args, **kwargs):
        if self.config.mock_enabled:
            raise SkipTest('Real server must be used for admin tests')

        super(UserManagementTests, self).setUp(*args, **kwargs)
        self.um = self.cluster.users()
        if self.supports_groups():
            self.um.upsert_group(Group('qweqwe', roles={Role.of(name='admin')}))