From 3cd2cc6254c5211184981d6990022673d7b3d910 Mon Sep 17 00:00:00 2001 From: Michal Nowak Date: Fri, 17 Feb 2023 13:16:13 +0100 Subject: [PATCH 1/2] Adapt to Python scripts to black 23.1.0 --- bin/tests/system/chain/ans4/ans.py | 2 +- bin/tests/system/cookie/ans9/ans.py | 2 ++ bin/tests/system/dnssec/ans10/ans.py | 1 + bin/tests/system/forward/ans11/ans.py | 1 + bin/tests/system/inline/tests_signed_zone_files.py | 1 - bin/tests/system/shutdown/tests_shutdown.py | 1 - bin/tests/system/statschannel/generic.py | 4 ---- bin/tests/system/statschannel/generic_dnspython.py | 3 --- bin/tests/system/statschannel/tests_json.py | 3 --- bin/tests/system/statschannel/tests_xml.py | 2 -- bin/tests/system/tcp/tests_tcp.py | 4 ---- 11 files changed, 5 insertions(+), 19 deletions(-) diff --git a/bin/tests/system/chain/ans4/ans.py b/bin/tests/system/chain/ans4/ans.py index 4d17705ef1..839067faa5 100755 --- a/bin/tests/system/chain/ans4/ans.py +++ b/bin/tests/system/chain/ans4/ans.py @@ -265,7 +265,7 @@ def create_response(msg): if wantsigs: r.answer.append(sigs[-1]) else: - for (i, sig) in rrs: + for i, sig in rrs: if sig and not wantsigs: continue elif sig: diff --git a/bin/tests/system/cookie/ans9/ans.py b/bin/tests/system/cookie/ans9/ans.py index 70cdf00dc0..5813475ece 100644 --- a/bin/tests/system/cookie/ans9/ans.py +++ b/bin/tests/system/cookie/ans9/ans.py @@ -35,6 +35,7 @@ from dns.rdataclass import * from dns.rdatatype import * from dns.tsig import * + # Log query to file def logquery(type, qname): with open("qlog", "a") as f: @@ -54,6 +55,7 @@ except: dopass2 = False + ############################################################################ # # This server will serve valid and spoofed answers. A spoofed answer will diff --git a/bin/tests/system/dnssec/ans10/ans.py b/bin/tests/system/dnssec/ans10/ans.py index c2f60e68e5..dbe49e5e5a 100644 --- a/bin/tests/system/dnssec/ans10/ans.py +++ b/bin/tests/system/dnssec/ans10/ans.py @@ -25,6 +25,7 @@ from dns.rdataclass import * from dns.rcode import * from dns.name import * + # Log query to file def logquery(type, qname): with open("qlog", "a") as f: diff --git a/bin/tests/system/forward/ans11/ans.py b/bin/tests/system/forward/ans11/ans.py index 95993813f8..00b5895f76 100644 --- a/bin/tests/system/forward/ans11/ans.py +++ b/bin/tests/system/forward/ans11/ans.py @@ -26,6 +26,7 @@ from dns.rdataclass import * from dns.rcode import * from dns.name import * + # Log query to file def logquery(type, qname): with open("qlog", "a") as f: diff --git a/bin/tests/system/inline/tests_signed_zone_files.py b/bin/tests/system/inline/tests_signed_zone_files.py index 06806eeb7d..596b756933 100755 --- a/bin/tests/system/inline/tests_signed_zone_files.py +++ b/bin/tests/system/inline/tests_signed_zone_files.py @@ -35,7 +35,6 @@ class RawFormatHeader(dict): def test_unsigned_serial_number(): - """ Check whether all signed zone files in the "ns8" subdirectory contain the serial number of the unsigned version of the zone in the raw-format header. diff --git a/bin/tests/system/shutdown/tests_shutdown.py b/bin/tests/system/shutdown/tests_shutdown.py index e8fc69e170..46c2d509b1 100755 --- a/bin/tests/system/shutdown/tests_shutdown.py +++ b/bin/tests/system/shutdown/tests_shutdown.py @@ -70,7 +70,6 @@ def do_work(named_proc, resolver, rndc_cmd, kill_method, n_workers, n_queries): # We're going to execute queries in parallel by means of a thread pool. # dnspython functions block, so we need to circunvent that. with ThreadPoolExecutor(n_workers + 1) as executor: - # Helper dict, where keys=Future objects and values are tags used # to process results later. futures = {} diff --git a/bin/tests/system/statschannel/generic.py b/bin/tests/system/statschannel/generic.py index 6688ff6db0..5ff09e2570 100644 --- a/bin/tests/system/statschannel/generic.py +++ b/bin/tests/system/statschannel/generic.py @@ -58,7 +58,6 @@ def check_manykeys(name, zone=None): def zone_mtime(zonedir, name): - try: si = os.stat(os.path.join(zonedir, "{}.db".format(name))) except FileNotFoundError: @@ -70,7 +69,6 @@ def zone_mtime(zonedir, name): def test_zone_timers_primary(fetch_zones, load_timers, **kwargs): - statsip = kwargs["statsip"] statsport = kwargs["statsport"] zonedir = kwargs["zonedir"] @@ -84,7 +82,6 @@ def test_zone_timers_primary(fetch_zones, load_timers, **kwargs): def test_zone_timers_secondary(fetch_zones, load_timers, **kwargs): - statsip = kwargs["statsip"] statsport = kwargs["statsport"] zonedir = kwargs["zonedir"] @@ -98,7 +95,6 @@ def test_zone_timers_secondary(fetch_zones, load_timers, **kwargs): def test_zone_with_many_keys(fetch_zones, load_zone, **kwargs): - statsip = kwargs["statsip"] statsport = kwargs["statsport"] diff --git a/bin/tests/system/statschannel/generic_dnspython.py b/bin/tests/system/statschannel/generic_dnspython.py index 37e6e89f14..34a0398108 100644 --- a/bin/tests/system/statschannel/generic_dnspython.py +++ b/bin/tests/system/statschannel/generic_dnspython.py @@ -28,7 +28,6 @@ def create_msg(qname, qtype): def udp_query(ip, port, msg): - ans = dns.query.udp(msg, ip, TIMEOUT, port=port) assert ans.rcode() == dns.rcode.NOERROR @@ -36,7 +35,6 @@ def udp_query(ip, port, msg): def tcp_query(ip, port, msg): - ans = dns.query.tcp(msg, ip, TIMEOUT, port=port) assert ans.rcode() == dns.rcode.NOERROR @@ -90,7 +88,6 @@ def check_traffic(data, expected): def test_traffic(fetch_traffic, **kwargs): - statsip = kwargs["statsip"] statsport = kwargs["statsport"] port = kwargs["port"] diff --git a/bin/tests/system/statschannel/tests_json.py b/bin/tests/system/statschannel/tests_json.py index 312c6830a6..c4599258ea 100755 --- a/bin/tests/system/statschannel/tests_json.py +++ b/bin/tests/system/statschannel/tests_json.py @@ -24,7 +24,6 @@ requests = pytest.importorskip("requests") # JSON helper functions def fetch_zones_json(statsip, statsport): - r = requests.get( "http://{}:{}/json/v1/zones".format(statsip, statsport), timeout=600 ) @@ -35,7 +34,6 @@ def fetch_zones_json(statsip, statsport): def fetch_traffic_json(statsip, statsport): - r = requests.get( "http://{}:{}/json/v1/traffic".format(statsip, statsport), timeout=600 ) @@ -47,7 +45,6 @@ def fetch_traffic_json(statsip, statsport): def load_timers_json(zone, primary=True): - name = zone["name"] # Check if the primary zone timer exists diff --git a/bin/tests/system/statschannel/tests_xml.py b/bin/tests/system/statschannel/tests_xml.py index 5b187b0f49..7f0b37e846 100755 --- a/bin/tests/system/statschannel/tests_xml.py +++ b/bin/tests/system/statschannel/tests_xml.py @@ -25,7 +25,6 @@ requests = pytest.importorskip("requests") # XML helper functions def fetch_zones_xml(statsip, statsport): - r = requests.get( "http://{}:{}/xml/v3/zones".format(statsip, statsport), timeout=600 ) @@ -75,7 +74,6 @@ def fetch_traffic_xml(statsip, statsport): def load_timers_xml(zone, primary=True): - name = zone.attrib["name"] loaded_el = zone.find("loaded") diff --git a/bin/tests/system/tcp/tests_tcp.py b/bin/tests/system/tcp/tests_tcp.py index 38343d2cf4..532b47b958 100644 --- a/bin/tests/system/tcp/tests_tcp.py +++ b/bin/tests/system/tcp/tests_tcp.py @@ -44,7 +44,6 @@ def create_socket(host, port): def test_tcp_garbage(named_port): 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()) (response, rtime) = dns.query.receive_tcp(sock, timeout()) @@ -67,7 +66,6 @@ def test_tcp_garbage(named_port): def test_tcp_garbage_response(named_port): 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()) (response, rtime) = dns.query.receive_tcp(sock, timeout()) @@ -91,7 +89,6 @@ def test_tcp_garbage_response(named_port): # Regression test for CVE-2022-0396 def test_close_wait(named_port): 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()) (response, rtime) = dns.query.receive_tcp(sock, timeout()) @@ -114,7 +111,6 @@ def test_close_wait(named_port): # request. If it gets stuck in CLOSE_WAIT state, there is no connection # available for the query below and it will time out. 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()) (response, rtime) = dns.query.receive_tcp(sock, timeout()) From 8064ac6becc0a5b2760d90923f41e8767bc24153 Mon Sep 17 00:00:00 2001 From: Michal Nowak Date: Fri, 17 Feb 2023 13:21:55 +0100 Subject: [PATCH 2/2] Fix unnecessary "else" after "raise" with pylint 2.16.2 bin/tests/system/get_algorithms.py:225:4: R1720: Unnecessary "else" after "raise", remove the "else" and de-indent the code inside it (no-else-raise) --- bin/tests/system/get_algorithms.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/tests/system/get_algorithms.py b/bin/tests/system/get_algorithms.py index 9cd07d4857..e21e208ce9 100755 --- a/bin/tests/system/get_algorithms.py +++ b/bin/tests/system/get_algorithms.py @@ -233,9 +233,8 @@ def main(): # later by run.sh print("export ALGORITHM_SET=error") raise - else: - for name, value in algs_env.items(): - print(f"export {name}={value}") + for name, value in algs_env.items(): + print(f"export {name}={value}") if __name__ == "__main__":