~online-accounts/signon/rtm-14.09

« back to all changes in this revision

Viewing changes to tests/libsignon-qt-tests/ssotestclient.cpp

  • Committer: Tarmac
  • Author(s): Alberto Mardegan
  • Date: 2013-11-26 16:09:31 UTC
  • mfrom: (605.1.3 packaging)
  • Revision ID: tarmac-20131126160931-xjatums22ndhvirc
Merge from upstream

signond: avoid rewriting password with empty string
Remove signon-keyring-extension from Recommends field
. Fixes: https://bugs.launchpad.net/bugs/1156776, https://bugs.launchpad.net/bugs/1237782.

Approved by Ken VanDine, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1588
1588
    return true;
1589
1589
}
1590
1590
 
 
1591
void SsoTestClient::emptyPasswordRegression()
 
1592
{
 
1593
    TEST_START
 
1594
 
 
1595
    m_identityResult.reset();
 
1596
 
 
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",
 
1603
                      "TEST_USERNAME_1",
 
1604
                      methods);
 
1605
    info.setSecret(myPassword);
 
1606
    info.setRealms(QStringList() << "test_realm");
 
1607
    QStringList acl;
 
1608
    acl << "*";
 
1609
    info.setAccessControlList(acl);
 
1610
 
 
1611
    Identity *identity = Identity::newIdentity(info);
 
1612
 
 
1613
    QEventLoop loop;
 
1614
 
 
1615
    const char *errorSignature = SIGNAL(error(const SignOn::Error &));
 
1616
    QSignalSpy errorSignal(identity, errorSignature);
 
1617
    connect(identity, errorSignature, &loop, SLOT(quit()));
 
1618
 
 
1619
    const char *credentialsStoredSignature =
 
1620
        SIGNAL(credentialsStored(const quint32));
 
1621
    QSignalSpy credentialsStoredSignal(identity, credentialsStoredSignature);
 
1622
    connect(identity, credentialsStoredSignature, &loop, SLOT(quit()));
 
1623
 
 
1624
    identity->storeCredentials();
 
1625
 
 
1626
    QTimer::singleShot(test_timeout, &loop, SLOT(quit()));
 
1627
    loop.exec();
 
1628
 
 
1629
    QCOMPARE(errorSignal.count(), 0);
 
1630
    QCOMPARE(credentialsStoredSignal.count(), 1);
 
1631
    credentialsStoredSignal.clear();
 
1632
 
 
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()));
 
1637
 
 
1638
    identity->verifySecret(myPassword);
 
1639
 
 
1640
    QTimer::singleShot(test_timeout, &loop, SLOT(quit()));
 
1641
    loop.exec();
 
1642
 
 
1643
    QCOMPARE(secretVerifiedSignal.count(), 1);
 
1644
    QCOMPARE(secretVerifiedSignal.at(0).at(0).toBool(), true);
 
1645
    secretVerifiedSignal.clear();
 
1646
 
 
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()));
 
1652
 
 
1653
    identity->queryInfo();
 
1654
 
 
1655
    QTimer::singleShot(test_timeout, &loop, SLOT(quit()));
 
1656
    loop.exec();
 
1657
 
 
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());
 
1663
 
 
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);
 
1668
 
 
1669
    identity->storeCredentials(m_identityResult.m_idInfo);
 
1670
 
 
1671
    QTimer::singleShot(test_timeout, &loop, SLOT(quit()));
 
1672
    loop.exec();
 
1673
 
 
1674
    /* check that the store succeeded */
 
1675
    QCOMPARE(errorSignal.count(), 0);
 
1676
    QCOMPARE(credentialsStoredSignal.count(), 1);
 
1677
    credentialsStoredSignal.clear();
 
1678
 
 
1679
    identity->verifySecret(myPassword);
 
1680
 
 
1681
    QTimer::singleShot(test_timeout, &loop, SLOT(quit()));
 
1682
    loop.exec();
 
1683
 
 
1684
    QCOMPARE(secretVerifiedSignal.count(), 1);
 
1685
    QCOMPARE(secretVerifiedSignal.at(0).at(0).toBool(), true);
 
1686
 
 
1687
    delete identity;
 
1688
 
 
1689
    TEST_DONE
 
1690
}
 
1691
 
1591
1692
int main(int argc, char *argv[])
1592
1693
{
1593
1694
    QCoreApplication app(argc, argv);