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 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)
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)
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)
def change_password(username, password): userservice = service.get('users') result = userservice.changePassword(username, password) return result == 'success'