~mardy/signon-keyring-extension/lp1172710

« back to all changes in this revision

Viewing changes to tests/keyring-test.cpp

  • Committer: Alberto Mardegan
  • Date: 2011-11-18 17:06:13 UTC
  • Revision ID: alberto.mardegan@canonical.com-20111118170613-kjhmm0rttwagsd16
Implement storing/loading of credentials

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <QDebug>
28
28
#include <QTest>
29
29
 
 
30
/* Let's hope I won't overwrite my credentials when running these tests :-) */
 
31
#define TEST_CREDENTIALS_ID 0x7fffffff
 
32
 
30
33
void KeyringTest::initTestCase()
31
34
{
32
35
    qDebug() << Q_FUNC_INFO;
46
49
    QVERIFY(ok);
47
50
}
48
51
 
 
52
void KeyringTest::updateCredentials()
 
53
{
 
54
    bool ok;
 
55
 
 
56
    QString testUsername = QLatin1String("Test username");
 
57
    QString testPassword = QLatin1String("Test p4ssw0rd");
 
58
    ok = storage->updateCredentials(TEST_CREDENTIALS_ID,
 
59
                                    testUsername,
 
60
                                    testPassword);
 
61
    QVERIFY(ok);
 
62
 
 
63
    QString username, password;
 
64
    ok = storage->loadCredentials(TEST_CREDENTIALS_ID, username, password);
 
65
    QVERIFY(ok);
 
66
    QCOMPARE(username, testUsername);
 
67
    QCOMPARE(password, testPassword);
 
68
 
 
69
    ok = storage->removeCredentials(TEST_CREDENTIALS_ID);
 
70
    QVERIFY(ok);
 
71
}
 
72
 
49
73
void KeyringTest::cleanupTestCase()
50
74
{
51
75
    delete storage;