1591
void SsoTestClient::emptyPasswordRegression()
1595
m_identityResult.reset();
1597
QString myPassword("My password");
1598
//inserting some credentials
1599
QMap<MethodName, MechanismsList> methods;
1600
methods.insert("method1", QStringList() << "mech1" << "mech2");
1601
methods.insert("method2", QStringList() << "mech1" << "mech2" << "mech3");
1602
IdentityInfo info("TEST_CAPTION_1",
1605
info.setSecret(myPassword);
1606
info.setRealms(QStringList() << "test_realm");
1609
info.setAccessControlList(acl);
1611
Identity *identity = Identity::newIdentity(info);
1615
const char *errorSignature = SIGNAL(error(const SignOn::Error &));
1616
QSignalSpy errorSignal(identity, errorSignature);
1617
connect(identity, errorSignature, &loop, SLOT(quit()));
1619
const char *credentialsStoredSignature =
1620
SIGNAL(credentialsStored(const quint32));
1621
QSignalSpy credentialsStoredSignal(identity, credentialsStoredSignature);
1622
connect(identity, credentialsStoredSignature, &loop, SLOT(quit()));
1624
identity->storeCredentials();
1626
QTimer::singleShot(test_timeout, &loop, SLOT(quit()));
1629
QCOMPARE(errorSignal.count(), 0);
1630
QCOMPARE(credentialsStoredSignal.count(), 1);
1631
credentialsStoredSignal.clear();
1633
/* Verify that the password is the one set by signon UI */
1634
const char *secretVerifiedSignature = SIGNAL(secretVerified(const bool));
1635
QSignalSpy secretVerifiedSignal(identity, secretVerifiedSignature);
1636
connect(identity, secretVerifiedSignature, &loop, SLOT(quit()));
1638
identity->verifySecret(myPassword);
1640
QTimer::singleShot(test_timeout, &loop, SLOT(quit()));
1643
QCOMPARE(secretVerifiedSignal.count(), 1);
1644
QCOMPARE(secretVerifiedSignal.at(0).at(0).toBool(), true);
1645
secretVerifiedSignal.clear();
1647
/* Now get the info, and re-store the identity */
1648
const char *infoSignature = SIGNAL(info(const SignOn::IdentityInfo &));
1649
connect(identity, infoSignature,
1650
&m_identityResult, SLOT(info(const SignOn::IdentityInfo &)));
1651
connect(identity, infoSignature, &loop, SLOT(quit()));
1653
identity->queryInfo();
1655
QTimer::singleShot(test_timeout, &loop, SLOT(quit()));
1658
QVERIFY2(m_identityResult.m_responseReceived !=
1659
TestIdentityResult::InexistentResp,
1660
"A response was not received.");
1661
QCOMPARE(m_identityResult.m_idInfo.isStoringSecret(), true);
1662
QCOMPARE(m_identityResult.m_idInfo.secret(), QString());
1664
/* Write it back, and verify that the password doesn't change.
1665
* Change the username to make sure that this is not a no-op. */
1666
QString myUserName("Bob");
1667
m_identityResult.m_idInfo.setUserName(myUserName);
1669
identity->storeCredentials(m_identityResult.m_idInfo);
1671
QTimer::singleShot(test_timeout, &loop, SLOT(quit()));
1674
/* check that the store succeeded */
1675
QCOMPARE(errorSignal.count(), 0);
1676
QCOMPARE(credentialsStoredSignal.count(), 1);
1677
credentialsStoredSignal.clear();
1679
identity->verifySecret(myPassword);
1681
QTimer::singleShot(test_timeout, &loop, SLOT(quit()));
1684
QCOMPARE(secretVerifiedSignal.count(), 1);
1685
QCOMPARE(secretVerifiedSignal.at(0).at(0).toBool(), true);
1591
1692
int main(int argc, char *argv[])
1593
1694
QCoreApplication app(argc, argv);