]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Rewrite ecdsa system test to pytest
authorMichal Nowak <mnowak@isc.org>
Thu, 18 Jul 2024 19:43:42 +0000 (21:43 +0200)
committerMichal Nowak <mnowak@isc.org>
Wed, 4 Dec 2024 17:56:53 +0000 (18:56 +0100)
bin/tests/system/ecdsa/.gitignore [deleted file]
bin/tests/system/ecdsa/ns1/sign.sh
bin/tests/system/ecdsa/tests.sh [deleted file]
bin/tests/system/ecdsa/tests_ecdsa.py [new file with mode: 0644]
bin/tests/system/ecdsa/tests_sh_ecdsa.py [deleted file]

diff --git a/bin/tests/system/ecdsa/.gitignore b/bin/tests/system/ecdsa/.gitignore
deleted file mode 100644 (file)
index e096e33..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-/ns1/named.conf
-/ns2/named.conf
index 2d49065639195455b65f898ee4bb013f01d90451..ec41d20b02b3975e3f1b3e5e4cd98c10b6c72f6d 100644 (file)
@@ -41,17 +41,11 @@ fi
 if [ $ECDSAP256SHA256_SUPPORTED = 1 ]; then
   keyfile_to_static_ds $ksk256 >trusted.conf
   cp trusted.conf ../ns2/trusted.conf
-else
-  keyfile_to_static_ds $ksk384 >trusted.conf
-  cp trusted.conf ../ns2/trusted.conf
 fi
 
 if [ $ECDSAP384SHA384_SUPPORTED = 1 ]; then
   keyfile_to_static_ds $ksk384 >trusted.conf
   cp trusted.conf ../ns3/trusted.conf
-else
-  keyfile_to_static_ds $ksk256 >trusted.conf
-  cp trusted.conf ../ns3/trusted.conf
 fi
 
 $SIGNER -P -g -o "$zone" "$zonefile" >/dev/null 2>signer.err || cat signer.err
diff --git a/bin/tests/system/ecdsa/tests.sh b/bin/tests/system/ecdsa/tests.sh
deleted file mode 100644 (file)
index 7016bf2..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/bin/sh
-
-# 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.
-
-set -e
-
-. ../conf.sh
-
-status=0
-n=0
-
-dig_with_opts() {
-  "$DIG" +tcp +noau +noadd +nosea +nostat +nocmd +dnssec -p "$PORT" "$@"
-}
-
-if [ $ECDSAP256SHA256_SUPPORTED = 1 ]; then
-  n=$((n + 1))
-  echo_i "checking that ECDSA256 positive validation works ($n)"
-  ret=0
-  dig_with_opts . @10.53.0.1 soa >dig.out.ns1.test$n || ret=1
-  dig_with_opts . @10.53.0.2 soa >dig.out.ns2.test$n || ret=1
-  $PERL ../digcomp.pl dig.out.ns1.test$n dig.out.ns2.test$n || ret=1
-  grep "flags:.*ad.*QUERY" dig.out.ns2.test$n >/dev/null || ret=1
-  if [ $ret != 0 ]; then echo_i "failed"; fi
-  status=$((status + ret))
-else
-  echo_i "algorithm ECDSA256 not supported, skipping test"
-fi
-
-if [ $ECDSAP384SHA384_SUPPORTED = 1 ]; then
-  n=$((n + 1))
-  echo_i "checking that ECDSA384 positive validation works ($n)"
-  ret=0
-  dig_with_opts . @10.53.0.1 soa >dig.out.ns1.test$n || ret=1
-  dig_with_opts . @10.53.0.3 soa >dig.out.ns3.test$n || ret=1
-  $PERL ../digcomp.pl dig.out.ns1.test$n dig.out.ns3.test$n || ret=1
-  grep "flags:.*ad.*QUERY" dig.out.ns3.test$n >/dev/null || ret=1
-  if [ $ret != 0 ]; then echo_i "failed"; fi
-  status=$((status + ret))
-else
-  echo_i "algorithm ECDSA384 not supported, skipping test"
-fi
-
-echo_i "exit status: $status"
-[ $status -eq 0 ] || exit 1
diff --git a/bin/tests/system/ecdsa/tests_ecdsa.py b/bin/tests/system/ecdsa/tests_ecdsa.py
new file mode 100644 (file)
index 0000000..6ae613c
--- /dev/null
@@ -0,0 +1,53 @@
+# 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
+
+import dns.message
+import isctest
+
+
+pytestmark = pytest.mark.extra_artifacts(
+    [
+        "ns*/trusted.conf",
+        "ns1/K*",
+        "ns1/dsset-*",
+        "ns1/root.db",
+        "ns1/root.db.signed",
+        "ns1/signer.err",
+    ]
+)
+
+
+def check_server_soa(resolver):
+    msg = dns.message.make_query(".", "SOA")
+    msg.flags += dns.flags.AD
+    res1 = isctest.query.tcp(msg, "10.53.0.1")
+    res2 = isctest.query.tcp(msg, resolver)
+    isctest.check.rrsets_equal(res1.answer, res2.answer)
+    assert res2.flags & dns.flags.AD
+
+
+@pytest.mark.skipif(
+    not os.environ["ECDSAP384SHA384_SUPPORTED"],
+    reason="algorithm ECDSA384 not supported",
+)
+def test_ecdsa256():
+    check_server_soa("10.53.0.2")
+
+
+@pytest.mark.skipif(
+    not os.environ["ECDSAP256SHA256_SUPPORTED"],
+    reason="algorithm ECDSA256 not supported",
+)
+def test_ecdsa384():
+    check_server_soa("10.53.0.3")
diff --git a/bin/tests/system/ecdsa/tests_sh_ecdsa.py b/bin/tests/system/ecdsa/tests_sh_ecdsa.py
deleted file mode 100644 (file)
index b264f64..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-# 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 pytest
-
-pytestmark = pytest.mark.extra_artifacts(
-    [
-        "dig.out.*",
-        "ns*/trusted.conf",
-        "ns1/K*",
-        "ns1/dsset-*",
-        "ns1/root.db",
-        "ns1/root.db.signed",
-        "ns1/signer.err",
-    ]
-)
-
-
-def test_ecdsa(run_tests_sh):
-    run_tests_sh()