Commit fd5925bd authored by Stavros-Anastasios Charismiadis's avatar Stavros-Anastasios Charismiadis
Browse files

[Mock server tests failing] Fix Events testing

parent bd0c7a96
Loading
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ import json
from flask import current_app
import asyncio
import aiohttp
from util import dict_to_camel_case, clean_empty

class Notifications():

@@ -33,9 +34,9 @@ class Notifications():
                    event_detail={redis_event.get('key'):redis_event.get('information')}
                current_app.logger.debug(event_detail)
                data = EventNotification(sub["subscription_id"], events=redis_event.get('event'), event_detail=event_detail)
                current_app.logger.debug(json.dumps(data,cls=JSONEncoder))
                current_app.logger.debug(json.dumps(data.to_dict(),cls=JSONEncoder))

                asyncio.run(self.send(url, json.loads(json.dumps(data,cls=JSONEncoder))))
                asyncio.run(self.send(url, dict_to_camel_case(clean_empty(data.to_dict()))))

        except Exception as e:
            current_app.logger.error("An exception occurred ::" + str(e))
+6 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ from ..models.problem_details import ProblemDetails
from ..encoder import JSONEncoder
from .resources import Resource
from .responses import internal_server_error
from ..util import dict_to_camel_case, clean_empty

class ControlAccess(Resource):

@@ -18,6 +19,11 @@ class ControlAccess(Resource):
            if cert_entry is not None:
                if cert_entry["cert_signature"] != cert_signature or "event_subscriptions" not in cert_entry["resources"] or event_id not in cert_entry["resources"]["event_subscriptions"]:
                    prob = ProblemDetails(title="Unauthorized", detail="User not authorized", cause="You are not the owner of this resource")

                    prob = prob.to_dict()
                    prob = clean_empty(prob)
                    prob = dict_to_camel_case(prob)

                    return Response(json.dumps(prob, cls=JSONEncoder), status=401, mimetype="application/json")

        except Exception as e:
+2 −2
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ class LoggingInvocationOperations(Resource):

            current_app.logger.debug("Check service apis")
            event=None
            invocation_log_base=json.loads(json.dumps(invocationlog, cls=JSONEncoder))
            invocation_log_base=json.loads(json.dumps(invocationlog.to_dict(), cls=JSONEncoder))

            for log in invocationlog.logs:
                result = self.__check_service_apis(log.api_id, log.api_name)
@@ -97,7 +97,7 @@ class LoggingInvocationOperations(Resource):
                        event="SERVICE_API_INVOCATION_FAILURE"

                    current_app.logger.info(event)
                    invocation_log_base['logs']=[log]
                    invocation_log_base['logs']=[log.to_dict()]
                    invocationLogs=[invocation_log_base]
                    RedisEvent(event,"invocationLogs",invocationLogs).send_event()

+1 −1
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ class RegisterOperations:
        try:
            
            url = f"https://capifcore/helper/deleteEntities/{uuid}" 
            requests.delete(url, cert=("register_service/certs/superadmin.crt", "register_service/certs/superadmin.key"), verify="register_service/certs/ca_root.crt")
            requests.delete(url, cert=("certs/superadmin.crt", "certs/superadmin.key"), verify="certs/ca_root.crt")
            
            mycol.delete_one({"uuid": uuid})