Esempio n. 1
0
def create_user(username, password):
    """ Creates a non-admin user with given username and password """
    non_alnum = re.compile('[^a-z0-9]', re.IGNORECASE)
    if non_alnum.findall(username):
        log.e(_('usernames may only contain letters and digits'))
        return False
    return service.get('users').addUser(username, password, admin=False)
Esempio n. 2
0
def delete_user(username):
    userservice = service.get('users')
    userid = userservice.getIdByName(username)
    if userid is None:
        log.e(_('user with the name "%s" does not exist!'), username)
        return False
    return userservice.deleteUser(userid)
Esempio n. 3
0
def delete_user(username):
    userservice = service.get('users')
    userid = userservice.getIdByName(username)
    if userid is None:
        log.e(_('user with the name "%s" does not exist!'), username)
        return False
    return userservice.deleteUser(userid)
Esempio n. 4
0
def create_user(username, password):
    """ Creates a non-admin user with given username and password """
    non_alnum = re.compile('[^a-z0-9]', re.IGNORECASE)
    if non_alnum.findall(username):
        log.e(_('usernames may only contain letters and digits'))
        return False
    return service.get('users').addUser(username, password, admin=False)
    def test_api_compactlistdir_must_call_cherrymodel_listdir(self):
        mock = MagicMock(spec=CherryModel)
        oldservice = service.get('cherrymodel')
        service.provide('cherrymodel', mock)

        self.http.api_compactlistdir('dir', filterstr='x')
        mock.listdir.assert_called_with('dir', 'x')

        service.provide('cherrymodel', oldservice)
Esempio n. 6
0
    def test_api_compactlistdir_must_call_cherrymodel_listdir(self):
        mock = MagicMock(spec=CherryModel)
        oldservice = service.get('cherrymodel')
        service.provide('cherrymodel', mock)

        self.http.api_compactlistdir('dir', filterstr='x')
        mock.listdir.assert_called_with('dir', 'x')

        service.provide('cherrymodel', oldservice)
Esempio n. 7
0
 def createUser(cls, credentials):
     username, password = credentials
     alphanum = re.compile('[^a-z0-9]', re.IGNORECASE)
     if alphanum.findall(username) or alphanum.findall(password):
         return False
     return service.get('users').addUser(username, password, False)
Esempio n. 8
0
def change_password(username, password):
    userservice = service.get('users')
    result = userservice.changePassword(username, password)
    return result == 'success'
Esempio n. 9
0
def change_password(username, password):
    userservice = service.get('users')
    result = userservice.changePassword(username, password)
    return result == 'success'