diff options
author | Jędrzej Nowacki <jedrzej.nowacki@digia.com> | 2013-11-07 15:18:28 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-18 15:00:45 +0100 |
commit | 1cef9b758067aa1ac76a3b62c084154830bce0df (patch) | |
tree | ef994df6fc5345d8d1f065ae387e4b5fc1d4b14e /tests | |
parent | b506d2bed345350e678f5d002df308f0d9e1a412 (diff) | |
download | qtenginio-1cef9b758067aa1ac76a3b62c084154830bce0df.tar.gz |
Check if the right signal is emitted on OAuth2 properties change.
Change-Id: I3f6af4a4b8be242796a22c4dbc5784423088c069
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/identity/common/identitycommon.h | 46 | ||||
-rw-r--r-- | tests/auto/identity/oauth2authentication/tst_oauth2authentication.cpp | 1 |
2 files changed, 47 insertions, 0 deletions
diff --git a/tests/auto/identity/common/identitycommon.h b/tests/auto/identity/common/identitycommon.h index b0a4544..5870ec3 100644 --- a/tests/auto/identity/common/identitycommon.h +++ b/tests/auto/identity/common/identitycommon.h @@ -71,6 +71,7 @@ protected: void identity_invalid(); void identity_afterLogout(const QByteArray &headerName); void queryRestrictedObject(); + void userAndPass(); }; template<class Derived, class Identity> @@ -594,3 +595,48 @@ void IdentityCommonTest<Derived, Identity>::queryRestrictedObject() // } } + +template<class Derived, class Identity> +void IdentityCommonTest<Derived, Identity>::userAndPass() +{ + EnginioClient client; + client.setBackendId(_backendId); + client.setServiceUrl(EnginioTests::TESTAPP_URL); + + QString userName = "logintest"; + QString userPass = "logintest"; + + Identity identity; + QSignalSpy userSpy(&identity, SIGNAL(userChanged(QString))); + QSignalSpy passSpy(&identity, SIGNAL(passwordChanged(QString))); + + QCOMPARE(identity.user(), QString()); + QCOMPARE(identity.password(), QString()); + + identity.setUser(userName); + QCOMPARE(userSpy.count(), 1); + QCOMPARE(passSpy.count(), 0); + identity.setPassword(userPass); + QCOMPARE(passSpy.count(), 1); + + QCOMPARE(identity.user(), userName); + QCOMPARE(identity.password(), userPass); + + // no real change + identity.setUser(userName); + QCOMPARE(userSpy.count(), 1); + identity.setPassword(userPass); + QCOMPARE(passSpy.count(), 1); + + QCOMPARE(identity.user(), userName); + QCOMPARE(identity.password(), userPass); + + identity.setUser(QString()); + QCOMPARE(userSpy.count(), 2); + QCOMPARE(passSpy.count(), 1); + identity.setPassword(QString()); + QCOMPARE(passSpy.count(), 2); + + QCOMPARE(identity.user(), QString()); + QCOMPARE(identity.password(), QString()); +} diff --git a/tests/auto/identity/oauth2authentication/tst_oauth2authentication.cpp b/tests/auto/identity/oauth2authentication/tst_oauth2authentication.cpp index 54a747d..ec3dcf7 100644 --- a/tests/auto/identity/oauth2authentication/tst_oauth2authentication.cpp +++ b/tests/auto/identity/oauth2authentication/tst_oauth2authentication.cpp @@ -72,6 +72,7 @@ private slots: void identity_invalid() { Base::identity_invalid(); } void identity_afterLogout() { Base::identity_afterLogout(QByteArrayLiteral("Authorization")); } void queryRestrictedObject() { Base::queryRestrictedObject(); } + void userAndPass() { Base::userAndPass(); } }; QTEST_MAIN(tst_OAuth2Authentication) |