Skip to content

Commit

Permalink
net-libs/signon-oauth2: add 0.25_p20210102 (with Qt 6 support)
Browse files Browse the repository at this point in the history
Signed-off-by: Sam James <[email protected]>
  • Loading branch information
thesamesam committed Jan 12, 2024
1 parent 1eba433 commit 0bb749c
Show file tree
Hide file tree
Showing 14 changed files with 891 additions and 0 deletions.
1 change: 1 addition & 0 deletions net-libs/signon-oauth2/Manifest
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
DIST signon-oauth2-0.25.tar.gz 41090 BLAKE2B d14cde073cf834427e337f94345b719ad1af38a285587f987f6ed42f96e8aecfcf63720e42b7f86f2018565c198e1f31b7b75da74c86db3e8a15680da70d3f9e SHA512 721cd514ee0a1175e3b1bbaa78dc1a87fd382327bcbee8356de040f04455f7cc80ed173e3f33a6acf4c0d679847063a25282e9d5c9a9be99f730bec41be96451
DIST signon-oauth2-0.25_p20210102.tar.bz2 34873 BLAKE2B 4e53f6d19cf0e9c8513afef44ab640dcd3ed811a9830acff65abd997691926388015b35e6f010c6a0bc25cc257e22a4b8e359ec690bbc35182cd1cf87c716b85 SHA512 5b371e6230c9ed4352ff151626dfaf40d2ecb41e389ee3a753fc41be3937191d416b864d555fd85cecbfe1615233a063db881adae3ea29aefb652a36d46633b5
200 changes: 200 additions & 0 deletions net-libs/signon-oauth2/files/0001-Port-QSignalSpys-to-PMF-syntax.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
From d3ba6d4c19ca0b1081fbafc757d3c496cc21ada2 Mon Sep 17 00:00:00 2001
From: Nicolas Fella <[email protected]>
Date: Sun, 15 Oct 2023 18:34:07 +0200
Subject: [PATCH 01/10] Port QSignalSpys to PMF syntax

---
tests/oauth2plugintest.cpp | 86 ++++++++++++++++----------------------
1 file changed, 37 insertions(+), 49 deletions(-)

diff --git a/tests/oauth2plugintest.cpp b/tests/oauth2plugintest.cpp
index 94e5c43..b257dc7 100644
--- a/tests/oauth2plugintest.cpp
+++ b/tests/oauth2plugintest.cpp
@@ -244,7 +244,7 @@ void OAuth2PluginTest::testPluginCancel()
m_testPlugin->cancel();

//then real cancel
- QSignalSpy pluginError(m_testPlugin, SIGNAL(error(const SignOn::Error &)));
+ QSignalSpy pluginError(m_testPlugin, &Plugin::error);

OAuth2PluginData userAgentData;
userAgentData.setHost("https://localhost");
@@ -435,11 +435,10 @@ void OAuth2PluginTest::testPluginProcess()
QFETCH(QVariantMap, response);
QFETCH(QVariantMap, stored);

- QSignalSpy result(m_testPlugin, SIGNAL(result(const SignOn::SessionData&)));
- QSignalSpy error(m_testPlugin, SIGNAL(error(const SignOn::Error &)));
- QSignalSpy userActionRequired(m_testPlugin,
- SIGNAL(userActionRequired(const SignOn::UiSessionData&)));
- QSignalSpy store(m_testPlugin, SIGNAL(store(const SignOn::SessionData&)));
+ QSignalSpy result(m_testPlugin, &Plugin::result);
+ QSignalSpy error(m_testPlugin, &Plugin::error);
+ QSignalSpy userActionRequired(m_testPlugin, &Plugin::userActionRequired);
+ QSignalSpy store(m_testPlugin, &Plugin::store);

