Commit b1835ce6 authored by Laurent Montel's avatar Laurent Montel 😁

Fix settings, so now we can use SelectImapWidget

parent 196b8524
......@@ -50,7 +50,7 @@ void SieveAccountTest::shouldAssignValue()
QString user = QStringLiteral("bla");
int port = 42;
KSieveUi::SieveImapAccountSettings::AuthenticationMode type = KSieveUi::SieveImapAccountSettings::DigestMD5;
KSieveUi::SieveImapAccountSettings::EncryptionMode mode = KSieveUi::SieveImapAccountSettings::SslV3_1;
KSieveUi::SieveImapAccountSettings::EncryptionMode mode = KSieveUi::SieveImapAccountSettings::SSLorTLS;
account.setPassword(pwd);
account.setServerName(server);
account.setUserName(user);
......@@ -73,7 +73,7 @@ void SieveAccountTest::shouldBeEqual()
QString user = QStringLiteral("bla");
int port = 42;
KSieveUi::SieveImapAccountSettings::AuthenticationMode type = KSieveUi::SieveImapAccountSettings::DigestMD5;
KSieveUi::SieveImapAccountSettings::EncryptionMode mode = KSieveUi::SieveImapAccountSettings::SslV3_1;
KSieveUi::SieveImapAccountSettings::EncryptionMode mode = KSieveUi::SieveImapAccountSettings::SSLorTLS;
account.setPassword(pwd);
account.setServerName(server);
account.setUserName(user);
......@@ -107,7 +107,7 @@ void SieveAccountTest::shouldCreateIdentifier()
//Identifier doesn't depend against theses settings
KSieveUi::SieveImapAccountSettings::AuthenticationMode type = KSieveUi::SieveImapAccountSettings::DigestMD5;
KSieveUi::SieveImapAccountSettings::EncryptionMode mode = KSieveUi::SieveImapAccountSettings::SslV3_1;
KSieveUi::SieveImapAccountSettings::EncryptionMode mode = KSieveUi::SieveImapAccountSettings::SSLorTLS;
account.setPort(42);
account.setAuthenticationType(type);
account.setEncryptionMode(mode);
......
......@@ -99,7 +99,7 @@ void UtilMethodTest::shouldAssignValue_data()
info1.sieveImapAccountSettings.setUserName(userName);
info1.sieveImapAccountSettings.setPassword(password);
info1.sieveImapAccountSettings.setAuthenticationType(KSieveUi::SieveImapAccountSettings::CramMD5);
info1.sieveImapAccountSettings.setAuthenticationType(KSieveUi::SieveImapAccountSettings::Plain);
//TODO fix encryptionmode
info1.sieveImapAccountSettings.setEncryptionMode(KSieveUi::SieveImapAccountSettings::Unencrypted);
......@@ -139,7 +139,7 @@ void UtilMethodTest::shouldAssignValue_data()
info1.sieveImapAccountSettings.setUserName(userName);
info1.sieveImapAccountSettings.setPassword(password);
info1.sieveImapAccountSettings.setAuthenticationType(KSieveUi::SieveImapAccountSettings::Login);
info1.sieveImapAccountSettings.setAuthenticationType(KSieveUi::SieveImapAccountSettings::ClearText);
//TODO fix encryptionmode
info1.sieveImapAccountSettings.setEncryptionMode(KSieveUi::SieveImapAccountSettings::Unencrypted);
......@@ -178,9 +178,9 @@ void UtilMethodTest::shouldAssignValue_data()
info1.sieveImapAccountSettings.setUserName(userName);
info1.sieveImapAccountSettings.setPassword(password);
info1.sieveImapAccountSettings.setAuthenticationType(KSieveUi::SieveImapAccountSettings::Login);
info1.sieveImapAccountSettings.setAuthenticationType(KSieveUi::SieveImapAccountSettings::ClearText);
//TODO fix encryptionmode
info1.sieveImapAccountSettings.setEncryptionMode(KSieveUi::SieveImapAccountSettings::AnySslVersion);
info1.sieveImapAccountSettings.setEncryptionMode(KSieveUi::SieveImapAccountSettings::SSLorTLS);
QTest::newRow("sievereuseconfig2ssl") << data1 << info1 << true << true;
}
......@@ -218,9 +218,9 @@ void UtilMethodTest::shouldAssignValue_data()
info1.sieveImapAccountSettings.setUserName(userName);
info1.sieveImapAccountSettings.setPassword(password);
info1.sieveImapAccountSettings.setAuthenticationType(KSieveUi::SieveImapAccountSettings::Login);
info1.sieveImapAccountSettings.setAuthenticationType(KSieveUi::SieveImapAccountSettings::ClearText);
//TODO fix encryptionmode
info1.sieveImapAccountSettings.setEncryptionMode(KSieveUi::SieveImapAccountSettings::TlsV1);
info1.sieveImapAccountSettings.setEncryptionMode(KSieveUi::SieveImapAccountSettings::STARTTLS);
QTest::newRow("sievereuseconfig2startls") << data1 << info1 << true << true;
}
......@@ -287,7 +287,7 @@ void UtilMethodTest::shouldAssignValue_data()
info1.sieveImapAccountSettings.setUserName(imapUser);
info1.sieveImapAccountSettings.setPassword(imapPasswd);
info1.sieveImapAccountSettings.setAuthenticationType(KSieveUi::SieveImapAccountSettings::DigestMD5);
info1.sieveImapAccountSettings.setAuthenticationType(KSieveUi::SieveImapAccountSettings::CramMD5);
info1.sieveImapAccountSettings.setEncryptionMode(KSieveUi::SieveImapAccountSettings::Unencrypted);
......@@ -328,7 +328,7 @@ void UtilMethodTest::shouldAssignValue_data()
info1.sieveImapAccountSettings.setUserName(imapUser);
info1.sieveImapAccountSettings.setPassword(imapPasswd);
info1.sieveImapAccountSettings.setAuthenticationType(KSieveUi::SieveImapAccountSettings::DigestMD5);
info1.sieveImapAccountSettings.setAuthenticationType(KSieveUi::SieveImapAccountSettings::CramMD5);
info1.sieveImapAccountSettings.setEncryptionMode(KSieveUi::SieveImapAccountSettings::Unencrypted);
......@@ -370,9 +370,9 @@ void UtilMethodTest::shouldAssignValue_data()
info1.sieveImapAccountSettings.setUserName(imapUser);
info1.sieveImapAccountSettings.setPassword(imapPasswd);
info1.sieveImapAccountSettings.setAuthenticationType(KSieveUi::SieveImapAccountSettings::DigestMD5);
info1.sieveImapAccountSettings.setAuthenticationType(KSieveUi::SieveImapAccountSettings::CramMD5);
info1.sieveImapAccountSettings.setEncryptionMode(KSieveUi::SieveImapAccountSettings::AnySslVersion);
info1.sieveImapAccountSettings.setEncryptionMode(KSieveUi::SieveImapAccountSettings::SSLorTLS);
QTest::newRow("sievereusecustomconfig1withoutvacationfileSSL") << data1 << info1 << true << false;
}
......@@ -412,9 +412,9 @@ void UtilMethodTest::shouldAssignValue_data()
info1.sieveImapAccountSettings.setUserName(imapUser);
info1.sieveImapAccountSettings.setPassword(imapPasswd);
info1.sieveImapAccountSettings.setAuthenticationType(KSieveUi::SieveImapAccountSettings::DigestMD5);
info1.sieveImapAccountSettings.setAuthenticationType(KSieveUi::SieveImapAccountSettings::CramMD5);
info1.sieveImapAccountSettings.setEncryptionMode(KSieveUi::SieveImapAccountSettings::TlsV1);
info1.sieveImapAccountSettings.setEncryptionMode(KSieveUi::SieveImapAccountSettings::STARTTLS);
QTest::newRow("sievereusecustomconfig1withoutvacationfileStarttls") << data1 << info1 << true << false;
}
......@@ -454,9 +454,9 @@ void UtilMethodTest::shouldAssignValue_data()
info1.sieveImapAccountSettings.setUserName(imapUser);
info1.sieveImapAccountSettings.setPassword(imapPasswd);
info1.sieveImapAccountSettings.setAuthenticationType(KSieveUi::SieveImapAccountSettings::GSSAPI);
info1.sieveImapAccountSettings.setAuthenticationType(KSieveUi::SieveImapAccountSettings::DigestMD5);
info1.sieveImapAccountSettings.setEncryptionMode(KSieveUi::SieveImapAccountSettings::TlsV1);
info1.sieveImapAccountSettings.setEncryptionMode(KSieveUi::SieveImapAccountSettings::STARTTLS);
QTest::newRow("sievereusecustomconfig1withoutvacationfileStarttls2") << data1 << info1 << true << false;
}
......@@ -495,9 +495,9 @@ void UtilMethodTest::shouldAssignValue_data()
info1.sieveImapAccountSettings.setUserName(imapUser);
info1.sieveImapAccountSettings.setPassword(imapPasswd);
info1.sieveImapAccountSettings.setAuthenticationType(KSieveUi::SieveImapAccountSettings::GSSAPI);
info1.sieveImapAccountSettings.setAuthenticationType(KSieveUi::SieveImapAccountSettings::DigestMD5);
info1.sieveImapAccountSettings.setEncryptionMode(KSieveUi::SieveImapAccountSettings::TlsV1);
info1.sieveImapAccountSettings.setEncryptionMode(KSieveUi::SieveImapAccountSettings::STARTTLS);
QTest::newRow("sievereusecustomconfig1withoutvacationfileStarttls3") << data1 << info1 << true << false;
}
......@@ -521,8 +521,8 @@ void UtilMethodTest::shouldAssignValue_data()
data1.sieveVacationFilename = QStringLiteral("vacation.siv");
data1.safety = QStringLiteral("STARTTLS");
data1.alternateAuthentication = 4;
//MailTransport::Transport::EnumAuthenticationType::PLAIN = 0
data1.authentication = 0;
//MailTransport::Transport::EnumAuthenticationType::PLAIN = 2
data1.authentication = 2;
data1.sieveAlternateUrl = QStringLiteral("bla.bla.com");
data1.password = imapPasswd;
data1.sieveCustomPassword = sievePasswd;
......@@ -545,7 +545,12 @@ void UtilMethodTest::shouldAssignValue()
std::unique_ptr<DataImapPasswordProvider> provider(new DataImapPasswordProvider(&data));
const KSieveUi::Util::AccountInfo info = KSieveUi::Util::findAccountInfo(QStringLiteral("foo"), provider.get(), useVacationFile, interface);
QCOMPARE(info.sieveImapAccountSettings.isValid(), sieveImapAccountValid);
QCOMPARE(info, accountInfo);
const bool equal = (info == accountInfo);
if (!equal) {
qDebug() << " info " << info;
qDebug() << " accountInfo " << accountInfo;
}
QVERIFY(equal);
}
QTEST_MAIN(UtilMethodTest)
......@@ -33,22 +33,21 @@ public:
//Keep sync with KIMAP settings.
enum EncryptionMode {
Unencrypted = 0,
TlsV1,
SslV2,
SslV3,
SslV3_1,
AnySslVersion
SSLorTLS, /*!< Use SSL/TLS encryption, KIMAP will automatically negoatiate
the best supported encryption protocol. */
STARTTLS /*!< Use STARTTLS to upgrade an initially plaintext connection to
encrypted connection. KIMAP will automatically negoatiate
the best supported encryption protocol. */
};
enum AuthenticationMode {
Login = 0,
ClearText = 0,
Login,
Plain,
CramMD5,
DigestMD5,
GSSAPI,
NTLM,
APOP,
ClearText,
GSSAPI,
Anonymous,
XOAuth2
};
......
......@@ -129,9 +129,9 @@ KSieveUi::Util::AccountInfo KSieveUi::Util::findAccountInfo(const QString &ident
accountInfo.sieveImapAccountSettings.setEncryptionMode(SieveImapAccountSettings::Unencrypted);
query.addQueryItem(QStringLiteral("x-allow-unencrypted"), QStringLiteral("true"));
} else if (resultSafety == QLatin1String("SSL")) {
accountInfo.sieveImapAccountSettings.setEncryptionMode(SieveImapAccountSettings::AnySslVersion);
accountInfo.sieveImapAccountSettings.setEncryptionMode(SieveImapAccountSettings::SSLorTLS);
} else if (resultSafety == QLatin1String("STARTTLS")) {
accountInfo.sieveImapAccountSettings.setEncryptionMode(SieveImapAccountSettings::TlsV1);
accountInfo.sieveImapAccountSettings.setEncryptionMode(SieveImapAccountSettings::STARTTLS);
} else {
accountInfo.sieveImapAccountSettings.setEncryptionMode(SieveImapAccountSettings::Unencrypted);
}
......@@ -197,9 +197,9 @@ KSieveUi::Util::AccountInfo KSieveUi::Util::findAccountInfo(const QString &ident
accountInfo.sieveImapAccountSettings.setEncryptionMode(SieveImapAccountSettings::Unencrypted);
query.addQueryItem(QStringLiteral("x-allow-unencrypted"), QStringLiteral("true"));
} else if (resultSafety == QLatin1String("SSL")) {
accountInfo.sieveImapAccountSettings.setEncryptionMode(SieveImapAccountSettings::AnySslVersion);
accountInfo.sieveImapAccountSettings.setEncryptionMode(SieveImapAccountSettings::SSLorTLS);
} else if (resultSafety == QLatin1String("STARTTLS")) {
accountInfo.sieveImapAccountSettings.setEncryptionMode(SieveImapAccountSettings::TlsV1);
accountInfo.sieveImapAccountSettings.setEncryptionMode(SieveImapAccountSettings::STARTTLS);
} else {
accountInfo.sieveImapAccountSettings.setEncryptionMode(SieveImapAccountSettings::Unencrypted);
}
......
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