Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Gemalto card support #310

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if(WIN32)
COMMAND ${LIGHT_CMD} -o "${BASE_FILE}.qt.msi"
WORKING_DIRECTORY $<TARGET_FILE_DIR:web-eid>
)
add_custom_target(bundle
add_custom_target(bundle DEPENDS installer
COMMAND "$ENV{WIX}bin\\candle.exe" -nologo -ext WixBalExtension -ext WixUtilExtension -dwebeid="${BASE_FILE}"
-dMSI_VERSION=${PROJECT_VERSION} -dpath="${CMAKE_SOURCE_DIR}/install" "${CMAKE_SOURCE_DIR}/install/plugins.wxs"
COMMAND "$ENV{WIX}bin\\light.exe" "plugins.wixobj" -nologo -ext WixBalExtension -out "${BASE_FILE}.exe"
Expand Down
2 changes: 1 addition & 1 deletion tests/mock-ui/mock-ui.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MockUI : public WebEidUI

QString getPin() override
{
static QString pin {"0090"};
static QString pin {"1234"};
return pin;
}

Expand Down
51 changes: 27 additions & 24 deletions tests/tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "mock-ui.hpp"
#include "getcommandhandler-mock.hpp"

#define NO_SIGNATURE
#include "select-certificate-script.hpp"
#include "atrs.hpp"
#include "changecertificatevaliduntil.hpp"
Expand Down Expand Up @@ -123,22 +124,22 @@ void WebEidTests::getCertificate_validCertificateHasExpectedCertificateSubject()

// assert
const auto certInfo = getCertAndPinInfoFromSignalSpy(certificateReadySpy);
QCOMPARE(certInfo.subject, QStringLiteral("M\u00C4NNIK, MARI-LIIS, 61709210125"));
QCOMPARE(certInfo.subject, QStringLiteral("J\u00D5EORG, JAAK-KRISTJAN, 38001085718"));

const auto certBytes =
QByteArray::fromBase64(controller->result()["certificate"].toString().toUtf8());
const auto certBytes = QByteArray::fromBase64(
controller->result()[QStringLiteral("certificate")].toString().toUtf8());
const auto cert = QSslCertificate(certBytes, QSsl::EncodingFormat::Der);
QVERIFY(!cert.isNull());
QCOMPARE(cert.subjectInfo(QSslCertificate::CommonName)[0],
QStringLiteral("M\u00C4NNIK,MARI-LIIS,61709210125"));
QCOMPARE(cert.subjectInfo(QSslCertificate::CommonName).constFirst(),
QStringLiteral("J\u00D5EORG,JAAK-KRISTJAN,38001085718"));
}

void WebEidTests::getCertificate_expiredCertificateHasExpectedCertificateSubject()
{
// arrange
PcscMock::setAtr(ESTEID_GEMALTO_V3_5_8_COLD_ATR);
PcscMock::setAtr(ESTEID_IDEMIA_V1_ATR);
PcscMock::setApduScript(
replaceCertValidUntilTo2010(ESTEID_GEMALTO_V3_5_8_GET_SIGN_CERTIFICATE_AND_SIGNING));
replaceCertValidUntilTo2010(ESTEID_IDEMIA_V1_SELECT_SIGN_CERTIFICATE_AND_SIGNING));

initGetCert();

Expand All @@ -150,14 +151,14 @@ void WebEidTests::getCertificate_expiredCertificateHasExpectedCertificateSubject

// assert
const auto certInfo = getCertAndPinInfoFromSignalSpy(certificateReadySpy);
QCOMPARE(certInfo.subject, QStringLiteral("M\u00C4NNIK, MARI-LIIS, 61709210125"));
QCOMPARE(certInfo.subject, QStringLiteral("J\u00D5EORG, JAAK-KRISTJAN, 38001085718"));

const auto certBytes =
QByteArray::fromBase64(controller->result()["certificate"].toString().toUtf8());
const auto certBytes = QByteArray::fromBase64(
controller->result()[QStringLiteral("certificate")].toString().toUtf8());
const auto cert = QSslCertificate(certBytes, QSsl::EncodingFormat::Der);
QVERIFY(!cert.isNull());
QCOMPARE(cert.subjectInfo(QSslCertificate::CommonName)[0],
QStringLiteral("M\u00C4NNIK,MARI-LIIS,61709210125"));
QCOMPARE(cert.subjectInfo(QSslCertificate::CommonName).constFirst(),
QStringLiteral("J\u00D5EORG,JAAK-KRISTJAN,38001085718"));
}

