Commit e48bc477 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add autotest + fix method signature

parent ec1e1d38
......@@ -67,3 +67,22 @@ void DKIMUtilTest::shouldVerifySubEmailDomain()
QCOMPARE(MessageViewer::DKIMUtil::emailSubDomain(domainName), QStringLiteral("kde.org"));
}
}
void DKIMUtilTest::shouldConvertAuthenticationMethodEnumToString()
{
QCOMPARE(MessageViewer::DKIMUtil::convertAuthenticationMethodEnumToString(MessageViewer::DKIMCheckSignatureJob::AuthenticationMethod::Unknown), QString());
QCOMPARE(MessageViewer::DKIMUtil::convertAuthenticationMethodEnumToString(MessageViewer::DKIMCheckSignatureJob::AuthenticationMethod::Dkim), QStringLiteral("dkim"));
QCOMPARE(MessageViewer::DKIMUtil::convertAuthenticationMethodEnumToString(MessageViewer::DKIMCheckSignatureJob::AuthenticationMethod::Spf), QStringLiteral("spf"));
QCOMPARE(MessageViewer::DKIMUtil::convertAuthenticationMethodEnumToString(MessageViewer::DKIMCheckSignatureJob::AuthenticationMethod::Dmarc), QStringLiteral("dmarc"));
QCOMPARE(MessageViewer::DKIMUtil::convertAuthenticationMethodEnumToString(MessageViewer::DKIMCheckSignatureJob::AuthenticationMethod::Dkimatps), QStringLiteral("dkim-atps"));
}
void DKIMUtilTest::shouldConvertAuthenticationMethodToString()
{
QCOMPARE(MessageViewer::DKIMUtil::convertAuthenticationMethodStringToEnum(QStringLiteral("dkim")), MessageViewer::DKIMCheckSignatureJob::AuthenticationMethod::Dkim);
QCOMPARE(MessageViewer::DKIMUtil::convertAuthenticationMethodStringToEnum(QStringLiteral("spf")), MessageViewer::DKIMCheckSignatureJob::AuthenticationMethod::Spf);
QCOMPARE(MessageViewer::DKIMUtil::convertAuthenticationMethodStringToEnum(QStringLiteral("dmarc")), MessageViewer::DKIMCheckSignatureJob::AuthenticationMethod::Dmarc);
QCOMPARE(MessageViewer::DKIMUtil::convertAuthenticationMethodStringToEnum(QStringLiteral("dkim-atps")), MessageViewer::DKIMCheckSignatureJob::AuthenticationMethod::Dkimatps);
QCOMPARE(MessageViewer::DKIMUtil::convertAuthenticationMethodStringToEnum(QStringLiteral("sdfsdf")), MessageViewer::DKIMCheckSignatureJob::AuthenticationMethod::Unknown);
QCOMPARE(MessageViewer::DKIMUtil::convertAuthenticationMethodStringToEnum(QString()), MessageViewer::DKIMCheckSignatureJob::AuthenticationMethod::Unknown);
}
......@@ -32,6 +32,8 @@ private Q_SLOTS:
void shouldTestBodyCanonizationRelaxed();
void shouldVerifyEmailDomain();
void shouldVerifySubEmailDomain();
void shouldConvertAuthenticationMethodEnumToString();
void shouldConvertAuthenticationMethodToString();
};
#endif // DKIMUTILTEST_H
......@@ -49,7 +49,7 @@ QVector<DKIMCheckSignatureJob::CheckSignatureResult> DKIMAuthenticationStatusInf
const QVector<DKIMAuthenticationStatusInfo::AuthStatusInfo> lstInfo = mStatusInfo.listAuthStatusInfo();
for (const DKIMAuthenticationStatusInfo::AuthStatusInfo &info : lstInfo) {
DKIMCheckSignatureJob::CheckSignatureResult convertedResult;
convertedResult.authenticationResult.method = MessageViewer::DKIMUtil::convertAuthenticationMethodToString(info.method);
convertedResult.authenticationResult.method = MessageViewer::DKIMUtil::convertAuthenticationMethodStringToEnum(info.method);
const QString &infoResult = info.result;
if (infoResult == QLatin1String("none")) {
convertedResult.status = DKIMCheckSignatureJob::DKIMStatus::EmailNotSigned;
......
......@@ -187,7 +187,7 @@ QString MessageViewer::DKIMUtil::convertAuthenticationMethodEnumToString(Message
return methodStr;
}
MessageViewer::DKIMCheckSignatureJob::AuthenticationMethod MessageViewer::DKIMUtil::convertAuthenticationMethodToString(const QString &str)
MessageViewer::DKIMCheckSignatureJob::AuthenticationMethod MessageViewer::DKIMUtil::convertAuthenticationMethodStringToEnum(const QString &str)
{
if (str == QLatin1String("dkim")) {
return MessageViewer::DKIMCheckSignatureJob::AuthenticationMethod::Dkim;
......
......@@ -35,7 +35,7 @@ MESSAGEVIEWER_TESTS_EXPORT Q_REQUIRED_RESULT QString emailDomain(const QString &
MESSAGEVIEWER_TESTS_EXPORT Q_REQUIRED_RESULT QString emailSubDomain(const QString &emailDomain);
MESSAGEVIEWER_TESTS_EXPORT Q_REQUIRED_RESULT QString defaultConfigFileName();
MESSAGEVIEWER_TESTS_EXPORT Q_REQUIRED_RESULT QString convertAuthenticationMethodEnumToString(DKIMCheckSignatureJob::AuthenticationMethod);
MESSAGEVIEWER_TESTS_EXPORT Q_REQUIRED_RESULT DKIMCheckSignatureJob::AuthenticationMethod convertAuthenticationMethodToString(const QString &str);
MESSAGEVIEWER_TESTS_EXPORT Q_REQUIRED_RESULT DKIMCheckSignatureJob::AuthenticationMethod convertAuthenticationMethodStringToEnum(const QString &str);
}
}
......
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