m_testPlugin->process(sessionData, mechanism);
if (errorCode < 0) {
@@ -696,11 +695,10 @@ void OAuth2PluginTest::testPluginHmacSha1Process()
QFETCH(QVariantMap, response);
QFETCH(QVariantMap, stored);

- QSignalSpy result(m_testPlugin, SIGNAL(result(const SignOn::SessionData&)));
- QSignalSpy error(m_testPlugin, SIGNAL(error(const SignOn::Error &)));
- QSignalSpy userActionRequired(m_testPlugin,
- SIGNAL(userActionRequired(const SignOn::UiSessionData&)));
- QSignalSpy store(m_testPlugin, SIGNAL(store(const SignOn::SessionData&)));
+ QSignalSpy result(m_testPlugin, &Plugin::result);
+ QSignalSpy error(m_testPlugin, &Plugin::error);
+ QSignalSpy userActionRequired(m_testPlugin, &Plugin::userActionRequired);
+ QSignalSpy store(m_testPlugin, &Plugin::store);

TestNetworkAccessManager *nam = new TestNetworkAccessManager;
m_testPlugin->m_networkAccessManager = nam;
@@ -777,11 +775,10 @@ void OAuth2PluginTest::testPluginUseragentUserActionFinished()
QStringList scopes = QStringList() << "scope1" << "scope2";
data.setScope(scopes);

- QSignalSpy resultSpy(m_testPlugin, SIGNAL(result(const SignOn::SessionData&)));
- QSignalSpy error(m_testPlugin, SIGNAL(error(const SignOn::Error &)));
- QSignalSpy userActionRequired(m_testPlugin,
- SIGNAL(userActionRequired(const SignOn::UiSessionData&)));
- QSignalSpy store(m_testPlugin, SIGNAL(store(const SignOn::SessionData&)));
+ QSignalSpy resultSpy(m_testPlugin, &Plugin::result);
+ QSignalSpy error(m_testPlugin, &Plugin::error);
+ QSignalSpy userActionRequired(m_testPlugin, &Plugin::userActionRequired);
+ QSignalSpy store(m_testPlugin, &Plugin::store);

m_testPlugin->process(data, QString("user_agent"));

@@ -1286,10 +1283,9 @@ void OAuth2PluginTest::testPluginWebserverUserActionFinished()
data.setScope(QStringList() << "one" << "two" << "three");
data.setDisableStateParameter(disableStateParameter);

- QSignalSpy result(m_testPlugin, SIGNAL(result(const SignOn::SessionData&)));
- QSignalSpy error(m_testPlugin, SIGNAL(error(const SignOn::Error &)));
- QSignalSpy userActionRequired(m_testPlugin,
- SIGNAL(userActionRequired(const SignOn::UiSessionData&)));
+ QSignalSpy result(m_testPlugin, &Plugin::result);
+ QSignalSpy error(m_testPlugin, &Plugin::error);
+ QSignalSpy userActionRequired(m_testPlugin, &Plugin::userActionRequired);

TestNetworkAccessManager *nam = new TestNetworkAccessManager;
m_testPlugin->m_networkAccessManager = nam;
@@ -1362,9 +1358,8 @@ void OAuth2PluginTest::testUserActionFinishedErrors()
data.setClientSecret("fa28f40b5a1f8c1d5628963d880636fbkjkjkj");
data.setRedirectUri("http://localhost/resp.html");

- QSignalSpy error(m_testPlugin, SIGNAL(error(const SignOn::Error &)));
- QSignalSpy userActionRequired(m_testPlugin,
- SIGNAL(userActionRequired(const SignOn::UiSessionData&)));
+ QSignalSpy error(m_testPlugin, &Plugin::error);
+ QSignalSpy userActionRequired(m_testPlugin, &Plugin::userActionRequired);

m_testPlugin->process(data, QString("web_server"));
QTRY_COMPARE(userActionRequired.count(), 1);
@@ -1486,10 +1481,9 @@ void OAuth2PluginTest::testOauth1UserActionFinished()
data.setConsumerSecret("fa28f40b5a1f8c1d5628963d880636fbkjkjkj");
data.setRealm("MyHost");

- QSignalSpy result(m_testPlugin, SIGNAL(result(const SignOn::SessionData&)));
- QSignalSpy error(m_testPlugin, SIGNAL(error(const SignOn::Error &)));
- QSignalSpy userActionRequired(m_testPlugin,
- SIGNAL(userActionRequired(const SignOn::UiSessionData&)));
+ QSignalSpy result(m_testPlugin, &Plugin::result);
+ QSignalSpy error(m_testPlugin, &Plugin::error);
+ QSignalSpy userActionRequired(m_testPlugin, &Plugin::userActionRequired);

TestNetworkAccessManager *nam = new TestNetworkAccessManager;
m_testPlugin->m_networkAccessManager = nam;
@@ -1610,9 +1604,8 @@ void OAuth2PluginTest::testOAuth2Errors()
data.setClientSecret("fa28f40b5a1f8c1d5628963d880636fbkjkjkj");
data.setRedirectUri("http://localhost/resp.html");

- QSignalSpy error(m_testPlugin, SIGNAL(error(const SignOn::Error &)));
- QSignalSpy userActionRequired(m_testPlugin,
- SIGNAL(userActionRequired(const SignOn::UiSessionData&)));
+ QSignalSpy error(m_testPlugin, &Plugin::error);
+ QSignalSpy userActionRequired(m_testPlugin, &Plugin::userActionRequired);

TestNetworkAccessManager *nam = new TestNetworkAccessManager;
m_testPlugin->m_networkAccessManager = nam;
@@ -1683,8 +1676,8 @@ void OAuth2PluginTest::testRefreshToken()

SignOn::UiSessionData info;

- QSignalSpy result(m_testPlugin, SIGNAL(result(const SignOn::SessionData&)));
- QSignalSpy error(m_testPlugin, SIGNAL(error(const SignOn::Error &)));
+ QSignalSpy result(m_testPlugin, &Plugin::result);
+ QSignalSpy error(m_testPlugin, &Plugin::error);

TestNetworkAccessManager *nam = new TestNetworkAccessManager;
m_testPlugin->m_networkAccessManager = nam;
@@ -1766,9 +1759,8 @@ void OAuth2PluginTest::testRefreshTokenError()

SignOn::UiSessionData info;

- QSignalSpy error(m_testPlugin, SIGNAL(error(const SignOn::Error &)));
- QSignalSpy userActionRequired(m_testPlugin,
- SIGNAL(userActionRequired(const SignOn::UiSessionData&)));
+ QSignalSpy error(m_testPlugin, &Plugin::error);
+ QSignalSpy userActionRequired(m_testPlugin, &Plugin::userActionRequired);

TestNetworkAccessManager *nam = new TestNetworkAccessManager;
m_testPlugin->m_networkAccessManager = nam;
@@ -1842,10 +1834,9 @@ void OAuth2PluginTest::testClientAuthentication()
data.setRedirectUri("http://localhost/resp.html");
data.setForceClientAuthViaRequestBody(forceAuthViaRequestBody);

- QSignalSpy result(m_testPlugin, SIGNAL(result(const SignOn::SessionData&)));
- QSignalSpy error(m_testPlugin, SIGNAL(error(const SignOn::Error &)));
- QSignalSpy userActionRequired(m_testPlugin,
- SIGNAL(userActionRequired(const SignOn::UiSessionData&)));
+ QSignalSpy result(m_testPlugin, &Plugin::result);
+ QSignalSpy error(m_testPlugin, &Plugin::error);
+ QSignalSpy userActionRequired(m_testPlugin, &Plugin::userActionRequired);

TestNetworkAccessManager *nam = new TestNetworkAccessManager;
m_testPlugin->m_networkAccessManager = nam;
@@ -1908,10 +1899,9 @@ void OAuth2PluginTest::testTokenPath()
data.setClientId("104660106251471");
data.setRedirectUri("http://localhost/resp.html");

- QSignalSpy result(m_testPlugin, SIGNAL(result(const SignOn::SessionData&)));
- QSignalSpy error(m_testPlugin, SIGNAL(error(const SignOn::Error &)));
- QSignalSpy userActionRequired(m_testPlugin,
- SIGNAL(userActionRequired(const SignOn::UiSessionData&)));
+ QSignalSpy result(m_testPlugin, &Plugin::result);
+ QSignalSpy error(m_testPlugin, &Plugin::error);
+ QSignalSpy userActionRequired(m_testPlugin, &Plugin::userActionRequired);

TestNetworkAccessManager *nam = new TestNetworkAccessManager;
m_testPlugin->m_networkAccessManager = nam;
@@ -1995,10 +1985,9 @@ void OAuth2PluginTest::testTokenQuery()
data.setClientId("104660106251471");
data.setRedirectUri("http://localhost/resp.html");

- QSignalSpy result(m_testPlugin, SIGNAL(result(const SignOn::SessionData&)));
- QSignalSpy error(m_testPlugin, SIGNAL(error(const SignOn::Error &)));
- QSignalSpy userActionRequired(m_testPlugin,
- SIGNAL(userActionRequired(const SignOn::UiSessionData&)));
+ QSignalSpy result(m_testPlugin, &Plugin::result);
+ QSignalSpy error(m_testPlugin, &Plugin::error);
+ QSignalSpy userActionRequired(m_testPlugin, &Plugin::userActionRequired);

QScopedPointer<TestNetworkAccessManager> nam(new TestNetworkAccessManager);
m_testPlugin->m_networkAccessManager = nam.data();
@@ -2062,8 +2051,7 @@ void OAuth2PluginTest::testOAuth2AuthRequestUri()
QFETCH(QVariantMap, sessionData);
QFETCH(QString, expectedUri);

- QSignalSpy userActionRequired(m_testPlugin,
- SIGNAL(userActionRequired(const SignOn::UiSessionData&)));
+ QSignalSpy userActionRequired(m_testPlugin, &Plugin::userActionRequired);

m_testPlugin->process(sessionData, mechanism);
QCOMPARE(userActionRequired.count(), 1);
--
2.43.0

101 changes: 101 additions & 0 deletions net-libs/signon-oauth2/files/0002-Port-to-new-connection-syntax.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
From a0b372dfb6d37d0a81a545239128fec5ee94283c Mon Sep 17 00:00:00 2001
From: Nicolas Fella <[email protected]>
Date: Sun, 15 Oct 2023 18:51:29 +0200
Subject: [PATCH 02/10] Port to new connection syntax

---
example/oauthclient.cpp | 8 ++++----
src/base-plugin.cpp | 12 ++++++------
src/plugin.cpp | 18 ++++++------------
tests/oauth2plugintest.cpp | 4 ++--
4 files changed, 18 insertions(+), 24 deletions(-)

diff --git a/example/oauthclient.cpp b/example/oauthclient.cpp
index adfcabf..328e8b7 100644
--- a/example/oauthclient.cpp
+++ b/example/oauthclient.cpp
@@ -47,10 +47,10 @@ OAuthClient::~OAuthClient()
void OAuthClient::authenticate()
{
SignOn::AuthSession *m_session = m_identity->createSession("oauth2");
- QObject::connect(m_session, SIGNAL(response(const SignOn::SessionData &)),
- this, SLOT(onResponse(const SignOn::SessionData &)));
- QObject::connect(m_session, SIGNAL(error(const SignOn::Error &)),
- this, SLOT(onError(const SignOn::Error &)));
+ QObject::connect(m_session, &SignOn::AuthSession::response,
+ this, &OAuthClient::onResponse);
+ QObject::connect(m_session, &SignOn::AuthSession::error,
+ this, &OAuthClient::onError);

OAuth2PluginData data;
data.setHost("www.facebook.com");
diff --git a/src/base-plugin.cpp b/src/base-plugin.cpp
index aa2d639..d5ce81c 100644
--- a/src/base-plugin.cpp
+++ b/src/base-plugin.cpp
@@ -124,12 +124,12 @@ void BasePlugin::postRequest(const QNetworkRequest &request,
Q_D(BasePlugin);

d->m_reply = d->m_networkAccessManager->post(request, data);
- connect(d->m_reply, SIGNAL(finished()),
- this, SLOT(onPostFinished()));
- connect(d->m_reply, SIGNAL(error(QNetworkReply::NetworkError)),
- this, SLOT(onNetworkError(QNetworkReply::NetworkError)));
- connect(d->m_reply, SIGNAL(sslErrors(QList<QSslError>)),
- this, SLOT(handleSslErrors(QList<QSslError>)));
+ connect(d->m_reply, &QNetworkReply::finished,
+ this, &BasePlugin::onPostFinished);
+ connect(d->m_reply, &QNetworkReply::error,
+ this, &BasePlugin::onNetworkError);
+ connect(d->m_reply, &QNetworkReply::sslErrors,
+ this, &BasePlugin::handleSslErrors);
}

void BasePlugin::serverReply(QNetworkReply *reply)
diff --git a/src/plugin.cpp b/src/plugin.cpp
index e6af807..c764609 100644
--- a/src/plugin.cpp
+++ b/src/plugin.cpp
@@ -107,18 +107,12 @@ void Plugin::process(const SignOn::SessionData &inData,
impl->setNetworkAccessManager(m_networkAccessManager);

// Forward the signals from the implementation
- connect(impl, SIGNAL(result(const SignOn::SessionData &)),
- SIGNAL(result(const SignOn::SessionData &)));
- connect(impl, SIGNAL(store(const SignOn::SessionData &)),
- SIGNAL(store(const SignOn::SessionData &)));
- connect(impl, SIGNAL(error(const SignOn::Error &)),
- SIGNAL(error(const SignOn::Error &)));
- connect(impl, SIGNAL(userActionRequired(const SignOn::UiSessionData &)),
- SIGNAL(userActionRequired(const SignOn::UiSessionData &)));
- connect(impl, SIGNAL(refreshed(const SignOn::UiSessionData &)),
- SIGNAL(refreshed(const SignOn::UiSessionData &)));
- connect(impl, SIGNAL(statusChanged(const AuthPluginState, const QString&)),
- SIGNAL(statusChanged(const AuthPluginState, const QString&)));
+ connect(impl, &BasePlugin::result, this, &Plugin::result);
+ connect(impl, &BasePlugin::store, this, &Plugin::store);
+ connect(impl, &BasePlugin::error, this, &Plugin::error);
+ connect(impl, &BasePlugin::userActionRequired, this, &Plugin::userActionRequired);
+ connect(impl, &BasePlugin::refreshed, this, &Plugin::refreshed);
+ connect(impl, &BasePlugin::statusChanged, this, &Plugin::statusChanged);

impl->process(inData, mechanism);
}
diff --git a/tests/oauth2plugintest.cpp b/tests/oauth2plugintest.cpp
index b257dc7..9e16950 100644
--- a/tests/oauth2plugintest.cpp
+++ b/tests/oauth2plugintest.cpp
@@ -142,8 +142,8 @@ public:
open(ReadOnly | Unbuffered);
setHeader(QNetworkRequest::ContentLengthHeader, QVariant(content.size()));

- QTimer::singleShot(0, this, SIGNAL(readyRead()));
- QTimer::singleShot(10, this, SLOT(finish()));
+ QTimer::singleShot(0, this, &TestNetworkReply::readyRead);
+ QTimer::singleShot(10, this, &TestNetworkReply::finish);
}

public Q_SLOTS:
--
2.43.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
From 8211fd4a3ca31370069c6953db1589c1110dca90 Mon Sep 17 00:00:00 2001
From: Nicolas Fella <[email protected]>
Date: Sun, 15 Oct 2023 18:59:12 +0200
Subject: [PATCH 03/10] Port away from deprecated error() signal

---
src/base-plugin.cpp | 7 ++++++-
tests/oauth2plugintest.cpp | 8 +++++++-
2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/base-plugin.cpp b/src/base-plugin.cpp
index d5ce81c..ffc8ad5 100644
--- a/src/base-plugin.cpp
+++ b/src/base-plugin.cpp
@@ -126,8 +126,13 @@ void BasePlugin::postRequest(const QNetworkRequest &request,
d->m_reply = d->m_networkAccessManager->post(request, data);
connect(d->m_reply, &QNetworkReply::finished,
this, &BasePlugin::onPostFinished);
- connect(d->m_reply, &QNetworkReply::error,
+#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
+ connect(d->m_reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error),
this, &BasePlugin::onNetworkError);
+#else
+ connect(d->m_reply, &QNetworkReply::errorOccurred,
+ this, &BasePlugin::onNetworkError);
+#endif
connect(d->m_reply, &QNetworkReply::sslErrors,
this, &BasePlugin::handleSslErrors);
}
diff --git a/tests/oauth2plugintest.cpp b/tests/oauth2plugintest.cpp
index 9e16950..f5221cc 100644
--- a/tests/oauth2plugintest.cpp
+++ b/tests/oauth2plugintest.cpp
@@ -148,7 +148,13 @@ public:

public Q_SLOTS:
void finish() { setFinished(true); Q_EMIT finished(); }
- void fail() { Q_EMIT error(error()); }
+ void fail() {
+#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
+ Q_EMIT error(error());
+#else
+ Q_EMIT errorOccurred(error());
+#endif
+ }

protected:
void abort() Q_DECL_OVERRIDE {}
--
2.43.0

Loading

0 comments on commit 0bb749c

Please sign in to comment.