Harden discovery rendezvous service
This commit is contained in:
parent
804e19c51a
commit
ef30369865
8 changed files with 57 additions and 7 deletions
|
|
@ -2,11 +2,16 @@ from __future__ import annotations
|
|||
|
||||
from http.client import HTTPConnection
|
||||
import json
|
||||
import socketserver
|
||||
import threading
|
||||
import unittest
|
||||
|
||||
from netfishing_discovery.registry import RoomRegistry
|
||||
from netfishing_discovery.server import DiscoveryHTTPServer, ServerConfig
|
||||
from netfishing_discovery.server import (
|
||||
DiscoveryHTTPServer,
|
||||
ServerConfig,
|
||||
TraversalUDPServer,
|
||||
)
|
||||
|
||||
|
||||
VALID_ROOM = {
|
||||
|
|
@ -22,7 +27,12 @@ VALID_ROOM = {
|
|||
class DiscoveryHTTPTests(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls) -> None:
|
||||
config = ServerConfig(bind_host="127.0.0.1", bind_port=0, room_ttl_seconds=30.0)
|
||||
config = ServerConfig(
|
||||
bind_host="127.0.0.1",
|
||||
bind_port=0,
|
||||
room_ttl_seconds=30.0,
|
||||
build_revision="test-build",
|
||||
)
|
||||
cls.server = DiscoveryHTTPServer(config, RoomRegistry(ttl_seconds=30.0))
|
||||
cls.thread = threading.Thread(target=cls.server.serve_forever, daemon=True)
|
||||
cls.thread.start()
|
||||
|
|
@ -163,6 +173,11 @@ class DiscoveryHTTPTests(unittest.TestCase):
|
|||
self.assertEqual(status, 200)
|
||||
assert body is not None
|
||||
self.assertEqual(body["status"], "ok")
|
||||
self.assertEqual(body["version"], "0.2.0")
|
||||
self.assertEqual(body["build_revision"], "test-build")
|
||||
|
||||
def test_udp_rendezvous_does_not_spawn_per_packet_threads(self) -> None:
|
||||
self.assertFalse(issubclass(TraversalUDPServer, socketserver.ThreadingMixIn))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue