Changeset View
Changeset View
Standalone View
Standalone View
src/kpasswdserver/autotests/kpasswdservertest.cpp
Show First 20 Lines • Show All 188 Lines • ▼ Show 20 Line(s) | 177 | { | |||
---|---|---|---|---|---|
189 | 189 | | |||
190 | KIO::AuthInfo result; | 190 | KIO::AuthInfo result; | ||
191 | queryAuthWithDialog(server, info, filledInfo, result); | 191 | queryAuthWithDialog(server, info, filledInfo, result); | ||
192 | 192 | | |||
193 | // Pretend that the returned credentials failed and initiate a retry, | 193 | // Pretend that the returned credentials failed and initiate a retry, | ||
194 | // but cancel the retry dialog. | 194 | // but cancel the retry dialog. | ||
195 | info.password.clear(); | 195 | info.password.clear(); | ||
196 | result = KIO::AuthInfo(); | 196 | result = KIO::AuthInfo(); | ||
197 | queryAuthWithDialog(server, info, filledInfo, result, s_buttonCancel, QDialog::Accepted /*unused*/, QStringLiteral("Invalid username or password")); | 197 | queryAuthWithDialog(server, info, filledInfo, result, s_buttonCancel, | ||
198 | QDialog::Accepted /*unused*/, QStringLiteral("Invalid username or password")); | ||||
198 | } | 199 | } | ||
199 | 200 | | |||
200 | void testAcceptRetryDialog() | 201 | void testAcceptRetryDialog() | ||
201 | { | 202 | { | ||
202 | KPasswdServer server(this); | 203 | KPasswdServer server(this); | ||
203 | server.setWalletDisabled(true); | 204 | server.setWalletDisabled(true); | ||
204 | 205 | | |||
205 | // What the app would ask | 206 | // What the app would ask | ||
206 | KIO::AuthInfo info; | 207 | KIO::AuthInfo info; | ||
207 | info.url = QUrl(QStringLiteral("http://www.example.com")); | 208 | info.url = QUrl(QStringLiteral("http://www.example.com")); | ||
208 | 209 | | |||
209 | // What the user would type | 210 | // What the user would type | ||
210 | KIO::AuthInfo filledInfo(info); | 211 | KIO::AuthInfo filledInfo(info); | ||
211 | filledInfo.username = QStringLiteral("username"); | 212 | filledInfo.username = QStringLiteral("username"); | ||
212 | filledInfo.password = QStringLiteral("password"); | 213 | filledInfo.password = QStringLiteral("password"); | ||
213 | 214 | | |||
214 | KIO::AuthInfo result; | 215 | KIO::AuthInfo result; | ||
215 | queryAuthWithDialog(server, info, filledInfo, result); | 216 | queryAuthWithDialog(server, info, filledInfo, result); | ||
216 | 217 | | |||
217 | // Pretend that the returned credentials failed and initiate a retry, | 218 | // Pretend that the returned credentials failed and initiate a retry, | ||
218 | // but this time continue the retry. | 219 | // but this time continue the retry. | ||
219 | info.password.clear(); | 220 | info.password.clear(); | ||
220 | result = KIO::AuthInfo(); | 221 | result = KIO::AuthInfo(); | ||
221 | 222 | | |||
222 | queryAuthWithDialog(server, info, filledInfo, result, s_buttonYes, QDialog::Accepted, QStringLiteral("Invalid username or password")); | 223 | queryAuthWithDialog(server, info, filledInfo, result, s_buttonYes, | ||
224 | QDialog::Accepted, QStringLiteral("Invalid username or password")); | ||||
223 | } | 225 | } | ||
224 | 226 | | |||
225 | void testUsernameMistmatch() | 227 | void testUsernameMistmatch() | ||
226 | { | 228 | { | ||
227 | KPasswdServer server(this); | 229 | KPasswdServer server(this); | ||
228 | server.setWalletDisabled(true); | 230 | server.setWalletDisabled(true); | ||
229 | 231 | | |||
230 | // What the app would ask. Note the username in the URL. | 232 | // What the app would ask. Note the username in the URL. | ||
▲ Show 20 Lines • Show All 172 Lines • ▼ Show 20 Line(s) | 400 | { | |||
403 | QVERIFY(id >= 0); // requestId, ever increasing | 405 | QVERIFY(id >= 0); // requestId, ever increasing | ||
404 | QVERIFY(spy.isEmpty()); | 406 | QVERIFY(spy.isEmpty()); | ||
405 | 407 | | |||
406 | const bool hasErrorMessage = (!errMsg.isEmpty()); | 408 | const bool hasErrorMessage = (!errMsg.isEmpty()); | ||
407 | const bool isCancelRetryDialogTest = (hasErrorMessage && retryButton == s_buttonCancel); | 409 | const bool isCancelRetryDialogTest = (hasErrorMessage && retryButton == s_buttonCancel); | ||
408 | 410 | | |||
409 | if (hasErrorMessage) { | 411 | if (hasErrorMessage) { | ||
410 | // Retry dialog only knows Yes/No | 412 | // Retry dialog only knows Yes/No | ||
411 | QMetaObject::invokeMethod(this, "checkRetryDialog", Qt::QueuedConnection, Q_ARG(QDialogButtonBox::StandardButton, retryButton)); | 413 | QMetaObject::invokeMethod(this, "checkRetryDialog", Qt::QueuedConnection, | ||
414 | Q_ARG(QDialogButtonBox::StandardButton, retryButton)); | ||||
412 | } | 415 | } | ||
413 | 416 | | |||
414 | if (!isCancelRetryDialogTest) { | 417 | if (!isCancelRetryDialogTest) { | ||
415 | QMetaObject::invokeMethod(this, "checkAndFillDialog", Qt::QueuedConnection, Q_ARG(KIO::AuthInfo, info), Q_ARG(KIO::AuthInfo, filledInfo), Q_ARG(QDialog::DialogCode, code)); | 418 | QMetaObject::invokeMethod(this, "checkAndFillDialog", Qt::QueuedConnection, Q_ARG(KIO::AuthInfo, info), | ||
419 | Q_ARG(KIO::AuthInfo, filledInfo), Q_ARG(QDialog::DialogCode, code)); | ||||
416 | } | 420 | } | ||
417 | // Force KPasswdServer to process the request now, otherwise the checkAndFillDialog needs a timer too... | 421 | // Force KPasswdServer to process the request now, otherwise the checkAndFillDialog needs a timer too... | ||
418 | server.processRequest(); | 422 | server.processRequest(); | ||
419 | if (spy.isEmpty()) | 423 | if (spy.isEmpty()) | ||
420 | QVERIFY(QSignalSpy(&server, sigQueryAuthInfoResult).wait(1000)); | 424 | QVERIFY(QSignalSpy(&server, sigQueryAuthInfoResult).wait(1000)); | ||
421 | QCOMPARE(spy.count(), 1); | 425 | QCOMPARE(spy.count(), 1); | ||
422 | QCOMPARE(spy[0][0].toLongLong(), id); | 426 | QCOMPARE(spy[0][0].toLongLong(), id); | ||
423 | // QCOMPARE(spy[0][1].toLongLong(), 3LL); // seqNr | 427 | // QCOMPARE(spy[0][1].toLongLong(), 3LL); // seqNr | ||
▲ Show 20 Lines • Show All 122 Lines • Show Last 20 Lines |