Commit 73080d99 authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

[2124] Don't add trailing space in toText() if fingerprint is empty

Also add some tests.
parent 595b447c
......@@ -128,7 +128,7 @@ string
SSHFP::toText() const {
return (lexical_cast<string>(static_cast<int>(algorithm_)) +
" " + lexical_cast<string>(static_cast<int>(fingerprint_type_)) +
" " + encodeHex(fingerprint_));
(fingerprint_.size() > 0 ? " " + encodeHex(fingerprint_) : ""));
}
int
......
......@@ -156,6 +156,13 @@ TEST_F(Rdata_SSHFP_Test, createFromWire) {
TEST_F(Rdata_SSHFP_Test, toText) {
EXPECT_TRUE(boost::iequals(sshfp_txt, rdata_sshfp.toText()));
const string sshfp_txt2("2 1");
const generic::SSHFP rdata_sshfp2(sshfp_txt2);
EXPECT_TRUE(boost::iequals(sshfp_txt2, rdata_sshfp2.toText()));
const generic::SSHFP rdata_sshfp3("2 1 ");
EXPECT_TRUE(boost::iequals(sshfp_txt2, rdata_sshfp3.toText()));
}
TEST_F(Rdata_SSHFP_Test, toWire) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment