# Path: conpot/core/attack_session.py
# class AttackSession(object):
#     def __init__(
#         self,
#         protocol,
#         source_ip,
#         source_port,
#         destination_ip,
#         destination_port,
#         log_queue,
#     ):
#         self.log_queue = log_queue
#         self.id = uuid.uuid4()
#         logger.info("New %s session from %s (%s)", protocol, source_ip, self.id)
#         self.protocol = protocol
#         self.source_ip = source_ip
#         self.source_port = source_port
#         self.destination_ip = destination_ip
#         self.destination_port = destination_port
#         self.timestamp = datetime.utcnow()
#         self.public_ip = None
#         self.data = dict()
#         self._ended = False
# 
#     def _dump_data(self, data):
#         return {
#             "id": self.id,
#             "remote": (self.source_ip, self.source_port),
#             "src_ip": self.source_ip,
#             "src_port": self.source_port,
#             "local": (self.destination_ip, self.destination_port),
#             "dst_ip": self.destination_ip,
#             "dst_port": self.destination_port,
#             "data_type": self.protocol,
#             "timestamp": self.timestamp,
#             "public_ip": self.public_ip,
#             "data": data,
#         }
# 
#     def add_event(self, event_data):
#         sec_elapsed = (datetime.utcnow() - self.timestamp).total_seconds()
#         elapse_ms = int(sec_elapsed * 1000)
#         while elapse_ms in self.data:
#             elapse_ms += 1
#         self.data[elapse_ms] = event_data
#         # TODO: We should only log the session when it is finished
#         self.log_queue.put(self._dump_data(event_data))
# 
#     def dump(self):
#         return self._dump_data(self.data)
# 
#     def set_ended(self):
#         self._ended = True


from datetime import datetime, timedelta
from freezegun import freeze_time
from conpot.core.attack_session import AttackSession




class LogQueueFake:
    def __init__(self):
        self.events = []

    def put(self, event):
        self.events.append(event)


def test_add_event_is_logged():
    protocol = "testing"
    source_ip = "1.2.3.4"
    source_port = 11
    destination_ip = "5.6.7.8"
    destination_port = 22
    log_queue = LogQueueFake()


# Path: conpot/core/attack_session.py
# class AttackSession(object):
#     def __init__(
#         self,
#         protocol,
#         source_ip,
#         source_port,
#         destination_ip,
#         destination_port,
#         log_queue,
#     ):
#         self.log_queue = log_queue
#         self.id = uuid.uuid4()
#         logger.info("New %s session from %s (%s)", protocol, source_ip, self.id)
#         self.protocol = protocol
#         self.source_ip = source_ip
#         self.source_port = source_port
#         self.destination_ip = destination_ip
#         self.destination_port = destination_port
#         self.timestamp = datetime.utcnow()
#         self.public_ip = None
#         self.data = dict()
#         self._ended = False
# 
#     def _dump_data(self, data):
#         return {
#             "id": self.id,
#             "remote": (self.source_ip, self.source_port),
#             "src_ip": self.source_ip,
#             "src_port": self.source_port,
#             "local": (self.destination_ip, self.destination_port),
#             "dst_ip": self.destination_ip,
#             "dst_port": self.destination_port,
#             "data_type": self.protocol,
#             "timestamp": self.timestamp,
#             "public_ip": self.public_ip,
#             "data": data,
#         }
# 
#     def add_event(self, event_data):
#         sec_elapsed = (datetime.utcnow() - self.timestamp).total_seconds()
#         elapse_ms = int(sec_elapsed * 1000)
#         while elapse_ms in self.data:
#             elapse_ms += 1
#         self.data[elapse_ms] = event_data
#         # TODO: We should only log the session when it is finished
#         self.log_queue.put(self._dump_data(event_data))
# 
#     def dump(self):
#         return self._dump_data(self.data)
# 
#     def set_ended(self):
#         self._ended = True


# Path: conpot/tests/test_attack_session.py
from datetime import datetime, timedelta
from freezegun import freeze_time
from conpot.core.attack_session import AttackSession





class LogQueueFake:
    def __init__(self):
        self.events = []

    def put(self, event):
        self.events.append(event)


def test_add_event_is_logged():
    protocol = "testing"
    source_ip = "1.2.3.4"
    source_port = 11
    destination_ip = "5.6.7.8"
    destination_port = 22
    log_queue = LogQueueFake()


    session = AttackSession(