]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
add svcb tpkg tests
authorTom Carpay <tom@nlnetlabs.nl>
Tue, 25 May 2021 13:44:49 +0000 (15:44 +0200)
committerTom Carpay <tom@nlnetlabs.nl>
Tue, 25 May 2021 13:44:49 +0000 (15:44 +0200)
30 files changed:
testdata/svcb.tdir/crypto.cloudflare.com.zone [new file with mode: 0644]
testdata/svcb.tdir/failure-cases.zone [new file with mode: 0644]
testdata/svcb.tdir/svcb.dsc [new file with mode: 0644]
testdata/svcb.tdir/svcb.failure-cases-01 [new file with mode: 0644]
testdata/svcb.tdir/svcb.failure-cases-02 [new file with mode: 0644]
testdata/svcb.tdir/svcb.failure-cases-03 [new file with mode: 0644]
testdata/svcb.tdir/svcb.failure-cases-04 [new file with mode: 0644]
testdata/svcb.tdir/svcb.failure-cases-05 [new file with mode: 0644]
testdata/svcb.tdir/svcb.failure-cases-06 [new file with mode: 0644]
testdata/svcb.tdir/svcb.failure-cases-07 [new file with mode: 0644]
testdata/svcb.tdir/svcb.failure-cases-08 [new file with mode: 0644]
testdata/svcb.tdir/svcb.failure-cases-09 [new file with mode: 0644]
testdata/svcb.tdir/svcb.failure-cases-10 [new file with mode: 0644]
testdata/svcb.tdir/svcb.failure-cases-11 [new file with mode: 0644]
testdata/svcb.tdir/svcb.failure-cases-12 [new file with mode: 0644]
testdata/svcb.tdir/svcb.failure-cases-13 [new file with mode: 0644]
testdata/svcb.tdir/svcb.failure-cases-14 [new file with mode: 0644]
testdata/svcb.tdir/svcb.failure-cases-15 [new file with mode: 0644]
testdata/svcb.tdir/svcb.failure-cases-16 [new file with mode: 0644]
testdata/svcb.tdir/svcb.failure-cases-17 [new file with mode: 0644]
testdata/svcb.tdir/svcb.failure-cases-18 [new file with mode: 0644]
testdata/svcb.tdir/svcb.failure-cases-19 [new file with mode: 0644]
testdata/svcb.tdir/svcb.failure-cases-20 [new file with mode: 0644]
testdata/svcb.tdir/svcb.failure-cases-21 [new file with mode: 0644]
testdata/svcb.tdir/svcb.failure-cases-22 [new file with mode: 0644]
testdata/svcb.tdir/svcb.success-cases.zone [new file with mode: 0644]
testdata/svcb.tdir/svcb.success-cases.zone.cmp [new file with mode: 0644]
testdata/svcb.tdir/svcb.test [new file with mode: 0644]
testdata/svcb.tdir/svcb.test-vectors-pf.zone [new file with mode: 0644]
testdata/svcb.tdir/svcb.test-vectors-wf.zone [new file with mode: 0644]

diff --git a/testdata/svcb.tdir/crypto.cloudflare.com.zone b/testdata/svcb.tdir/crypto.cloudflare.com.zone
new file mode 100644 (file)
index 0000000..53c89c7
--- /dev/null
@@ -0,0 +1,9 @@
+crypto.cloudflare.com. 3600 IN SOA jobs.ns.cloudflare.com. dns.cloudflare.com. (
+                               2037099480 ; serial
+                               10000      ; refresh (2 hours 46 minutes 40 seconds)
+                               2400       ; retry (40 minutes)
+                               604800     ; expire (1 week)
+                               3600       ; minimum (1 hour)
+                               )
+crypto.cloudflare.com.  300     IN      HTTPS   1 . alpn=h2 ipv4hint=162.159.135.79,162.159.136.79 echconfig=AEj+CgBETwAgACDeVpr34JzYHDGNFoGWhksj5mpBxradonbqH3X9+h7jHgAEAAEAAQAAABNjbG91ZGZsYXJlLWVzbmkuY29tAAA= ipv6hint=2606:4700:7::a29f:874f,2606:4700:7::a29f:884f
+
diff --git a/testdata/svcb.tdir/failure-cases.zone b/testdata/svcb.tdir/failure-cases.zone
new file mode 100644 (file)
index 0000000..9ca222e
--- /dev/null
@@ -0,0 +1,95 @@
+$ORIGIN failure-cases.
+$TTL 3600
+
+
+@       SOA     primary admin 1 3600 1800 7200 3600
+        NS      primary
+primary A       127.0.0.1
+
+; This example has multiple instances of the same SvcParamKey
+
+f01    SVCB   1 foo.example.com. (
+                       key123=abc key123=def
+                       )
+; In the next examples the SvcParamKeys are missing their values.
+
+f02    SVCB   1 foo.example.com. mandatory
+
+; In the next examples the SvcParamKeys are missing their values.
+
+f03    SVCB   1 foo.example.com. alpn
+
+; In the next examples the SvcParamKeys are missing their values.
+
+f04    SVCB   1 foo.example.com. port
+
+; In the next examples the SvcParamKeys are missing their values.
+
+f05    SVCB   1 foo.example.com. ipv4hint
+
+; In the next examples the SvcParamKeys are missing their values.
+
+f06    SVCB   1 foo.example.com. ipv6hint
+
+; The "no-default-alpn" SvcParamKey value MUST be empty
+
+f07    SVCB   1 foo.example.com. no-default-alpn=abc
+
+; In this record a mandatory SvcParam is missing
+
+f08    SVCB   1 foo.example.com. mandatory=key123
+
+; The "mandatory" SvcParamKey MUST not be included in mandatory list
+
+f09    SVCB   1 foo.example.com. mandatory=mandatory
+
+; Here there are multiple instances of the same SvcParamKey in the mandatory list
+
+f10    SVCB   1 foo.example.com. (
+                      mandatory=key123,key123 key123=abc
+                      )
+
+; This example has multiple instances of the same SvcParamKey
+
+f11    HTTPS   1 foo.example.com. (
+                       key123=abc key123=def
+                       )
+
+; In the next examples the SvcParamKeys are missing their values.
+
+f12    HTTPS   1 foo.example.com. mandatory
+
+; In the next examples the SvcParamKeys are missing their values.
+
+f13    HTTPS   1 foo.example.com. alpn
+
+; In the next examples the SvcParamKeys are missing their values.
+
+f14    HTTPS   1 foo.example.com. port
+
+; In the next examples the SvcParamKeys are missing their values.
+
+f15    HTTPS   1 foo.example.com. ipv4hint
+
+; In the next examples the SvcParamKeys are missing their values.
+
+f16    HTTPS   1 foo.example.com. ipv6hint
+
+; The "no-default-alpn" SvcParamKey value MUST be empty
+
+f17    HTTPS   1 foo.example.com. no-default-alpn=abc
+
+; In this record a mandatory SvcParam is missing
+
+f18    HTTPS   1 foo.example.com. mandatory=key123
+
+; The "mandatory" SvcParamKey MUST not be included in mandatory list
+
+f19    HTTPS   1 foo.example.com. mandatory=mandatory
+
+; Here there are multiple instances of the same SvcParamKey in the mandatory list
+
+f20    HTTPS   1 foo.example.com. (
+                      mandatory=key123,key123 key123=abc
+                      )
+
diff --git a/testdata/svcb.tdir/svcb.dsc b/testdata/svcb.tdir/svcb.dsc
new file mode 100644 (file)
index 0000000..6eae763
--- /dev/null
@@ -0,0 +1,16 @@
+BaseName: svcb
+Version: 1.0
+Description: Test SVCB and HTTPS parsing
+CreationDate: Fri May 25 12:51:22 UTC 2021
+Maintainer: Tom Carpay
+Category: 
+Component:
+CmdDepends: 
+Depends: 
+Help:
+Pre:
+Post:
+Test: svcb.test
+AuxFiles: 
+Passed:
+Failure:
diff --git a/testdata/svcb.tdir/svcb.failure-cases-01 b/testdata/svcb.tdir/svcb.failure-cases-01
new file mode 100644 (file)
index 0000000..497098b
--- /dev/null
@@ -0,0 +1,10 @@
+$ORIGIN failure-cases.
+$TTL 3600
+
+@       SOA     primary admin 0 0 0 0 0
+
+; This example has multiple instances of the same SvcParamKey
+
+f01    SVCB   1 foo.example.com. (
+                       key123=abc key123=def
+                       )
diff --git a/testdata/svcb.tdir/svcb.failure-cases-02 b/testdata/svcb.tdir/svcb.failure-cases-02
new file mode 100644 (file)
index 0000000..7365617
--- /dev/null
@@ -0,0 +1,8 @@
+$ORIGIN failure-cases.
+$TTL 3600
+
+@       SOA     primary admin 0 0 0 0 0
+
+; In the next examples the SvcParamKeys are missing their values.
+
+f02    SVCB   1 foo.example.com. mandatory
diff --git a/testdata/svcb.tdir/svcb.failure-cases-03 b/testdata/svcb.tdir/svcb.failure-cases-03
new file mode 100644 (file)
index 0000000..8ae6c4a
--- /dev/null
@@ -0,0 +1,8 @@
+$ORIGIN failure-cases.
+$TTL 3600
+
+@       SOA     primary admin 0 0 0 0 0
+
+; In the next examples the SvcParamKeys are missing their values.
+
+f03    SVCB   1 foo.example.com. alpn
diff --git a/testdata/svcb.tdir/svcb.failure-cases-04 b/testdata/svcb.tdir/svcb.failure-cases-04
new file mode 100644 (file)
index 0000000..5aa32a8
--- /dev/null
@@ -0,0 +1,8 @@
+$ORIGIN failure-cases.
+$TTL 3600
+
+@       SOA     primary admin 0 0 0 0 0
+
+; In the next examples the SvcParamKeys are missing their values.
+
+f04    SVCB   1 foo.example.com. port
diff --git a/testdata/svcb.tdir/svcb.failure-cases-05 b/testdata/svcb.tdir/svcb.failure-cases-05
new file mode 100644 (file)
index 0000000..4b2f95c
--- /dev/null
@@ -0,0 +1,8 @@
+$ORIGIN failure-cases.
+$TTL 3600
+
+@       SOA     primary admin 0 0 0 0 0
+
+; In the next examples the SvcParamKeys are missing their values.
+
+f05    SVCB   1 foo.example.com. ipv4hint
diff --git a/testdata/svcb.tdir/svcb.failure-cases-06 b/testdata/svcb.tdir/svcb.failure-cases-06
new file mode 100644 (file)
index 0000000..a111846
--- /dev/null
@@ -0,0 +1,8 @@
+$ORIGIN failure-cases.
+$TTL 3600
+
+@       SOA     primary admin 0 0 0 0 0
+
+; In the next examples the SvcParamKeys are missing their values.
+
+f06    SVCB   1 foo.example.com. ipv6hint
diff --git a/testdata/svcb.tdir/svcb.failure-cases-07 b/testdata/svcb.tdir/svcb.failure-cases-07
new file mode 100644 (file)
index 0000000..a8512ad
--- /dev/null
@@ -0,0 +1,8 @@
+$ORIGIN failure-cases.
+$TTL 3600
+
+@       SOA     primary admin 0 0 0 0 0
+
+; The "no-default-alpn" SvcParamKey value MUST be empty
+
+f07    SVCB   1 foo.example.com. no-default-alpn=abc
diff --git a/testdata/svcb.tdir/svcb.failure-cases-08 b/testdata/svcb.tdir/svcb.failure-cases-08
new file mode 100644 (file)
index 0000000..4bbf618
--- /dev/null
@@ -0,0 +1,8 @@
+$ORIGIN failure-cases.
+$TTL 3600
+
+@       SOA     primary admin 0 0 0 0 0
+
+; In this record a mandatory SvcParam is missing
+
+f08    SVCB   1 foo.example.com. mandatory=key123
diff --git a/testdata/svcb.tdir/svcb.failure-cases-09 b/testdata/svcb.tdir/svcb.failure-cases-09
new file mode 100644 (file)
index 0000000..408e937
--- /dev/null
@@ -0,0 +1,9 @@
+$ORIGIN failure-cases.
+$TTL 3600
+
+@       SOA     primary admin 0 0 0 0 0
+
+; The "mandatory" SvcParamKey MUST not be included in mandatory list
+
+f09    SVCB   1 foo.example.com. mandatory=mandatory
+
diff --git a/testdata/svcb.tdir/svcb.failure-cases-10 b/testdata/svcb.tdir/svcb.failure-cases-10
new file mode 100644 (file)
index 0000000..b1e6ccf
--- /dev/null
@@ -0,0 +1,10 @@
+$ORIGIN failure-cases.
+$TTL 3600
+
+@       SOA     primary admin 0 0 0 0 0
+
+; Here there are multiple instances of the same SvcParamKey in the mandatory list
+
+f10    SVCB   1 foo.example.com. (
+                      mandatory=key123,key123 key123=abc
+                      )
diff --git a/testdata/svcb.tdir/svcb.failure-cases-11 b/testdata/svcb.tdir/svcb.failure-cases-11
new file mode 100644 (file)
index 0000000..ee4d5a4
--- /dev/null
@@ -0,0 +1,10 @@
+$ORIGIN failure-cases.
+$TTL 3600
+
+@       SOA     primary admin 0 0 0 0 0
+
+; This example has multiple instances of the same SvcParamKey
+
+f01    HTTPS   1 foo.example.com. (
+                       key123=abc key123=def
+                       )
diff --git a/testdata/svcb.tdir/svcb.failure-cases-12 b/testdata/svcb.tdir/svcb.failure-cases-12
new file mode 100644 (file)
index 0000000..e57fa88
--- /dev/null
@@ -0,0 +1,8 @@
+$ORIGIN failure-cases.
+$TTL 3600
+
+@       SOA     primary admin 0 0 0 0 0
+
+; In the next examples the SvcParamKeys are missing their values.
+
+f02    HTTPS   1 foo.example.com. mandatory
diff --git a/testdata/svcb.tdir/svcb.failure-cases-13 b/testdata/svcb.tdir/svcb.failure-cases-13
new file mode 100644 (file)
index 0000000..52f3e62
--- /dev/null
@@ -0,0 +1,8 @@
+$ORIGIN failure-cases.
+$TTL 3600
+
+@       SOA     primary admin 0 0 0 0 0
+
+; In the next examples the SvcParamKeys are missing their values.
+
+f03    HTTPS   1 foo.example.com. alpn
diff --git a/testdata/svcb.tdir/svcb.failure-cases-14 b/testdata/svcb.tdir/svcb.failure-cases-14
new file mode 100644 (file)
index 0000000..3525d26
--- /dev/null
@@ -0,0 +1,8 @@
+$ORIGIN failure-cases.
+$TTL 3600
+
+@       SOA     primary admin 0 0 0 0 0
+
+; In the next examples the SvcParamKeys are missing their values.
+
+f04    HTTPS   1 foo.example.com. port
diff --git a/testdata/svcb.tdir/svcb.failure-cases-15 b/testdata/svcb.tdir/svcb.failure-cases-15
new file mode 100644 (file)
index 0000000..1ab5137
--- /dev/null
@@ -0,0 +1,8 @@
+$ORIGIN failure-cases.
+$TTL 3600
+
+@       SOA     primary admin 0 0 0 0 0
+
+; In the next examples the SvcParamKeys are missing their values.
+
+f05    HTTPS   1 foo.example.com. ipv4hint
diff --git a/testdata/svcb.tdir/svcb.failure-cases-16 b/testdata/svcb.tdir/svcb.failure-cases-16
new file mode 100644 (file)
index 0000000..78bed5c
--- /dev/null
@@ -0,0 +1,8 @@
+$ORIGIN failure-cases.
+$TTL 3600
+
+@       SOA     primary admin 0 0 0 0 0
+
+; In the next examples the SvcParamKeys are missing their values.
+
+f06    HTTPS   1 foo.example.com. ipv6hint
diff --git a/testdata/svcb.tdir/svcb.failure-cases-17 b/testdata/svcb.tdir/svcb.failure-cases-17
new file mode 100644 (file)
index 0000000..84aede0
--- /dev/null
@@ -0,0 +1,8 @@
+$ORIGIN failure-cases.
+$TTL 3600
+
+@       SOA     primary admin 0 0 0 0 0
+
+; The "no-default-alpn" SvcParamKey value MUST be empty
+
+f07    HTTPS   1 foo.example.com. no-default-alpn=abc
diff --git a/testdata/svcb.tdir/svcb.failure-cases-18 b/testdata/svcb.tdir/svcb.failure-cases-18
new file mode 100644 (file)
index 0000000..0ecbc54
--- /dev/null
@@ -0,0 +1,8 @@
+$ORIGIN failure-cases.
+$TTL 3600
+
+@       SOA     primary admin 0 0 0 0 0
+
+; In this record a mandatory SvcParam is missing
+
+f08    HTTPS   1 foo.example.com. mandatory=key123
diff --git a/testdata/svcb.tdir/svcb.failure-cases-19 b/testdata/svcb.tdir/svcb.failure-cases-19
new file mode 100644 (file)
index 0000000..5765564
--- /dev/null
@@ -0,0 +1,9 @@
+$ORIGIN failure-cases.
+$TTL 3600
+
+@       SOA     primary admin 0 0 0 0 0
+
+; The "mandatory" SvcParamKey MUST not be included in mandatory list
+
+f09    HTTPS   1 foo.example.com. mandatory=mandatory
+
diff --git a/testdata/svcb.tdir/svcb.failure-cases-20 b/testdata/svcb.tdir/svcb.failure-cases-20
new file mode 100644 (file)
index 0000000..fc4781e
--- /dev/null
@@ -0,0 +1,10 @@
+$ORIGIN failure-cases.
+$TTL 3600
+
+@       SOA     primary admin 0 0 0 0 0
+
+; Here there are multiple instances of the same SvcParamKey in the mandatory list
+
+f10    HTTPS   1 foo.example.com. (
+                      mandatory=key123,key123 key123=abc
+                      )
diff --git a/testdata/svcb.tdir/svcb.failure-cases-21 b/testdata/svcb.tdir/svcb.failure-cases-21
new file mode 100644 (file)
index 0000000..c601516
--- /dev/null
@@ -0,0 +1,9 @@
+$ORIGIN failure-cases.
+$TTL 3600
+
+@       SOA     primary admin 0 0 0 0 0
+
+; Here there are multiple instances of the same SvcParamKey in the mandatory list
+
+f21    HTTPS   1 foo.example.com. ech="123"
+f21    HTTPS   1 foo.example.com. echconfig="123"
diff --git a/testdata/svcb.tdir/svcb.failure-cases-22 b/testdata/svcb.tdir/svcb.failure-cases-22
new file mode 100644 (file)
index 0000000..d01b697
--- /dev/null
@@ -0,0 +1,8 @@
+$ORIGIN failure-cases.
+$TTL 3600
+
+@       SOA     primary admin 0 0 0 0 0
+
+; Port mus be a positive number < 65536
+
+f22    HTTPS   1 foo.example.com. port=65536
diff --git a/testdata/svcb.tdir/svcb.success-cases.zone b/testdata/svcb.tdir/svcb.success-cases.zone
new file mode 100644 (file)
index 0000000..0a96659
--- /dev/null
@@ -0,0 +1,40 @@
+$ORIGIN success-cases.
+$TTL 3600
+
+@       SOA     primary admin 0 0 0 0 0
+
+
+; A particular key does not need to have a value
+
+s01    SVCB   0 . key123
+
+
+; echconfig does not need to have a value
+
+s02    SVCB   0 . echconfig
+
+
+; When "no-default-alpn" is specified in an RR, "alpn" must also be specified
+; in order for the RR to be "self-consistent"
+
+s03    HTTPS   0 . alpn="h2,h3" no-default-alpn
+
+
+; SHOULD is not MUST (so allowed)
+; Zone-file implementations SHOULD enforce self-consistency
+
+s04    HTTPS   0 . no-default-alpn
+
+
+; SHOULD is not MUST (so allowed)
+; (port and no-default-alpn are automatically mandatory keys with HTTPS)
+; Other automatically mandatory keys SHOULD NOT appear in the list either.
+
+s05    HTTPS   0 . alpn="dot" no-default-alpn port=853 mandatory=port
+
+; Any valid base64 is okay for ech
+s06     HTTPS   0 . ech="aGVsbG93b3JsZCE="
+
+; echconfig is an alias for ech
+s07     HTTPS   0 . echconfig="aGVsbG93b3JsZCE="
+
diff --git a/testdata/svcb.tdir/svcb.success-cases.zone.cmp b/testdata/svcb.tdir/svcb.success-cases.zone.cmp
new file mode 100644 (file)
index 0000000..540b541
--- /dev/null
@@ -0,0 +1,12 @@
+$ORIGIN .
+success-cases  3600    IN      SOA     primary.success-cases. admin.success-cases. (
+               0 0 0 0 0 )
+$ORIGIN success-cases.
+s01    3600    IN      SVCB    0 . key123
+s02    3600    IN      SVCB    0 . ech
+s03    3600    IN      HTTPS   0 . alpn="h2,h3" no-default-alpn
+s04    3600    IN      HTTPS   0 . no-default-alpn
+s05    3600    IN      HTTPS   0 . mandatory=port alpn="dot" no-default-alpn port=853
+s06    3600    IN      HTTPS   0 . ech=aGVsbG93b3JsZCE=
+s07    3600    IN      HTTPS   0 . ech=aGVsbG93b3JsZCE=
+; zone success-cases is ok
diff --git a/testdata/svcb.tdir/svcb.test b/testdata/svcb.tdir/svcb.test
new file mode 100644 (file)
index 0000000..48a7545
--- /dev/null
@@ -0,0 +1,234 @@
+# #-- svcb.test --#
+# source the master var file when it's there
+[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
+# use .tpkg.var.test for in test variable passing
+[ -f .tpkg.var.test ] && source .tpkg.var.test
+
+
+# check and write the test vectors in their respective formats
+PRE=../..
+if ! $PRE/readzone svcb.test-vectors-pf.zone > svcb.test-vectors-pf.zone.out
+then
+       echo "Could not parse presentation format zone"
+       exit 1
+
+elif ! $PRE/readzone svcb.test-vectors-pf.zone.out > svcb.test-vectors-pf.zone.out.out
+then
+       echo "Could not parse output from presentation format zone"
+       exit 1
+
+elif ! $PRE/readzone svcb.test-vectors-wf.zone > svcb.test-vectors-wf.zone.out
+then
+       echo "Could not parse RFC3597 formatted zone"
+       exit 1
+
+elif ! $PRE/readzone svcb.test-vectors-wf.zone.out > svcb.test-vectors-wf.zone.out.out
+then
+       echo "Could not parse output from RFC3597 formatted zone"
+       exit 1
+else
+       echo "All test zones parsed successfully"
+fi
+
+
+# check the formatting of the written files
+if ! diff svcb.test-vectors-pf.zone.out svcb.test-vectors-pf.zone.out.out
+then
+       echo "Parsing inconsistency 1"
+       exit 1
+
+elif ! diff svcb.test-vectors-pf.zone.out svcb.test-vectors-wf.zone.out
+then
+       echo "Parsing inconsistency 2"
+       exit 1
+
+elif ! diff svcb.test-vectors-pf.zone.out svcb.test-vectors-wf.zone.out.out
+then
+       echo "Parsing inconsistency 3"
+       exit 1
+else
+       echo "Parsing of SVCB and HTTPS was consistent"
+fi
+
+
+# check all the failure cases
+if  svcb.failure-cases-01
+then
+       echo "Failure case 1: Multiple instances of the same SvcParamKey"
+       echo "Incorrectly succeeded"
+       exit 1
+
+elif $PRE/readzone svcb.failure-cases-02
+then
+       echo "Failure case 2: a SvcParamKey is missing a value"
+       echo "Incorrectly succeeded"
+       exit 1
+
+elif $PRE/readzone svcb.failure-cases-03
+then
+       echo "Failure case 3: a SvcParamKey is missing a value"
+       echo "Incorrectly succeeded"
+       exit 1
+
+elif $PRE/readzone svcb.failure-cases-04
+then
+       echo "Failure case 4: a SvcParamKey is missing a value"
+       echo "Incorrectly succeeded"
+       exit 1
+
+elif $PRE/readzone svcb.failure-cases-05
+then
+       echo "Failure case 5: a SvcParamKey is missing a value"
+       echo "Incorrectly succeeded"
+       exit 1
+
+elif $PRE/readzone svcb.failure-cases-06
+then
+       echo "Failure case 6: a SvcParamKey is missing a value"
+       echo "Incorrectly succeeded"
+       exit 1
+
+elif $PRE/readzone svcb.failure-cases-07
+then
+       echo "Failure case 7: The \no-default-alpn\" SvcParamKey value MUST be empty
+       echo "Incorrectly succeeded"
+       exit 1
+
+elif $PRE/readzone svcb.failure-cases-08
+then
+       echo "Failure case 8: a mandatory SvcParam is missing"
+       echo "Incorrectly succeeded"
+       exit 1
+
+elif $PRE/readzone svcb.failure-cases-09
+then
+       echo "Failure case 9: The \"mandatory\" SvcParamKey MUST not be included in mandatory list"
+       echo "Incorrectly succeeded"
+       exit 1
+
+elif $PRE/readzone svcb.failure-cases-10
+then
+       echo "Failure case 10: multiple instances of the same SvcParamKey in the mandatory list"
+       echo "Incorrectly succeeded"
+       exit 1
+
+elif $PRE/readzone svcb.failure-cases-11
+then
+       echo "Failure case 11: Multiple instances of the same SvcParamKey"
+       echo "Incorrectly succeeded"
+       exit 1
+
+elif $PRE/readzone svcb.failure-cases-12
+then
+       echo "Failure case 12: a SvcParamKey is missing a value"
+       echo "Incorrectly succeeded"
+       exit 1
+
+elif $PRE/readzone svcb.failure-cases-13
+then
+       echo "Failure case 13: a SvcParamKey is missing a value"
+       echo "Incorrectly succeeded"
+       exit 1
+
+elif $PRE/readzone svcb.failure-cases-14
+then
+       echo "Failure case 14: a SvcParamKey is missing a value"
+       echo "Incorrectly succeeded"
+       exit 1
+
+elif $PRE/readzone svcb.failure-cases-15
+then
+       echo "Failure case 15: a SvcParamKey is missing a value"
+       echo "Incorrectly succeeded"
+       exit 1
+
+elif $PRE/readzone svcb.failure-cases-16
+then
+       echo "Failure case 16: a SvcParamKey is missing a value"
+       echo "Incorrectly succeeded"
+       exit 1
+
+elif $PRE/readzone svcb.failure-cases-17
+then
+       echo "Failure case 17: The \no-default-alpn\" SvcParamKey value MUST be empty
+       echo "Incorrectly succeeded"
+       exit 1
+
+elif $PRE/readzone svcb.failure-cases-18
+then
+       echo "Failure case 18: a mandatory SvcParam is missing"
+       echo "Incorrectly succeeded"
+       exit 1
+
+elif $PRE/readzone svcb.failure-cases-19
+then
+       echo "Failure case 19: The \"mandatory\" SvcParamKey MUST not be included in mandatory list"
+       echo "Incorrectly succeeded"
+       exit 1
+
+elif $PRE/readzone svcb.failure-cases-20
+then
+       echo "Failure case 20: multiple instances of the same SvcParamKey in the mandatory list"
+       echo "Incorrectly succeeded"
+       exit 1
+
+elif $PRE/readzone svcb.failure-cases-21
+then
+       echo "Failure case 21: ech value is not base64 encoded"
+       echo "Incorrectly succeeded"
+       exit 1
+
+elif $PRE/readzone svcb.failure-cases-22
+then
+       echo "Failure case 22: port value needs to be a positive integer < 65536"
+       echo "Incorrectly succeeded"
+       exit 1
+else
+       echo "All failure cases test successfully"
+fi
+
+
+# check all the succes and write them
+if ! $PRE/nsd-checkzone -p success-cases svcb.success-cases.zone > svcb.success-cases.zone.out
+then
+       echo "Some particular success cases did not succeed to parse"
+       exit 1
+
+elif ! diff svcb.success-cases.zone.out svcb.success-cases.zone.cmp
+then
+       echo "Some success cases could not be printed"
+       exit 1
+else
+       echo "All particular success cases parsed and printed successfully"
+fi
+
+
+rem $PRE/nsd-control -c svcb.secondary.conf write
+rem while [ ! -f test-vectors-secondary.zone ]
+rem do
+rem    sleep 1
+rem done
+rem while ! grep '^v20' test-vectors-secondary.zone
+rem do
+rem    sleep 1
+rem done
+rem grep -v '^;' svcb.test-vectors-pf.zone.out > svcb.test-vectors-pf.zone.out2
+rem grep -v '^;' test-vectors-secondary.zone > test-vectors-secondary.zone.out
+rem if ! diff svcb.test-vectors-pf.zone.out2 test-vectors-secondary.zone.out
+rem then
+rem    echo "Output from secondary did not match output from primary"
+rem    exit 1
+rem else
+rem    echo "Output from secondary did match output from primary"
+rem fi
+
+rem dig @127.0.0.1 -p $TPKG_SEC_PORT f01.failure-cases. TYPE64 > f01.failure-cases.out
+rem if grep 'status: NOERROR' f01.failure-cases.out
+rem then
+rem    echo "Failure case 1: Multiple instances of the same SvcParamKey"
+rem    echo "allowed for secondary"
+rem else
+rem    echo "Could not load failure-cases zone in secondary"
+rem    exit  1
+rem fi
+
diff --git a/testdata/svcb.tdir/svcb.test-vectors-pf.zone b/testdata/svcb.tdir/svcb.test-vectors-pf.zone
new file mode 100644 (file)
index 0000000..d2cb508
--- /dev/null
@@ -0,0 +1,92 @@
+$ORIGIN test-vectors.
+$TTL 3600
+
+@      SOA     primary admin 1 3600 1800 7200 3600
+
+       NS      primary
+primary        A       127.0.0.1
+; D.1. AliasForm
+
+v01    SVCB    0 foo.example.com.
+
+; D.2. ServiceForm
+; The first form is the simple "use the ownername".
+
+v02    SVCB    1 .
+
+; This vector only has a port.
+
+v03    SVCB    16 foo.example.com. port=53
+
+; This example has a key that is not registered, its value is unquoted.
+
+v04    SVCB    1 foo.example.com. key667=hello
+
+; This example has a key that is not registered, its value is quoted and
+; contains a decimal-escaped character.
+
+v05    SVCB    1 foo.example.com. key667="hello\210qoo"
+
+; Here, two IPv6 hints are quoted in the presentation format.
+
+v06    SVCB    1 foo.example.com. ipv6hint="2001:db8::1,2001:db8::53:1"
+
+; This example shows a single IPv6 hint in IPv4 mapped IPv6 presentation format.
+
+v07    SVCB    1 example.com. ipv6hint="2001:db8:ffff:ffff:ffff:ffff:198.51.100.100"
+
+; In the next vector, neither the SvcParamValues nor the mandatory keys are
+; sorted in presentation format, but are correctly sorted in the wire-format.
+
+v08    SVCB    16 foo.example.org. (alpn=h2,h3-19 mandatory=ipv4hint,alpn
+                    ipv4hint=192.0.2.1)
+
+; This last (two) vectors has an alpn value with an escaped comma and an
+; escaped backslash in two presentation formats.
+
+v09    SVCB    16 foo.example.org. alpn="f\\\\oo\\,bar,h2"
+v10    SVCB    16 foo.example.org. alpn=f\\\092oo\092,bar,h2
+
+
+; D.1. AliasForm
+
+v11    HTTPS   0 foo.example.com.
+
+; D.2. ServiceForm
+; The first form is the simple "use the ownername".
+
+v12    HTTPS   1 .
+
+; This vector only has a port.
+
+v13    HTTPS   16 foo.example.com. port=53
+
+; This example has a key that is not registered, its value is unquoted.
+
+v14    HTTPS   1 foo.example.com. key667=hello
+
+; This example has a key that is not registered, its value is quoted and
+; contains a decimal-escaped character.
+
+v15    HTTPS   1 foo.example.com. key667="hello\210qoo"
+
+; Here, two IPv6 hints are quoted in the presentation format.
+
+v16    HTTPS   1 foo.example.com. ipv6hint="2001:db8::1,2001:db8::53:1"
+
+; This example shows a single IPv6 hint in IPv4 mapped IPv6 presentation format.
+
+v17    HTTPS   1 example.com. ipv6hint="2001:db8:ffff:ffff:ffff:ffff:198.51.100.100"
+
+; In the next vector, neither the SvcParamValues nor the mandatory keys are
+; sorted in presentation format, but are correctly sorted in the wire-format.
+
+v18    HTTPS   16 foo.example.org. (alpn=h2,h3-19 mandatory=ipv4hint,alpn
+                    ipv4hint=192.0.2.1)
+
+; This last (two) vectors has an alpn value with an escaped comma and an
+; escaped backslash in two presentation formats.
+
+v19    HTTPS   16 foo.example.org. alpn="f\\\\oo\\,bar,h2"
+v20    HTTPS   16 foo.example.org. alpn=f\\\092oo\092,bar,h2
+
diff --git a/testdata/svcb.tdir/svcb.test-vectors-wf.zone b/testdata/svcb.tdir/svcb.test-vectors-wf.zone
new file mode 100644 (file)
index 0000000..bf47ab7
--- /dev/null
@@ -0,0 +1,232 @@
+$ORIGIN test-vectors.
+$TTL 3600
+
+@      SOA     primary admin 1 3600 1800 7200 3600
+
+       NS      primary
+primary        A       127.0.0.1
+
+; D.1. AliasForm
+
+v01    SVCB    \# 19 (
+00 00                                              ; priority
+03 66 6f 6f 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00 ; target
+)
+
+; D.2. ServiceForm
+; The first form is the simple "use the ownername".
+
+v02    SVCB    \# 3 (
+00 01      ; priority
+00         ; target (root label)
+)
+
+; This vector only has a port.
+
+v03    SVCB    \# 25 (
+00 10                                              ; priority
+03 66 6f 6f 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00 ; target
+00 03                                              ; key 3
+00 02                                              ; length 2
+00 35                                              ; value
+)
+
+; This example has a key that is not registered, its value is unquoted.
+
+v04    SVCB    \# 28 (
+00 01                                              ; priority
+03 66 6f 6f 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00 ; target
+02 9b                                              ; key 667
+00 05                                              ; length 5
+68 65 6c 6c 6f                                     ; value
+)
+
+; This example has a key that is not registered, its value is quoted and
+; contains a decimal-escaped character.
+
+v05    SVCB    \# 32 (
+00 01                                              ; priority
+03 66 6f 6f 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00 ; target
+02 9b                                              ; key 667
+00 09                                              ; length 9
+68 65 6c 6c 6f d2 71 6f 6f                         ; value
+)
+
+; Here, two IPv6 hints are quoted in the presentation format.
+
+v06    SVCB    \# 55 (
+00 01                                              ; priority
+03 66 6f 6f 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00 ; target
+00 06                                              ; key 6
+00 20                                              ; length 32
+20 01 0d b8 00 00 00 00 00 00 00 00 00 00 00 01    ; first address
+20 01 0d b8 00 00 00 00 00 00 00 00 00 53 00 01    ; second address
+)
+
+; This example shows a single IPv6 hint in IPv4 mapped IPv6 presentation format.
+
+v07    SVCB    \# 35 (
+00 01                                              ; priority
+07 65 78 61 6d 70 6c 65 03 63 6f 6d 00             ; target
+00 06                                              ; key 6
+00 10                                              ; length 16
+20 01 0d b8 ff ff ff ff ff ff ff ff c6 33 64 64    ; address
+)
+
+; In the next vector, neither the SvcParamValues nor the mandatory keys are
+; sorted in presentation format, but are correctly sorted in the wire-format.
+
+v08    SVCB    \# 48 (
+00 10                                              ; priority
+03 66 6f 6f 07 65 78 61 6d 70 6c 65 03 6f 72 67 00 ; target
+00 00                                              ; key 0
+00 04                                              ; param length 4
+00 01                                              ; value: key 1
+00 04                                              ; value: key 4
+00 01                                              ; key 1
+00 09                                              ; param length 9
+02                                                 ; alpn length 2
+68 32                                              ; alpn value
+05                                                 ; alpn length 5
+68 33 2d 31 39                                     ; alpn value
+00 04                                              ; key 4
+00 04                                              ; param length 4
+c0 00 02 01                                        ; param value
+)
+
+; This last (two) vectors has an alpn value with an escaped comma and an
+; escaped backslash in two presentation formats.
+
+v09    SVCB    \# 35 (
+00 10                                              ; priority
+03 66 6f 6f 07 65 78 61 6d 70 6c 65 03 6f 72 67 00 ; target
+00 01                                              ; key 1
+00 0c                                              ; param length 12
+08                                                 ; alpn length 8
+66 5c 6f 6f 2c 62 61 72                            ; alpn value
+02                                                 ; alpn length 2
+68 32                                              ; alpn value
+)
+v10    SVCB    \# 35 (
+00 10                                              ; priority
+03 66 6f 6f 07 65 78 61 6d 70 6c 65 03 6f 72 67 00 ; target
+00 01                                              ; key 1
+00 0c                                              ; param length 12
+08                                                 ; alpn length 8
+66 5c 6f 6f 2c 62 61 72                            ; alpn value
+02                                                 ; alpn length 2
+68 32                                              ; alpn value
+)
+
+; D.1. AliasForm
+
+v11    HTTPS   \# 19 (
+00 00                                              ; priority
+03 66 6f 6f 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00 ; target
+)
+
+; D.2. ServiceForm
+; The first form is the simple "use the ownername".
+
+v12    HTTPS   \# 3 (
+00 01      ; priority
+00         ; target (root label)
+)
+
+; This vector only has a port.
+
+v13    HTTPS   \# 25 (
+00 10                                              ; priority
+03 66 6f 6f 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00 ; target
+00 03                                              ; key 3
+00 02                                              ; length 2
+00 35                                              ; value
+)
+
+; This example has a key that is not registered, its value is unquoted.
+
+v14    HTTPS   \# 28 (
+00 01                                              ; priority
+03 66 6f 6f 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00 ; target
+02 9b                                              ; key 667
+00 05                                              ; length 5
+68 65 6c 6c 6f                                     ; value
+)
+
+; This example has a key that is not registered, its value is quoted and
+; contains a decimal-escaped character.
+
+v15    HTTPS   \# 32 (
+00 01                                              ; priority
+03 66 6f 6f 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00 ; target
+02 9b                                              ; key 667
+00 09                                              ; length 9
+68 65 6c 6c 6f d2 71 6f 6f                         ; value
+)
+
+; Here, two IPv6 hints are quoted in the presentation format.
+
+v16    HTTPS   \# 55 (
+00 01                                              ; priority
+03 66 6f 6f 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00 ; target
+00 06                                              ; key 6
+00 20                                              ; length 32
+20 01 0d b8 00 00 00 00 00 00 00 00 00 00 00 01    ; first address
+20 01 0d b8 00 00 00 00 00 00 00 00 00 53 00 01    ; second address
+)
+
+; This example shows a single IPv6 hint in IPv4 mapped IPv6 presentation format.
+
+v17    HTTPS   \# 35 (
+00 01                                              ; priority
+07 65 78 61 6d 70 6c 65 03 63 6f 6d 00             ; target
+00 06                                              ; key 6
+00 10                                              ; length 16
+20 01 0d b8 ff ff ff ff ff ff ff ff c6 33 64 64    ; address
+)
+
+; In the next vector, neither the SvcParamValues nor the mandatory keys are
+; sorted in presentation format, but are correctly sorted in the wire-format.
+
+v18    HTTPS   \# 48 (
+00 10                                              ; priority
+03 66 6f 6f 07 65 78 61 6d 70 6c 65 03 6f 72 67 00 ; target
+00 00                                              ; key 0
+00 04                                              ; param length 4
+00 01                                              ; value: key 1
+00 04                                              ; value: key 4
+00 01                                              ; key 1
+00 09                                              ; param length 9
+02                                                 ; alpn length 2
+68 32                                              ; alpn value
+05                                                 ; alpn length 5
+68 33 2d 31 39                                     ; alpn value
+00 04                                              ; key 4
+00 04                                              ; param length 4
+c0 00 02 01                                        ; param value
+)
+
+; This last (two) vectors has an alpn value with an escaped comma and an
+; escaped backslash in two presentation formats.
+
+v19    HTTPS   \# 35 (
+00 10                                              ; priority
+03 66 6f 6f 07 65 78 61 6d 70 6c 65 03 6f 72 67 00 ; target
+00 01                                              ; key 1
+00 0c                                              ; param length 12
+08                                                 ; alpn length 8
+66 5c 6f 6f 2c 62 61 72                            ; alpn value
+02                                                 ; alpn length 2
+68 32                                              ; alpn value
+)
+v20    HTTPS   \# 35 (
+00 10                                              ; priority
+03 66 6f 6f 07 65 78 61 6d 70 6c 65 03 6f 72 67 00 ; target
+00 01                                              ; key 1
+00 0c                                              ; param length 12
+08                                                 ; alpn length 8
+66 5c 6f 6f 2c 62 61 72                            ; alpn value
+02                                                 ; alpn length 2
+68 32                                              ; alpn value
+)
+