From: Fred Morcos Date: Tue, 22 Nov 2022 09:56:39 +0000 (+0100) Subject: Cleanup test_generic_signers in test-signers.cc X-Git-Tag: dnsdist-1.8.0-rc1~124^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ba4a5e4c9041b9cf7696c5210e0d39d0f024051;p=thirdparty%2Fpdns.git Cleanup test_generic_signers in test-signers.cc --- diff --git a/pdns/test-signers.cc b/pdns/test-signers.cc index f491ee8fe3..6e27096bb8 100644 --- a/pdns/test-signers.cc +++ b/pdns/test-signers.cc @@ -391,14 +391,16 @@ static void test_generic_signer(std::shared_ptr dcke, DNSKEY auto signature = dcke->sign(message); BOOST_CHECK(dcke->verify(message, signature)); + auto signerSignature = std::string(signer.signature.begin(), signer.signature.end()); if (signer.isDeterministic) { - string b64 = Base64Encode(signature); - BOOST_CHECK_EQUAL(b64, Base64Encode(std::string(signer.signature.begin(), signer.signature.end()))); + auto signatureBase64 = Base64Encode(signature); + auto signerSignatureBase64 = Base64Encode(signerSignature); + BOOST_CHECK_EQUAL(signatureBase64, signerSignatureBase64); } else { /* since the signing process is not deterministic, we can't directly compare our signature with the one we have. Still the one we have should also validate correctly. */ - BOOST_CHECK(dcke->verify(message, std::string(signer.signature.begin(), signer.signature.end()))); + BOOST_CHECK(dcke->verify(message, signerSignature)); } if (!signer.rfcMsgDump.empty() && !signer.rfcB64Signature.empty()) { @@ -415,11 +417,11 @@ BOOST_FIXTURE_TEST_CASE(test_generic_signers, Fixture) auto dcke = std::shared_ptr(DNSCryptoKeyEngine::makeFromISCString(drc, signer.iscMap)); test_generic_signer(dcke, drc, signer, message); - unique_ptr fp{fmemopen((void*)signer.pem.c_str(), signer.pem.length(), "r"), &std::fclose}; - BOOST_REQUIRE(fp.get() != nullptr); + unique_ptr inputFile{fmemopen((void*)signer.pem.c_str(), signer.pem.length(), "r"), &std::fclose}; + BOOST_REQUIRE(inputFile.get() != nullptr); DNSKEYRecordContent pemDRC; - shared_ptr pemKey{DNSCryptoKeyEngine::makeFromPEMFile(pemDRC, "", *fp, signer.algorithm)}; + shared_ptr pemKey{DNSCryptoKeyEngine::makeFromPEMFile(pemDRC, "", *inputFile, signer.algorithm)}; BOOST_CHECK_EQUAL(pemKey->convertToISC(), dcke->convertToISC());