|
@@ -1,4 +1,4 @@
|
|
|
-// Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
|
|
|
+// Copyright (C) 2012-2013 Internet Systems Consortium, Inc. ("ISC")
|
|
|
//
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
@@ -30,17 +30,45 @@
|
|
|
|
|
|
using isc::UnitTestUtil;
|
|
|
using namespace std;
|
|
|
+using namespace isc;
|
|
|
using namespace isc::dns;
|
|
|
using namespace isc::util;
|
|
|
using namespace isc::dns::rdata;
|
|
|
|
|
|
namespace {
|
|
|
class Rdata_SSHFP_Test : public RdataTest {
|
|
|
- // there's nothing to specialize
|
|
|
+protected:
|
|
|
+ Rdata_SSHFP_Test() :
|
|
|
+ sshfp_txt("2 1 123456789abcdef67890123456789abcdef67890"),
|
|
|
+ rdata_sshfp(sshfp_txt)
|
|
|
+ {}
|
|
|
+
|
|
|
+ void checkFromText_None(const string& rdata_str) {
|
|
|
+ checkFromText<generic::SSHFP, isc::Exception, isc::Exception>(
|
|
|
+ rdata_str, rdata_sshfp, false, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ void checkFromText_LexerError(const string& rdata_str) {
|
|
|
+ checkFromText
|
|
|
+ <generic::SSHFP, InvalidRdataText, MasterLexer::LexerError>(
|
|
|
+ rdata_str, rdata_sshfp, true, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ void checkFromText_BadValue(const string& rdata_str) {
|
|
|
+ checkFromText<generic::SSHFP, InvalidRdataText, BadValue>(
|
|
|
+ rdata_str, rdata_sshfp, true, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ void checkFromText_BadString(const string& rdata_str) {
|
|
|
+ checkFromText
|
|
|
+ <generic::SSHFP, InvalidRdataText, isc::Exception>(
|
|
|
+ rdata_str, rdata_sshfp, true, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ const string sshfp_txt;
|
|
|
+ const generic::SSHFP rdata_sshfp;
|
|
|
};
|
|
|
|
|
|
-const string sshfp_txt("2 1 123456789abcdef67890123456789abcdef67890");
|
|
|
-const generic::SSHFP rdata_sshfp(2, 1, "123456789abcdef67890123456789abcdef67890");
|
|
|
const uint8_t rdata_sshfp_wiredata[] = {
|
|
|
// algorithm
|
|
|
0x02,
|
|
@@ -56,22 +84,13 @@ const uint8_t rdata_sshfp_wiredata[] = {
|
|
|
|
|
|
TEST_F(Rdata_SSHFP_Test, createFromText) {
|
|
|
// Basic test
|
|
|
- const generic::SSHFP rdata_sshfp2(sshfp_txt);
|
|
|
- EXPECT_EQ(0, rdata_sshfp2.compare(rdata_sshfp));
|
|
|
+ checkFromText_None(sshfp_txt);
|
|
|
|
|
|
// With different spacing
|
|
|
- const generic::SSHFP rdata_sshfp3("2 1 123456789abcdef67890123456789abcdef67890");
|
|
|
- EXPECT_EQ(0, rdata_sshfp3.compare(rdata_sshfp));
|
|
|
+ checkFromText_None("2 1 123456789abcdef67890123456789abcdef67890");
|
|
|
|
|
|
// Combination of lowercase and uppercase
|
|
|
- const generic::SSHFP rdata_sshfp4("2 1 123456789ABCDEF67890123456789abcdef67890");
|
|
|
- EXPECT_EQ(0, rdata_sshfp4.compare(rdata_sshfp));
|
|
|
-}
|
|
|
-
|
|
|
-TEST_F(Rdata_SSHFP_Test, createFromLexer) {
|
|
|
- EXPECT_EQ(0, rdata_sshfp.compare(
|
|
|
- *test::createRdataUsingLexer(RRType::SSHFP(), RRClass::IN(),
|
|
|
- sshfp_txt)));
|
|
|
+ checkFromText_None("2 1 123456789ABCDEF67890123456789abcdef67890");
|
|
|
}
|
|
|
|
|
|
TEST_F(Rdata_SSHFP_Test, algorithmTypes) {
|
|
@@ -101,10 +120,11 @@ TEST_F(Rdata_SSHFP_Test, algorithmTypes) {
|
|
|
}
|
|
|
|
|
|
TEST_F(Rdata_SSHFP_Test, badText) {
|
|
|
- EXPECT_THROW(const generic::SSHFP rdata_sshfp("1"), InvalidRdataText);
|
|
|
- EXPECT_THROW(const generic::SSHFP rdata_sshfp("BUCKLE MY SHOES"), InvalidRdataText);
|
|
|
- EXPECT_THROW(const generic::SSHFP rdata_sshfp("1 2 foo"), InvalidRdataText);
|
|
|
- EXPECT_THROW(const generic::SSHFP rdata_sshfp("1 2 12ab bar"), InvalidRdataText);
|
|
|
+ checkFromText_LexerError("1");
|
|
|
+ checkFromText_LexerError("ONE 2 123456789abcdef67890123456789abcdef67890");
|
|
|
+ checkFromText_LexerError("1 TWO 123456789abcdef67890123456789abcdef67890");
|
|
|
+ checkFromText_BadValue("1 2 BUCKLEMYSHOES");
|
|
|
+ checkFromText_BadString(sshfp_txt + " extra text");
|
|
|
}
|
|
|
|
|
|
TEST_F(Rdata_SSHFP_Test, copy) {
|
|
@@ -161,6 +181,16 @@ TEST_F(Rdata_SSHFP_Test, createFromWire) {
|
|
|
InvalidBufferPosition);
|
|
|
}
|
|
|
|
|
|
+TEST_F(Rdata_SSHFP_Test, createFromComponents) {
|
|
|
+ const generic::SSHFP rdata_sshfp2(2, 1, "123456789abcdef67890123456789abcdef67890");
|
|
|
+ EXPECT_EQ(0, rdata_sshfp2.compare(rdata_sshfp));
|
|
|
+}
|
|
|
+
|
|
|
+TEST_F(Rdata_SSHFP_Test, createByCopy) {
|
|
|
+ const generic::SSHFP rdata_sshfp2(rdata_sshfp);
|
|
|
+ EXPECT_EQ(0, rdata_sshfp2.compare(rdata_sshfp));
|
|
|
+}
|
|
|
+
|
|
|
TEST_F(Rdata_SSHFP_Test, toText) {
|
|
|
EXPECT_TRUE(boost::iequals(sshfp_txt, rdata_sshfp.toText()));
|
|
|
|