summaryrefslogtreecommitdiffstats
path: root/tests/auto/oauthhttpserverreplyhandler
Commit message (Collapse)AuthorAgeFilesLines
* Mark the whole repo with QT_NO_URL_CAST_FROM_STRINGAhmad Samir6 days1-9/+9
| | | | | | Pick-to: 6.11 Change-Id: I8bd4e61bcbd957defb117ef16189033c903efcd0 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Add testcase for different token response content formatsJuha Vuolle2025-01-301-0/+73
| | | | | | | | Basically just to add test coverage. Pick-to: 6.9 6.8 Change-Id: I4fed6054c369e1ee4f5c8692b7e1645341dafb3a Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Rename networkReplyErrors() testcase to tokenReplyErrors()Juha Vuolle2025-01-301-4/+4
| | | | | | | | | | This better captures what the test is about. Amends: 08f30372a7d3a08d566be5598ac4a37f564f0aeb Pick-to: 6.9 6.8 Change-Id: I4ea60c1b50fc5101555ea51fe5662742a4e802d8 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Make webserver and tlswebserver autotest utilities not a header-onlyJuha Vuolle2025-01-301-1/+1
| | | | | | | | | | Cleaner and more readable this way. As a drive-by, change include style to more conventional style Pick-to: 6.9 Task-number: QTBUG-131922 Change-Id: I35fa8f28240bf7b4c96ecc3c89d19556411f4d96 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Deprecate QOAuth2AuthorizationCodeFlow::accessTokenUrl propertyIvan Solovev2024-12-191-1/+1
| | | | | | | | | | | | | | | | | ... and schedule it for removal in Qt 7. Update most of the unit-test to use the new property, leaving just some of them with a conditional check, to make sure that the old API is still tested. [ChangeLog][QOAuth2AuthorizationCodeFlow] Deprecated accessTokenUrl property and scheduled it for removal in Qt 7. Use QAbstractOAuth2::tokenUrl instead. Task-number: QTBUG-132106 Pick-to: 6.9 Change-Id: I0bbb32854380268f8b7226859911b6fc3bd9289e Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
* Add a method to manually define http callback hostnameJuha Vuolle2024-12-041-10/+29
| | | | | | | | | | | | | | | This allows setting an arbitrary hostname in case 'localhost' or IP literal are not preferable: http://localhost:1234/cb // pre-existing http://127.0.0.1:1234/cb // pre-existing http://my.localnet:1234/cb // new, possible with this commit [ChangeLog][QOAuthHttpServerReplyHandler] Added new API for manually specifying the callback/redirect_uri hostname Task-number: QTBUG-130159 Change-Id: I0d218fc43ea0dec35383c03b313c7f9d5f0f8593 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Improve callback/redirect_uri hostname settingJuha Vuolle2024-12-041-2/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Setting hostname part of redirect uri (callback) is important part to get correct, because authorization servers often expect a verbatim match between what has been registered, and what is sent as part of authorization request. This commit clarifies and improves specifying the hostname part. Historically the callback host was fixed to "127.0.0.1" which has its drawbacks (and can be outright wrong). The situation was later improved by using "localhost" hostname, which correctly maps to both IPv4 and IPv6 interfaces. However, there are authorization servers which require the use of IP literals, and reject "localhost". To address these issues, this commit consists of: - Map Any, AnyIPv4, and AnyIPv6 to "localhost". This mapping is logical because "localhost" will work then independent of what the actual used address is - Map IPv4 and IPv6 loopback addresses (LocalHost, LocalHostIPv6) to their IP literals 127.0.0.1 and ::1 These are well-known IP literal addresses, and mapping them to "localhost" does not bring an advantage - If user has provided a string literal, use that directly - Change default address to "LocalHost", which maps to hostname "127.0.0.1". This, in part, undoes the changed behavior where the default changed to "localhost". With this change, users that don't define callback address shouldn't notice a difference to the very original behavior All in all these changes should improve the compatibility with various authorization servers and provide more flexibility to users. Amends: fd49b7f6543e7b49be7847624c64ee86c4272ccd Amends: 4e03167088181bf513adcfb8aac93fb8efb3f420 [ChangeLog][QOAuthHttpServerReplyHandler] Changed and clarified callback hostname handling (especially localhost vs. 127.0.0.1) Pick-to: 6.8 Fixes: QTBUG-130159 Change-Id: I25dfb996d10f95fe60bdb4f46ea848edcb2528be Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Add string literal suffix in an autotest caseJuha Vuolle2024-12-031-1/+1
| | | | | | | | | | Otherwise the string combinining is prune to problems with some platforms/compilers. Amends: 08f30372a7d3a08d566be5598ac4a37f564f0aeb Change-Id: I05aebf542adb52da9caff495d69d2d332b9c207e Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Fix and improve token request error reportingJuha Vuolle2024-11-292-0/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From QAbstractOAuth::Error documentation: NetworkError - Failed to connect to the server. ServerError - The server answered the request with an error, or its response was not successfully received The reply handler's usage of these error codes didn't match these criteria. Notably it used QNetworkReply::error() function, which mixes network, protocol, and HTTP status errors. As per OAuth RFC, it is common for the authorization server to respond with an HTTP error status like 400 Bad Request in case something is wrong either on the client-side or on the server-side. This commit makes a distinction between network/protocol errors, and errors where the server responded with an HTTP status (or errors which can be otherwise considered server-errors, like missing content-type header). Network/protocol errors are NetworkErrors, and other errors are ServerErrors. As a related change, one qCWarning is removed as redundant, because in practice tokenRequestErrorOccurred() handler also prints a warning. Also as a related change, empty JSON object branch was missing an error signal emission which is now added. Note: Picking this to branches earlier than 6.6 isn't particularly useful, because token request error reporting was introduced in 6.6. Prior to 6.6, an error results only in a qCWarning print, not an error signal emission. Amends: 32f29d3e227da206f262efa055d1cac895855a98 [ChangeLog][QOAuthHttpServerReplyHandler] Make a better distinction between NetworkErrors and ServerErrors with token requests. Pick-to: 6.8 Change-Id: I3ea8ca30da3e82867628ae5a90e2aa84e435d66d Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Add https support to QOAuthHttpServerReplyHandlerJuha Vuolle2024-11-143-0/+168
| | | | | | | | | [ChangeLog][QOAuthHttpServerReplyHandler] Added support for https localhost server Fixes: QTBUG-64615 Change-Id: Ic28c74bb382642077e791ea1e6cd0b3ed9ee2264 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Emit callbackDataReceived signalJuha Vuolle2024-07-221-0/+30
| | | | | | | | | | | The signal is documented but not emitted. [ChangeLog][QAbstractOAuthReplyHandler] Replyhandlers emit the callbackDataReceived() signal prior to parsing the data, as documented. Fixes: QTBUG-85377 Change-Id: I9f7d68b8174732cbbe617ce80301d07ee741f5b4 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Cache callback value / redirect_uri for later useJuha Vuolle2024-05-231-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to 'RFC 8252 Section 8.3' the loopback listening should be closed after receiving authorization response. There were however two things preventing application developers from doing this: 1) The callback (aka redirect_uri) is needed in the subsequent access token request (note: listening is not needed anymore). 2) The callback (aka redirect_uri) is currently used also in refresh token request (this is unnecessary though, and should be removed in a follow-up commit). But the problem for these two was that the QOAuthHttpServerReplyHandler::callback() code asserted (debug) or just returned a wrong value (release) if the handler wasn't listening. This made it unfeasible to close the handler in a timely manner. With this commit the callback/redirect_uri is cached, and consequently the handler can be closed immediately after authorization. Pick-to: 6.7 6.5 6.2 Fixes: QTBUG-124333 Change-Id: I063637029908ed4fa0390a0cb07511c92bd51874 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QOAuthHttpServerReplyHandler: add a test for a non-HTTP commandThiago Macieira2024-05-131-0/+28
| | | | | | | | | EHLO is SMTP. Pick-to: 6.7 Change-Id: Ie30a3caf09ef4176bb36fffd17cdba0ddd765c6a Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
* QOAuthHttpServerReplyHandler: fix parsing of parsed URIsThiago Macieira2024-05-131-0/+111
| | | | | | | | | | | Instead of constructing it via strings, just let QUrl parse it because it will do so properly. This fixes the incorrect handling of URIs requested that are a prefix to the URL we want to handle. Pick-to: 6.7 Change-Id: Ie30a3caf09ef4176bb36fffd17cdb59a516441aa Reviewed-by: Jesus Fernandez <jsfdez@gmail.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* tst_QOAuthHttpServerReplyHandler: fix infinite wait on failThiago Macieira2024-05-131-3/+8
| | | | | | | | Just add a timeout and use QTestEventLoop. Change-Id: Ie30a3caf09ef4176bb36fffd17cdb69a30b6b1ee Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
* Correct license for test filesLucie Gérard2024-03-261-1/+1
| | | | | | | | | | | | According to QUIP-18 [1], all test files should be LicenseRef-Qt-Commercial OR GPL-3.0-only [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: Ia7b5193dc62217ae8afb4a80725645e113dcc874 Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* Mark the whole repo with QT_NO_CONTEXTLESS_CONNECTAhmad Samir2023-08-221-2/+0
| | | | | | | | | | | By adding it to the default build flags via .cmake.conf. This amends commit 5ad5773f2388bfa74b16fd9108f3f00cbed06b43. Task-number: QTBUG-116296 Change-Id: Ifca206eb4831e22db1205bba3e295a29d3c83aec Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Build with QT_NO_CONTEXTLESS_CONNECTAhmad Samir2023-07-122-1/+3
| | | | | | | | | | | This disables the 3-arg QObject::connect() overload: QObject::connect(sender, signal, functor) For details see: https://lists.qt-project.org/pipermail/development/2023-July/044141.html Change-Id: If6e8d202b114d053933fc1dcab5b99377c67a879 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Port from container::count() and length() to size() - V4Marc Mutz2022-10-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); a.k.a qt-port-to-std-compatible-api V4 with config Scope: 'Container'. Change-Id: I9635ce1b96e5788e63a5b8d56ab226ffaf0270e7 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Port from container::count() and length() to size()Marc Mutz2022-10-071-1/+1
| | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o)); makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container', with the extended set of container classes recognized. Change-Id: I126d264a62c9db96ed1b3b37781d2eeea4e2acab Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-08-231-1/+1
| | | | | | | Task-number: QTBUG-105718 Change-Id: Id6065ca3122682b7ba7cf27480314b3d8fced417 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* CMake: Don't use PUBLIC_LIBRARIES for tests and test helpersAlexandru Croitor2022-07-281-1/+1
| | | | | Change-Id: I00b1993847909470f257a6d07e46069bd202c0dc Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* Add license headers to cmake filesLucie Gérard2022-07-071-0/+3
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I75a84023fdf965b72410e39bf40f81f7941d6d16 Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
* Use SPDX license identifiersLucie Gérard2022-06-161-27/+2
| | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. License files are organized under LICENSES directory. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: Ic012e87171ed4cef6871eff7d76f56994ea3ca1f Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
* Remove qmake project filesJoerg Bornemann2021-04-291-6/+0
| | | | | | | Task-number: QTBUG-88742 Change-Id: I97c112a9d2794881a75441591d17b2a0ce487cad Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* CMake: Regenerate projects to use new qt_internal_ APIAlexandru Croitor2020-10-011-1/+1
| | | | | | | | Modify special case locations to use the new API as well. Task-number: QTBUG-86815 Change-Id: I6dfd4a015e177bf868e38e5ac2916ea30615aa33 Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
* CMake: Regenerate projects after mergewip/cmakeAlexandru Croitor2020-03-241-2/+1
| | | | | | | Change-Id: Ie3dcf131d55db1b5d5a6271910785e4aac46140e Reviewed-by: Liang Qi <liang.qi@qt.io> Reviewed-by: Leander Beernaert <leander.beernaert@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Regenerate projectsAlexandru Croitor2019-11-151-1/+1
| | | | | | Change-Id: Ibc93c962abc8c82900babf695a83dcbec551de31 Reviewed-by: Qt CMake Build Bot Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Regenerate qtneworkauthAlexandru Croitor2019-09-301-1/+0
| | | | | | | | | | Fixes examples to be actually standalone examples. Also some special cases were added here and there. And some new changes that comes from the newer version of pro2cmake. Change-Id: I0053bb740e41b44bf793ec4e284283bf013eaac8 Reviewed-by: Qt CMake Build Bot Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* CMake Port for QtNetworkAuthLeander Beernaert2019-06-031-0/+19
| | | | | | | | | | | Convert the QtNetworkAuth project to be compatible with the cmake build system. Includes tests and examples. Added header guard to twitter.h to work with CMake's moc setup. Change-Id: I0762e0b53f4e3194c969655e4c3deae21768b327 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Bump copyright yearJesus Fernandez2017-07-121-1/+1
| | | | | Change-Id: Iaad9fb2096cd01a762c3eace90c6154b0d0ebe59 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* OAuth supportJesus Fernandez2016-08-192-0/+81
New library to support OAuth1 and OAuth2 standard in Qt. OAuth provides a method for clients to access server resources on behalf of a resource owner (such as a different client or an end-user). It also provides a process for end-users to authorize third-party access to their server resources without sharing their credentials (typically, a username and password pair), using user-agent redirections. [ChangeLog][OAuth] Added OAuth support Change-Id: I3971456f93bf6ddd7fd46f555202bab2eb777c15 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>