def test_authenticate(self): resp = falcon.Response() AuthMiddleware.authenticate(resp) self.assertIsNotNone(resp._cookies) jwt = resp._cookies[AuthMiddleware.cookie_name] self.assertEqual(jwt.key, AuthMiddleware.cookie_name) self.assertEqual(jwt.value, self.auth_token_verified) self.assertEqual(jwt['path'], '/')
def test_authenticate(self): resp = falcon.Response() AuthMiddleware.authenticate(resp) self.assertIsNotNone(resp._cookies) jwt = resp._cookies[AuthMiddleware.cookie_name] self.assertEqual(jwt.key, AuthMiddleware.cookie_name) self.assertEqual(jwt.value, self.auth_token_verified) self.assertEqual(jwt['path'], '/')
def on_post(self, req, resp): """ :type req: MonitorrentRequest :type resp: MonitorrentResponse """ body = req.json if body is None or 'password' not in body: raise falcon.HTTPBadRequest('WrongPassword', 'password is not specified') password = body['password'] if password != self.settings_manager.get_password(): raise falcon.HTTPUnauthorized('WrongPassword', 'password is not correct', None) AuthMiddleware.authenticate(resp)
def on_post(self, req, resp): """ :type req: MonitorrentRequest :type resp: MonitorrentResponse """ body = req.json if body is None or 'password' not in body: raise falcon.HTTPBadRequest('WrongPassword', 'password is not specified') password = body['password'] if password != self.settings_manager.get_password(): raise falcon.HTTPUnauthorized('WrongPassword', 'password is not correct', None) AuthMiddleware.authenticate(resp)