void WebEidTests::getCertificate_outputsSupportedAlgos()
Expand All @@ -175,7 +176,9 @@ void WebEidTests::getCertificate_outputsSupportedAlgos()
runEventLoopVerifySignalsEmitted(certificateReadySpy);

// assert
QCOMPARE(controller->result()["supportedSignatureAlgorithms"].toList()[0].toMap(), ES224_ALGO);
QCOMPARE(
controller->result()[QStringLiteral("supportedSignatureAlgorithms")].toList()[0].toMap(),
ES224_ALGO);
}

void WebEidTests::authenticate_validArgumentsResultInValidToken()
Expand All @@ -192,15 +195,15 @@ void WebEidTests::authenticate_validArgumentsResultInValidToken()

// assert
const auto certInfo = getCertAndPinInfoFromSignalSpy(authenticateSpy);
QCOMPARE(certInfo.subject, QStringLiteral("M\u00C4NNIK, MARI-LIIS, 61709210125"));
QCOMPARE(certInfo.subject, QStringLiteral("J\u00D5EORG, JAAK-KRISTJAN, 38001085718"));

QCOMPARE(controller->result()["unverifiedCertificate"].toString().left(25),
QStringLiteral("MIIGRzCCBC+gAwIBAgIQRA7X0"));
QCOMPARE(controller->result()[QStringLiteral("unverifiedCertificate")].toString().left(25),
QStringLiteral("MIIEAzCCA2WgAwIBAgIQOWkBW"));
}

void WebEidTests::fromPunycode_decodesEeDomain()
{
QCOMPARE(fromPunycode(QUrl("https://xn--igusnunik-p7af.ee")),
QCOMPARE(fromPunycode(QUrl(QStringLiteral("https://xn--igusnunik-p7af.ee"))),
QStringLiteral("\u00F5igusn\u00F5unik.ee"));
}

Expand All @@ -216,7 +219,7 @@ void WebEidTests::quit_exits()

} catch (const std::exception& e) {
QFAIL(QStringLiteral("WebEidTests::quit_exits() failed with exception: %s")
.arg(e.what())
.arg(QLatin1String(e.what()))
.toUtf8());
}
}
Expand Down Expand Up @@ -248,7 +251,7 @@ void WebEidTests::initGetCert()

} catch (const std::exception& e) {
QFAIL(QStringLiteral("WebEidTests::initGetCert() failed with exception: %s")
.arg(e.what())
.arg(QLatin1String(e.what()))
.toUtf8());
}
}
Expand All @@ -264,23 +267,23 @@ void WebEidTests::initAuthenticate()

} catch (const std::exception& e) {
QFAIL(QStringLiteral("WebEidTests::initAuthenticate() failed with exception: %s")
.arg(e.what())
.arg(QLatin1String(e.what()))
.toUtf8());
}
}

void WebEidTests::initCard(bool withSigningScript)
{
try {
PcscMock::setAtr(ESTEID_GEMALTO_V3_5_8_COLD_ATR);
PcscMock::setAtr(ESTEID_IDEMIA_V1_ATR);
const auto notExpiredCertScript = replaceCertValidUntilToNextYear(
withSigningScript ? ESTEID_GEMALTO_V3_5_8_GET_SIGN_CERTIFICATE_AND_SIGNING
: ESTEID_GEMALTO_V3_5_8_GET_AUTH_CERTIFICATE_AND_AUTHENTICATE);
withSigningScript ? ESTEID_IDEMIA_V1_SELECT_SIGN_CERTIFICATE_AND_SIGNING
: ESTEID_IDEMIA_V1_SELECT_AUTH_CERTIFICATE_AND_AUTHENTICATE);
PcscMock::setApduScript(notExpiredCertScript);

} catch (const std::exception& e) {
QFAIL(QStringLiteral("WebEidTests::initCard() failed with exception: %s")
.arg(e.what())
.arg(QLatin1String(e.what()))
.toUtf8());
}
}
Expand Down
Loading