}
lexer.ungetToken();
- // missing digest data is okay
- if (digest_txt.size() > 0) {
- decodeBase64(digest_txt, digest_);
+ if (digest_txt.size() == 0) {
+ isc_throw(InvalidRdataText, "Missing DHCID RDATA");
}
+
+ decodeBase64(digest_txt, digest_);
}
/// \brief Constructor from string.
/// The \c lexer should point to the beginning of valid textual representation
/// of a DHCID RDATA.
///
-/// \throw MasterLexer::LexerError General parsing error such as missing field.
+/// \throw InvalidRdataText on empty string.
+/// \throw BadValue if the text is not valid base-64.
+/// \throw MasterLexer::LexerError General parsing error.
///
/// \param lexer A \c MasterLexer object parsing a master file for the
/// RDATA to be created
rdata_str, rdata_dhcid, false, false);
}
- void checkFromText_InvalidLength(const string& rdata_str) {
- checkFromText<in::DHCID, InvalidRdataLength, InvalidRdataLength>(
+ void checkFromText_InvalidText(const string& rdata_str) {
+ checkFromText<in::DHCID, InvalidRdataText, InvalidRdataText>(
rdata_str, rdata_dhcid, true, true);
}
TEST_F(Rdata_DHCID_Test, fromText) {
EXPECT_EQ(dhcid_txt, rdata_dhcid.toText());
- // missing digest data is okay
- EXPECT_NO_THROW(const in::DHCID digest(""));
-
// Space in digest data is OK
checkFromText_None(
"0LIg0LvQtdGB0YMg 0YDQvtC00LjQu9Cw 0YHRjCDRkdC70L7R h9C60LA=");
}
TEST_F(Rdata_DHCID_Test, badText) {
+ // missing digest data
+ checkFromText_InvalidText("");
+
+ // invalid base64
checkFromText_BadValue("EEeeeeeeEEEeeeeeeGaaahAAAAAAAAHHHHHHHHHHH!=");
// unterminated multi-line base64