#1752: simplifying the DNS implementation - switch to TCP + fixing the DNS integration test

This commit is contained in:
Czar Echavez
2023-09-12 13:37:11 +01:00
parent fb96ef18c0
commit 8b6bc84321
8 changed files with 31 additions and 17 deletions

View File

@@ -4,6 +4,7 @@ from primaite.simulator.network.hardware.nodes.computer import Computer
from primaite.simulator.network.hardware.nodes.server import Server
from primaite.simulator.system.services.dns_client import DNSClient
from primaite.simulator.system.services.dns_server import DNSServer
from primaite.simulator.system.services.service import ServiceOperatingState
def test_dns_client_server(uc2_network):
@@ -13,12 +14,17 @@ def test_dns_client_server(uc2_network):
dns_client: DNSClient = client_1.software_manager.software["DNSClient"]
dns_server: DNSServer = domain_controller.software_manager.software["DNSServer"]
# register a domain to web server
dns_server.dns_register("real-domain.com", IPv4Address("192.168.1.12"))
assert dns_client.operating_state == ServiceOperatingState.RUNNING
assert dns_server.operating_state == ServiceOperatingState.RUNNING
dns_server.show()
dns_client.check_domain_exists(target_domain="real-domain.com", dest_ip_address=IPv4Address("192.168.1.14"))
# fake domain should not be added to dns cache
dns_client.check_domain_exists(
target_domain="fake-domain.com", dest_ip_address=IPv4Address(domain_controller.ip_address)
)
assert dns_client.dns_cache.get("fake-domain.com", None) is None
# should register the domain in the client cache
assert dns_client.dns_cache.get("real-domain.com") is not None
# arcd.com is registered in dns server and should be saved to cache
dns_client.check_domain_exists(target_domain="arcd.com", dest_ip_address=IPv4Address(domain_controller.ip_address))
assert dns_client.dns_cache.get("arcd.com", None) is not None

View File

@@ -31,7 +31,7 @@ def test_create_dns_server(dns_server):
dns_server_service: DNSServer = dns_server.software_manager.software["DNSServer"]
assert dns_server_service.name is "DNSServer"
assert dns_server_service.port is Port.DNS
assert dns_server_service.protocol is IPProtocol.UDP
assert dns_server_service.protocol is IPProtocol.TCP
def test_create_dns_client(dns_client):
@@ -39,7 +39,7 @@ def test_create_dns_client(dns_client):
dns_client_service: DNSClient = dns_client.software_manager.software["DNSClient"]
assert dns_client_service.name is "DNSClient"
assert dns_client_service.port is Port.DNS
assert dns_client_service.protocol is IPProtocol.UDP
assert dns_client_service.protocol is IPProtocol.TCP
def test_dns_server_domain_name_registration(dns_server):