Commit 99148d9f authored by Robin Knapp's avatar Robin Knapp

inital frame for integration

parent b3b9ce72
......@@ -11,7 +11,7 @@ from werkzeug.exceptions import HTTPException
from src.api import config
from src.api.routes import validation_v2_entities, historic_validation_v2_entities, validation_ld_entities, \
historic_validation_ld_entities
from src.api.server_utils import ValidationErrorResponse, random_id, parse_model
from src.api.server_utils import ValidationErrorResponse, random_id, parse_model, check_ksi_signature
from src.logger import FORMATTER
......@@ -69,6 +69,7 @@ def create_app():
if request.data:
# ensure payload is valid json model and has compliant format
parse_model()
check_ksi_signature()
@app.errorhandler(HTTPException)
def handle_http_exc(e):
......
......@@ -5,6 +5,7 @@ import re
import string
from ast import literal_eval
from json import load, JSONDecodeError
from time import sleep
from typing import Any
import requests
......@@ -532,6 +533,19 @@ def parse_model():
module=__name__)
def check_ksi_signature():
model = literal_eval(request.data.decode('UTF-8'))
if not model.get('ksiSignature'):
raise ValueError('missing')
URL = 'http://127.0.0.1:8000/ksi'
try:
req = requests.post(url=URL, data=request.data.decode('UTF-8'), timeout=5.0)
except requests.exceptions.HTTPError:
raise ValidationErrorResponse()
print(req.json())
sleep(20000)
class ValidationErrorResponse(HTTPException):
""" Custom HTTP exception that is to be used for erroneous requests."""
# without code = <int> the raise Exception pattern is not working
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment