# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
-import os
import pytest
for item in items:
if "dnspython2" in item.keywords:
item.add_marker(skip_dnspython2)
-
-
-@pytest.fixture
-def named_port(request):
- # pylint: disable=unused-argument
- port = os.getenv("PORT")
- if port is None:
- port = 5301
- else:
- port = int(port)
-
- return port
-
-
-@pytest.fixture
-def control_port(request):
- # pylint: disable=unused-argument
- port = os.getenv("CONTROLPORT")
- if port is None:
- port = 5301
- else:
- port = int(port)
-
- return port
+#!/usr/bin/python3
+
# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
#
# SPDX-License-Identifier: MPL-2.0
# information regarding copyright ownership.
import os
+
import pytest
-@pytest.fixture(scope='module')
+@pytest.fixture(scope='session')
def named_port():
- return int(os.environ.get("PORT", default=5300))
+ return int(os.environ.get('PORT', default=5300))
+
+
+@pytest.fixture(scope='session')
+def named_tlsport():
+ return int(os.environ.get('TLSPORT', default=8853))
+
+
+@pytest.fixture(scope='session')
+def control_port():
+ return int(os.environ.get('CONTROLPORT', default=9953))
+++ /dev/null
-# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
-#
-# SPDX-License-Identifier: MPL-2.0
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, you can obtain one at https://mozilla.org/MPL/2.0/.
-#
-# See the COPYRIGHT file distributed with this work for additional
-# information regarding copyright ownership.
-
-import os
-import pytest
-
-
-@pytest.fixture
-def port(request):
- # pylint: disable=unused-argument
- env_port = os.getenv("PORT")
- if env_port is None:
- env_port = 5300
- else:
- env_port = int(env_port)
-
- return env_port
import dns.rcode
-def test_connreset(port):
+def test_connreset(named_port):
msg = dns.message.make_query("sub.example.", "A", want_dnssec=True,
use_edns=0, payload=1232)
- ans = dns.query.udp(msg, "10.53.0.2", timeout=10, port=port)
+ ans = dns.query.udp(msg, "10.53.0.2", timeout=10, port=named_port)
assert ans.rcode() == dns.rcode.SERVFAIL
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
-import os
import shutil
import subprocess
pytest.skip('gnutls-cli does not support the --logfile option')
return executable
-
-
-@pytest.fixture
-def named_tlsport():
- return int(os.environ.get('TLSPORT', '853'))
for item in items:
if "json" in item.keywords:
item.add_marker(no_jsonstats)
-
-
-@pytest.fixture
-def named_port(request):
- # pylint: disable=unused-argument
- port = os.getenv("PORT")
- if port is None:
- port = 5301
- else:
- port = int(port)
-
- return port
cp -a "${srcdir}/common" "${builddir}"
fi
# Some tests require additional files to work for out-of-tree test runs.
- for file in ckdnsrps.sh digcomp.pl ditch.pl fromhex.pl kasp.sh packet.pl start.pl stop.pl testcrypto.sh; do
+ for file in ckdnsrps.sh conftest.py digcomp.pl ditch.pl fromhex.pl kasp.sh packet.pl start.pl stop.pl testcrypto.sh; do
if [ ! -r "${file}" ]; then
cp -a "${srcdir}/${file}" "${builddir}"
fi
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
-import os
import pytest
for item in items:
if "dnspython" in item.keywords:
item.add_marker(skip_dnspython)
-
-
-@pytest.fixture
-def named_port(request):
- # pylint: disable=unused-argument
- port = os.getenv("PORT")
- if port is None:
- port = 5301
- else:
- port = int(port)
-
- return port
-
-
-@pytest.fixture
-def control_port(request):
- # pylint: disable=unused-argument
- port = os.getenv("CONTROLPORT")
- if port is None:
- port = 5301
- else:
- port = int(port)
-
- return port
def statsport(request):
# pylint: disable=unused-argument
env_port = os.getenv("EXTRAPORT1")
- if port is None:
+ if env_port is None:
env_port = 5301
else:
env_port = int(env_port)
return env_port
-
-
-@pytest.fixture
-def port(request):
- # pylint: disable=unused-argument
- env_port = os.getenv("PORT")
- if port is None:
- env_port = 5300
- else:
- env_port = int(env_port)
-
- return env_port
@pytest.mark.dnspython
@pytest.mark.skipif(os.getenv("HAVEJSONSTATS", "unset") != "1",
reason="JSON not configured")
-def test_traffic_json(port, statsport):
+def test_traffic_json(named_port, statsport):
generic.test_traffic(fetch_traffic_json,
statsip="10.53.0.2", statsport=statsport,
- port=port)
+ port=named_port)
@pytest.mark.dnspython
@pytest.mark.skipif(os.getenv("HAVEXMLSTATS", "unset") != "1",
reason="XML not configured")
-def test_traffic_xml(port, statsport):
+def test_traffic_xml(named_port, statsport):
generic.test_traffic(fetch_traffic_xml,
statsip="10.53.0.2", statsport=statsport,
- port=port)
+ port=named_port)
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
-import os
import pytest
for item in items:
if "dnspython2" in item.keywords:
item.add_marker(skip_dnspython2)
-
-
-@pytest.fixture
-def port(request):
- # pylint: disable=unused-argument
- env_port = os.getenv("PORT")
- if port is None:
- env_port = 5300
- else:
- env_port = int(env_port)
-
- return env_port
@pytest.mark.dnspython
@pytest.mark.dnspython2
-def test_tcp_garbage(port):
+def test_tcp_garbage(named_port):
import dns.query
- with create_socket("10.53.0.7", port) as sock:
+ with create_socket("10.53.0.7", named_port) as sock:
msg = create_msg("a.example.", "A")
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
@pytest.mark.dnspython
@pytest.mark.dnspython2
-def test_tcp_garbage_response(port):
+def test_tcp_garbage_response(named_port):
import dns.query
import dns.message
- with create_socket("10.53.0.7", port) as sock:
+ with create_socket("10.53.0.7", named_port) as sock:
msg = create_msg("a.example.", "A")
(sbytes, stime) = dns.query.send_tcp(sock, msg, timeout())
for item in items:
if "long" in item.keywords:
item.add_marker(skip_long_tests)
-
-
-@pytest.fixture
-def port(request):
- # pylint: disable=unused-argument
- env_port = os.getenv("PORT")
- if port is None:
- env_port = 5300
- else:
- env_port = int(env_port)
-
- return env_port
@pytest.mark.dnspython
@pytest.mark.dnspython2
-def test_initial_timeout(port):
+def test_initial_timeout(named_port):
#
# The initial timeout is 2.5 seconds, so this should timeout
#
import dns.query
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
- sock.connect(("10.53.0.1", port))
+ sock.connect(("10.53.0.1", named_port))
time.sleep(3)
@pytest.mark.dnspython
@pytest.mark.dnspython2
-def test_idle_timeout(port):
+def test_idle_timeout(named_port):
#
# The idle timeout is 5 seconds, so the third message should fail
#
msg = create_msg("example.", "A")
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
- sock.connect(("10.53.0.1", port))
+ sock.connect(("10.53.0.1", named_port))
time.sleep(1)
@pytest.mark.dnspython
@pytest.mark.dnspython2
-def test_keepalive_timeout(port):
+def test_keepalive_timeout(named_port):
#
# Keepalive is 7 seconds, so the third message should succeed.
#
msg.use_edns(edns=True, payload=4096, options=[kopt])
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
- sock.connect(("10.53.0.1", port))
+ sock.connect(("10.53.0.1", named_port))
time.sleep(1)
@pytest.mark.dnspython
@pytest.mark.dnspython2
-def test_pipelining_timeout(port):
+def test_pipelining_timeout(named_port):
#
# The pipelining should only timeout after the last message is received
#
msg = create_msg("example.", "A")
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
- sock.connect(("10.53.0.1", port))
+ sock.connect(("10.53.0.1", named_port))
time.sleep(1)
@pytest.mark.dnspython
@pytest.mark.dnspython2
-def test_long_axfr(port):
+def test_long_axfr(named_port):
#
# The timers should not fire during AXFR, thus the connection should not
# close abruptly
import dns.rdatatype
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
- sock.connect(("10.53.0.1", port))
+ sock.connect(("10.53.0.1", named_port))
name = dns.name.from_text("example.")
msg = create_msg("example.", "AXFR")
@pytest.mark.dnspython
@pytest.mark.dnspython2
-def test_send_timeout(port):
+def test_send_timeout(named_port):
import dns.query
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
- sock.connect(("10.53.0.1", port))
+ sock.connect(("10.53.0.1", named_port))
# Send and receive single large RDATA over TCP
msg = create_msg("large.example.", "TXT")
@pytest.mark.dnspython
@pytest.mark.dnspython2
@pytest.mark.long
-def test_max_transfer_idle_out(port):
+def test_max_transfer_idle_out(named_port):
import dns.query
import dns.rdataclass
import dns.rdatatype
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
- sock.connect(("10.53.0.1", port))
+ sock.connect(("10.53.0.1", named_port))
name = dns.name.from_text("example.")
msg = create_msg("example.", "AXFR")
@pytest.mark.dnspython
@pytest.mark.dnspython2
@pytest.mark.long
-def test_max_transfer_time_out(port):
+def test_max_transfer_time_out(named_port):
import dns.query
import dns.rdataclass
import dns.rdatatype
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
- sock.connect(("10.53.0.1", port))
+ sock.connect(("10.53.0.1", named_port))
name = dns.name.from_text("example.")
msg = create_msg("example.", "AXFR")