diff --git a/scripts/clang-format.sh b/scripts/clang-format.sh index 98cea32..e00d7d7 100755 --- a/scripts/clang-format.sh +++ b/scripts/clang-format.sh @@ -5,4 +5,4 @@ set -u cd "$( dirname "$0" )/.." -find src/ include/ tests/mock/ tests/integration/ -iname '*.hpp' -o -iname '*.h' -o -iname '*.cpp' | xargs clang-format -i +find src/ include/ tests/mock/ tests/integration/ tests/common/ -iname '*.hpp' -o -iname '*.h' -o -iname '*.cpp' | xargs clang-format -i diff --git a/tests/common/selectcard.hpp b/tests/common/selectcard.hpp index 892c753..74ba8f1 100644 --- a/tests/common/selectcard.hpp +++ b/tests/common/selectcard.hpp @@ -3,8 +3,10 @@ #include "electronic-id/electronic-id.hpp" #include +#include -inline electronic_id::ElectronicID::ptr autoSelectSupportedCard() { +inline electronic_id::ElectronicID::ptr autoSelectSupportedCard() +{ using namespace electronic_id; auto cardList = availableSupportedCards(); @@ -12,5 +14,16 @@ inline electronic_id::ElectronicID::ptr autoSelectSupportedCard() { throw std::logic_error("test::autoSelectSupportedCard(): No smart cards attached"); } - return cardList[0]; + return cardList[0]; +} + +inline void printCardInfo(const electronic_id::ElectronicID& eid) +{ + std::cout << "Selected card: " << eid.name() << '\n'; +#ifdef _WIN32 + std::wcout << L"Card reader: " << eid.smartcard().readerName() << L'\n'; +#else + std::cout << "Card reader: " << eid.smartcard().readerName() << '\n'; +#endif + std::cout << "Protocol: " << static_cast(eid.smartcard().protocol()) << '\n'; } diff --git a/tests/common/verify.hpp b/tests/common/verify.hpp index 65164e9..de2b7f3 100644 --- a/tests/common/verify.hpp +++ b/tests/common/verify.hpp @@ -1,24 +1,24 @@ /* -* Copyright (c) 2020-2024 Estonian Information System Authority -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in all -* copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -*/ + * Copyright (c) 2020-2024 Estonian Information System Authority + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ #pragma once diff --git a/tests/integration/test-authenticate.cpp b/tests/integration/test-authenticate.cpp index 88ab487..d37117a 100644 --- a/tests/integration/test-authenticate.cpp +++ b/tests/integration/test-authenticate.cpp @@ -25,8 +25,6 @@ #include "gtest/gtest.h" -#include - TEST(electronic_id_test, authenticate) { using namespace electronic_id; @@ -36,7 +34,7 @@ TEST(electronic_id_test, authenticate) EXPECT_TRUE(cardInfo); - std::cout << "Selected card: " << cardInfo->name() << '\n'; + printCardInfo(*cardInfo); byte_vector cert = cardInfo->getCertificate(CertificateType::AUTHENTICATION); diff --git a/tests/integration/test-get-certificate.cpp b/tests/integration/test-get-certificate.cpp index 391b895..7b1d294 100644 --- a/tests/integration/test-get-certificate.cpp +++ b/tests/integration/test-get-certificate.cpp @@ -24,8 +24,6 @@ #include "gtest/gtest.h" -#include - using namespace pcsc_cpp; TEST(electronic_id_test, getCertificate) @@ -36,7 +34,7 @@ TEST(electronic_id_test, getCertificate) EXPECT_TRUE(cardInfo); - std::cout << "Selected card: " << cardInfo->name() << '\n'; + printCardInfo(*cardInfo); auto certificate = cardInfo->getCertificate(CertificateType::AUTHENTICATION); diff --git a/tests/integration/test-signing.cpp b/tests/integration/test-signing.cpp index 0b78585..709e99d 100644 --- a/tests/integration/test-signing.cpp +++ b/tests/integration/test-signing.cpp @@ -26,7 +26,6 @@ #include "gtest/gtest.h" #include -#include using namespace electronic_id; using namespace pcsc_cpp; @@ -37,7 +36,7 @@ static void signing(HashAlgorithm hashAlgo) EXPECT_TRUE(cardInfo); - std::cout << "Selected card: " << cardInfo->name() << '\n'; + printCardInfo(*cardInfo); if (!cardInfo->isSupportedSigningHashAlgorithm(hashAlgo)) { std::string skip = "Card does not support hashing algorithm: " + std::string(hashAlgo);