|
@@ -91,6 +91,22 @@ class MockDataSrcClient:
|
|
|
return soa_rrset
|
|
|
return soa_rrset
|
|
|
|
|
|
+class MyCCSession(isc.config.ConfigData):
|
|
|
+ def __init__(self):
|
|
|
+ module_spec = isc.config.module_spec_from_file(
|
|
|
+ xfrout.SPECFILE_LOCATION)
|
|
|
+ ConfigData.__init__(self, module_spec)
|
|
|
+
|
|
|
+ def get_remote_config_value(self, module_name, identifier):
|
|
|
+ if module_name == "Auth" and identifier == "database_file":
|
|
|
+ return "initdb.file", False
|
|
|
+ else:
|
|
|
+ return "unknown", False
|
|
|
+
|
|
|
+# This constant dictionary stores all default configuration parameters
|
|
|
+# defined in the xfrout spec file.
|
|
|
+DEFAULT_CONFIG = MyCCSession().get_full_config()
|
|
|
+
|
|
|
# We subclass the Session class we're testing here, only overriding a few
|
|
|
# methods
|
|
|
class MyXfroutSession(XfroutSession):
|
|
@@ -111,6 +127,7 @@ class Dbserver:
|
|
|
def __init__(self):
|
|
|
self._shutdown_event = threading.Event()
|
|
|
self.transfer_counter = 0
|
|
|
+ self._max_transfers_out = DEFAULT_CONFIG['transfers_out']
|
|
|
def get_db_file(self):
|
|
|
return 'test.sqlite3'
|
|
|
def increase_transfers_counter(self):
|
|
@@ -158,7 +175,9 @@ class TestXfroutSession(unittest.TestCase):
|
|
|
def setUp(self):
|
|
|
self.sock = MySocket(socket.AF_INET,socket.SOCK_STREAM)
|
|
|
self.xfrsess = MyXfroutSession(self.sock, None, Dbserver(),
|
|
|
- TSIGKeyRing(), ('127.0.0.1', 12345),
|
|
|
+ TSIGKeyRing(),
|
|
|
+ (socket.AF_INET, socket.SOCK_STREAM,
|
|
|
+ ('127.0.0.1', 12345)),
|
|
|
# When not testing ACLs, simply accept
|
|
|
isc.acl.dns.REQUEST_LOADER.load(
|
|
|
[{"action": "ACCEPT"}]),
|
|
@@ -248,11 +267,13 @@ class TestXfroutSession(unittest.TestCase):
|
|
|
rcode, msg = self.xfrsess._parse_query_message(self.mdata)
|
|
|
self.assertEqual(rcode.to_text(), "NOERROR")
|
|
|
# This should be dropped completely, therefore returning None
|
|
|
- self.xfrsess._remote = ('192.0.2.1', 12345)
|
|
|
+ self.xfrsess._remote = (socket.AF_INET, socket.SOCK_STREAM,
|
|
|
+ ('192.0.2.1', 12345))
|
|
|
rcode, msg = self.xfrsess._parse_query_message(self.mdata)
|
|
|
self.assertEqual(None, rcode)
|
|
|
# This should be refused, therefore REFUSED
|
|
|
- self.xfrsess._remote = ('192.0.2.2', 12345)
|
|
|
+ self.xfrsess._remote = (socket.AF_INET, socket.SOCK_STREAM,
|
|
|
+ ('192.0.2.2', 12345))
|
|
|
rcode, msg = self.xfrsess._parse_query_message(self.mdata)
|
|
|
self.assertEqual(rcode.to_text(), "REFUSED")
|
|
|
|
|
@@ -261,7 +282,8 @@ class TestXfroutSession(unittest.TestCase):
|
|
|
|
|
|
# If the TSIG check fails, it should not check ACL
|
|
|
# (If it checked ACL as well, it would just drop the request)
|
|
|
- self.xfrsess._remote = ('192.0.2.1', 12345)
|
|
|
+ self.xfrsess._remote = (socket.AF_INET, socket.SOCK_STREAM,
|
|
|
+ ('192.0.2.1', 12345))
|
|
|
self.xfrsess._tsig_key_ring = TSIGKeyRing()
|
|
|
rcode, msg = self.xfrsess._parse_query_message(request_data)
|
|
|
self.assertEqual(rcode.to_text(), "NOTAUTH")
|
|
@@ -299,19 +321,23 @@ class TestXfroutSession(unittest.TestCase):
|
|
|
{"action": "REJECT"}
|
|
|
]))
|
|
|
# both matches
|
|
|
- self.xfrsess._remote = ('192.0.2.1', 12345)
|
|
|
+ self.xfrsess._remote = (socket.AF_INET, socket.SOCK_STREAM,
|
|
|
+ ('192.0.2.1', 12345))
|
|
|
[rcode, msg] = self.xfrsess._parse_query_message(request_data)
|
|
|
self.assertEqual(rcode.to_text(), "NOERROR")
|
|
|
# TSIG matches, but address doesn't
|
|
|
- self.xfrsess._remote = ('192.0.2.2', 12345)
|
|
|
+ self.xfrsess._remote = (socket.AF_INET, socket.SOCK_STREAM,
|
|
|
+ ('192.0.2.2', 12345))
|
|
|
[rcode, msg] = self.xfrsess._parse_query_message(request_data)
|
|
|
self.assertEqual(rcode.to_text(), "REFUSED")
|
|
|
# Address matches, but TSIG doesn't (not included)
|
|
|
- self.xfrsess._remote = ('192.0.2.1', 12345)
|
|
|
+ self.xfrsess._remote = (socket.AF_INET, socket.SOCK_STREAM,
|
|
|
+ ('192.0.2.1', 12345))
|
|
|
[rcode, msg] = self.xfrsess._parse_query_message(self.mdata)
|
|
|
self.assertEqual(rcode.to_text(), "REFUSED")
|
|
|
# Neither address nor TSIG matches
|
|
|
- self.xfrsess._remote = ('192.0.2.2', 12345)
|
|
|
+ self.xfrsess._remote = (socket.AF_INET, socket.SOCK_STREAM,
|
|
|
+ ('192.0.2.2', 12345))
|
|
|
[rcode, msg] = self.xfrsess._parse_query_message(self.mdata)
|
|
|
self.assertEqual(rcode.to_text(), "REFUSED")
|
|
|
|
|
@@ -675,19 +701,6 @@ class TestXfroutSession(unittest.TestCase):
|
|
|
# and it should not have sent anything else
|
|
|
self.assertEqual(0, len(self.sock.sendqueue))
|
|
|
|
|
|
-class MyCCSession(isc.config.ConfigData):
|
|
|
- def __init__(self):
|
|
|
- module_spec = isc.config.module_spec_from_file(
|
|
|
- xfrout.SPECFILE_LOCATION)
|
|
|
- ConfigData.__init__(self, module_spec)
|
|
|
-
|
|
|
- def get_remote_config_value(self, module_name, identifier):
|
|
|
- if module_name == "Auth" and identifier == "database_file":
|
|
|
- return "initdb.file", False
|
|
|
- else:
|
|
|
- return "unknown", False
|
|
|
-
|
|
|
-
|
|
|
class MyUnixSockServer(UnixSockServer):
|
|
|
def __init__(self):
|
|
|
self._shutdown_event = threading.Event()
|
|
@@ -705,23 +718,27 @@ class TestUnixSockServer(unittest.TestCase):
|
|
|
file descriptor. This is needed, because we get only that one
|
|
|
from auth."""
|
|
|
# We test with UDP, as it can be "connected" without other
|
|
|
- # endpoint
|
|
|
+ # endpoint. Note that in the current implementation _guess_remote()
|
|
|
+ # unconditionally returns SOCK_STREAM.
|
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
|
sock.connect(('127.0.0.1', 12345))
|
|
|
- self.assertEqual(('127.0.0.1', 12345),
|
|
|
+ self.assertEqual((socket.AF_INET, socket.SOCK_STREAM,
|
|
|
+ ('127.0.0.1', 12345)),
|
|
|
self.unix._guess_remote(sock.fileno()))
|
|
|
if socket.has_ipv6:
|
|
|
# Don't check IPv6 address on hosts not supporting them
|
|
|
sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
|
|
|
sock.connect(('::1', 12345))
|
|
|
- self.assertEqual(('::1', 12345, 0, 0),
|
|
|
+ self.assertEqual((socket.AF_INET6, socket.SOCK_STREAM,
|
|
|
+ ('::1', 12345, 0, 0)),
|
|
|
self.unix._guess_remote(sock.fileno()))
|
|
|
# Try when pretending there's no IPv6 support
|
|
|
# (No need to pretend when there's really no IPv6)
|
|
|
xfrout.socket.has_ipv6 = False
|
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
|
sock.connect(('127.0.0.1', 12345))
|
|
|
- self.assertEqual(('127.0.0.1', 12345),
|
|
|
+ self.assertEqual((socket.AF_INET, socket.SOCK_STREAM,
|
|
|
+ ('127.0.0.1', 12345)),
|
|
|
self.unix._guess_remote(sock.fileno()))
|
|
|
# Return it back
|
|
|
xfrout.socket.has_ipv6 = True
|