summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesus Fernandez <jesus.fernandez@qt.io>2017-09-11 14:33:02 +0200
committerJesus Fernandez <Jesus.Fernandez@qt.io>2017-09-20 08:13:18 +0000
commit47b80ecae6fe0b9a2c74f0b0feb243145695995e (patch)
treedddbd2ae06d9c7b18dce7bf41fc3bb0fc564fcc8
parent3d93f6436596e349e43c3798b675af66db71df8a (diff)
Avoid emitting QOAuth1::granted signal twicev5.9.2
Due to a bug in OAuth1 implementation, the granted() signal was being emitted two times. This fix saves clients from repeating requests to the web server, after authentication, in response to the repeated signal. [ChangeLog][QOAuth1] Emit granted() only one time. Task-number: QTBUG-63182 Change-Id: I6723d55a38fb773300ae14d3d9108d6863cde635 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
-rw-r--r--src/oauth/qoauth1.cpp4
-rw-r--r--tests/auto/oauth1/tst_oauth1.cpp2
2 files changed, 3 insertions, 3 deletions
diff --git a/src/oauth/qoauth1.cpp b/src/oauth/qoauth1.cpp
index e23c21e..22b3597 100644
--- a/src/oauth/qoauth1.cpp
+++ b/src/oauth/qoauth1.cpp
@@ -597,9 +597,7 @@ void QOAuth1::grant()
// https://tools.ietf.org/html/rfc5849#section-2.2
resourceOwnerAuthorization(d->authorizationUrl, parameters);
}
- } else if (status == Status::Granted) {
- Q_EMIT granted();
- } else {
+ } else if (status == Status::NotAuthenticated) {
// Inherit class called QAbstractOAuth::setStatus(Status::NotAuthenticated);
setTokenCredentials(QString(), QString());
disconnect(connection);
diff --git a/tests/auto/oauth1/tst_oauth1.cpp b/tests/auto/oauth1/tst_oauth1.cpp
index e6d458c..cdde34d 100644
--- a/tests/auto/oauth1/tst_oauth1.cpp
+++ b/tests/auto/oauth1/tst_oauth1.cpp
@@ -525,11 +525,13 @@ void tst_OAuth1::grant()
QEventLoop eventLoop;
+ QSignalSpy grantSignalSpy(&o1, &QOAuth1::granted);
QTimer::singleShot(10000, &eventLoop, &QEventLoop::quit);
connect(&o1, &QOAuth1::granted, &eventLoop, &QEventLoop::quit);
o1.grant();
eventLoop.exec();
QVERIFY(tokenReceived);
+ QCOMPARE(grantSignalSpy.count(), 1);
QCOMPARE(o1.status(), QAbstractOAuth::Status::Granted);
}