Parcourir la source

[2124] Add some more wire data tests

Mukund Sivaraman il y a 13 ans
Parent
commit
5e7af00c87

+ 21 - 1
src/lib/dns/tests/rdata_sshfp_unittest.cc

@@ -105,7 +105,27 @@ TEST_F(Rdata_SSHFP_Test, createFromWire) {
     EXPECT_EQ(0, rdata_sshfp.compare(
                   *rdataFactoryFromFile(RRType("SSHFP"), RRClass("IN"),
                                         "rdata_sshfp_fromWire2")));
-    // TBD: more tests
+    // algorithm=1, fingerprint=1
+    EXPECT_NO_THROW(rdataFactoryFromFile(RRType("SSHFP"), RRClass("IN"),
+                                         "rdata_sshfp_fromWire3.wire"));
+
+    // algorithm=255, fingerprint=1
+    EXPECT_NO_THROW(rdataFactoryFromFile(RRType("SSHFP"), RRClass("IN"),
+                                         "rdata_sshfp_fromWire4.wire"));
+
+    // algorithm=0, fingerprint=1
+    EXPECT_THROW(rdataFactoryFromFile(RRType("SSHFP"), RRClass("IN"),
+                                      "rdata_sshfp_fromWire5.wire"),
+                 InvalidRdataText);
+
+    // algorithm=5, fingerprint=0
+    EXPECT_THROW(rdataFactoryFromFile(RRType("SSHFP"), RRClass("IN"),
+                                      "rdata_sshfp_fromWire6.wire"),
+                 InvalidRdataText);
+
+    // algorithm=255, fingerprint=255
+    EXPECT_NO_THROW(rdataFactoryFromFile(RRType("SSHFP"), RRClass("IN"),
+                                         "rdata_sshfp_fromWire7.wire"));
 }
 
 TEST_F(Rdata_SSHFP_Test, toText) {

+ 5 - 0
src/lib/dns/tests/testdata/.gitignore

@@ -79,6 +79,11 @@
 /rdata_soa_toWireUncompressed.wire
 /rdata_sshfp_fromWire1.wire
 /rdata_sshfp_fromWire2.wire
+/rdata_sshfp_fromWire3.wire
+/rdata_sshfp_fromWire4.wire
+/rdata_sshfp_fromWire5.wire
+/rdata_sshfp_fromWire6.wire
+/rdata_sshfp_fromWire7.wire
 /rdata_tsig_fromWire1.wire
 /rdata_tsig_fromWire2.wire
 /rdata_tsig_fromWire3.wire

+ 6 - 0
src/lib/dns/tests/testdata/Makefile.am

@@ -45,6 +45,9 @@ BUILT_SOURCES += rdata_rp_fromWire3.wire rdata_rp_fromWire4.wire
 BUILT_SOURCES += rdata_rp_fromWire5.wire rdata_rp_fromWire6.wire
 BUILT_SOURCES += rdata_rp_toWire1.wire rdata_rp_toWire2.wire
 BUILT_SOURCES += rdata_sshfp_fromWire1.wire rdata_sshfp_fromWire2.wire
+BUILT_SOURCES += rdata_sshfp_fromWire3.wire rdata_sshfp_fromWire4.wire
+BUILT_SOURCES += rdata_sshfp_fromWire5.wire rdata_sshfp_fromWire6.wire
+BUILT_SOURCES += rdata_sshfp_fromWire7.wire
 BUILT_SOURCES += rdata_afsdb_fromWire1.wire rdata_afsdb_fromWire2.wire
 BUILT_SOURCES += rdata_afsdb_fromWire3.wire rdata_afsdb_fromWire4.wire
 BUILT_SOURCES += rdata_afsdb_fromWire5.wire
@@ -129,6 +132,9 @@ EXTRA_DIST += rdata_rp_fromWire5.spec rdata_rp_fromWire6.spec
 EXTRA_DIST += rdata_rp_toWire1.spec rdata_rp_toWire2.spec
 EXTRA_DIST += rdata_sshfp_fromWire rdata_sshfp_fromWire2
 EXTRA_DIST += rdata_sshfp_fromWire1.spec rdata_sshfp_fromWire2.spec
+EXTRA_DIST += rdata_sshfp_fromWire3.spec rdata_sshfp_fromWire4.spec
+EXTRA_DIST += rdata_sshfp_fromWire5.spec rdata_sshfp_fromWire6.spec
+EXTRA_DIST += rdata_sshfp_fromWire7.spec
 EXTRA_DIST += rdata_afsdb_fromWire1.spec rdata_afsdb_fromWire2.spec
 EXTRA_DIST += rdata_afsdb_fromWire3.spec rdata_afsdb_fromWire4.spec
 EXTRA_DIST += rdata_afsdb_fromWire5.spec

+ 9 - 0
src/lib/dns/tests/testdata/rdata_sshfp_fromWire3.spec

@@ -0,0 +1,9 @@
+#
+# SSHFP RDATA
+#
+[custom]
+sections: sshfp
+[sshfp]
+fingerprint: 123456789abcdef67890123456789abcdef67890
+algorithm: 1
+fingerprint_type: 1

+ 9 - 0
src/lib/dns/tests/testdata/rdata_sshfp_fromWire4.spec

@@ -0,0 +1,9 @@
+#
+# SSHFP RDATA
+#
+[custom]
+sections: sshfp
+[sshfp]
+fingerprint: 123456789abcdef67890123456789abcdef67890
+algorithm: 255
+fingerprint_type: 1

+ 9 - 0
src/lib/dns/tests/testdata/rdata_sshfp_fromWire5.spec

@@ -0,0 +1,9 @@
+#
+# SSHFP RDATA
+#
+[custom]
+sections: sshfp
+[sshfp]
+fingerprint: 123456789abcdef67890123456789abcdef67890
+algorithm: 0
+fingerprint_type: 1

+ 9 - 0
src/lib/dns/tests/testdata/rdata_sshfp_fromWire6.spec

@@ -0,0 +1,9 @@
+#
+# SSHFP RDATA
+#
+[custom]
+sections: sshfp
+[sshfp]
+fingerprint: 123456789abcdef67890123456789abcdef67890
+algorithm: 5
+fingerprint_type: 0

+ 9 - 0
src/lib/dns/tests/testdata/rdata_sshfp_fromWire7.spec

@@ -0,0 +1,9 @@
+#
+# SSHFP RDATA
+#
+[custom]
+sections: sshfp
+[sshfp]
+fingerprint: 123456789abcdef67890123456789abcdef67890
+algorithm: 255
+fingerprint_type: 255