From 81d4594e7869eeb08bb0a938eba92c886941a6a6 Mon Sep 17 00:00:00 2001 From: Siebren Weertman Date: Mon, 26 Feb 2024 13:36:11 +0000 Subject: [PATCH] Also test sig in other libs --- .../unit/xmldsig/test_SignedInfo_Fragment.cpp | 49 ++++++++++++++----- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/tests/unit/xmldsig/test_SignedInfo_Fragment.cpp b/tests/unit/xmldsig/test_SignedInfo_Fragment.cpp index a68862b..9101fb3 100644 --- a/tests/unit/xmldsig/test_SignedInfo_Fragment.cpp +++ b/tests/unit/xmldsig/test_SignedInfo_Fragment.cpp @@ -13,7 +13,7 @@ class Test_SignedInfo_Fragment : public testing::Test { using Document_t = XmlFragmentDocT; uint8_t m_data[512] = {0}; exi_bitstream_t m_stream; - int encode_xmldsigFragment(exi_bitstream_t* stream, Document_t*); + virtual int encode_xmldsigFragment(exi_bitstream_t* stream, void* document) = 0; template static void setExiStr(StrT& out, std::string_view setStr) { @@ -26,16 +26,8 @@ class Test_SignedInfo_Fragment : public testing::Test { out.bytesLen = Len - 1; memcpy(out.bytes, setStr, Len - 1); } + void WhenEncodingKnownSupportedAppProtocolRequest_ThenResultMatchesExpected(); }; -class Test_SignedInfo_Fragment_ISO2: public Test_SignedInfo_Fragment { -protected: - int encode_xmldsigFragment(exi_bitstream_t* stream, Document_t* document) - { - return encode_iso2_xmldsigFragment(stream, document); - } -}; - - /** \brief Fragment encode * \param xml_input @@ -59,7 +51,8 @@ class Test_SignedInfo_Fragment_ISO2: public Test_SignedInfo_Fragment * */ -TEST_F(Test_SignedInfo_Fragment_ISO2, WhenEncodingKnownSupportedAppProtocolRequest_ThenResultMatchesExpected) { +template +void Test_SignedInfo_Fragment::WhenEncodingKnownSupportedAppProtocolRequest_ThenResultMatchesExpected() { static constexpr uint8_t expected[] = "\x80\x81\x12\xb4\x3a\x3a\x38\x1d\x17\x97\xbb\xbb\xbb\x97\x3b\x99\x97\x37\xb9\x33\x97\xaa\x29\x17\xb1\xb0\xb7" "\x37\xb7\x34\xb1\xb0\xb6\x16\xb2\xbc\x34\x97\xa1\xab\x43\xa3\xa3\x81\xd1\x79\x7b\xbb\xbb\xb9\x73\xb9\x99\x73" @@ -116,3 +109,37 @@ TEST_F(Test_SignedInfo_Fragment_ISO2, WhenEncodingKnownSupportedAppProtocolReque const auto memcpyRes = memcmp(m_data, expected, sizeof(expected) - 1); ASSERT_EQ(memcpyRes, 0); } + +class Test_SignedInfo_Fragment_ISO2: public Test_SignedInfo_Fragment { +protected: + int encode_xmldsigFragment(exi_bitstream_t* stream, void* document) final + { + return encode_iso2_xmldsigFragment(stream, (Document_t*)document); + } +}; +class Test_SignedInfo_Fragment_ISO20DC: public Test_SignedInfo_Fragment { +protected: + int encode_xmldsigFragment(exi_bitstream_t* stream, void* document) final + { + return encode_iso20_dc_xmldsigFragment(stream, (Document_t*)document); + } +}; +class Test_SignedInfo_Fragment_ISO20AC: public Test_SignedInfo_Fragment { +protected: + int encode_xmldsigFragment(exi_bitstream_t* stream, void* document) final + { + return encode_iso20_ac_xmldsigFragment(stream, (Document_t*)document); + } +}; + +TEST_F(Test_SignedInfo_Fragment_ISO2, WhenEncodingKnownSupportedAppProtocolRequest_ThenResultMatchesExpected) { + WhenEncodingKnownSupportedAppProtocolRequest_ThenResultMatchesExpected(); +} + +TEST_F(Test_SignedInfo_Fragment_ISO20AC, WhenEncodingKnownSupportedAppProtocolRequest_ThenResultMatchesExpected) { + WhenEncodingKnownSupportedAppProtocolRequest_ThenResultMatchesExpected(); +} + +TEST_F(Test_SignedInfo_Fragment_ISO20DC, WhenEncodingKnownSupportedAppProtocolRequest_ThenResultMatchesExpected) { + WhenEncodingKnownSupportedAppProtocolRequest_ThenResultMatchesExpected(); +}