Commit Graph

1789 Commits (152153cb111db1bbd42e94f27712bbc39accf310)

Author SHA1 Message Date
Øystein Heskestad 85c3a2f544 Regenerate certificates for qsslserver auto-test
The 'not valid after' date was set to the last day of 9999 which the
date time parser could not handle. Set the expiry year to 2050 and
regenerate keys with length of 3072 bits instead of 2048 bits.

Fixes: QTBUG-129504
Change-Id: Iaede785264c1d31b021ccabc9d1aaf949c8922f2
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit a5364a279e9ed9bc69a13698f9b43dbe36d0a326)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-17 19:30:35 +00:00
Thiago Macieira 4374f3ce41 tst_QDnsLookup: don't add duplicate 'nameserver' lines
I don't know why systemd-resolved did have those for me, but it did, so
QtTest complains.

QWARN  : tst_QDnsLookup::setNameserver() Duplicate data tag "..." - please rename.

Change-Id: I8df70eb429682b529ecefffd0aca735f94d77225
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 1420ee85165c03bac2aa1678b295f7b1ebe44f51)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-03 03:43:03 +00:00
Thiago Macieira c2df419edf tst_QDnsLookup: add the ability to specify an alternate default server
For people running this test who are burdened with a broken DNS server
and for whom the check added in the previous commit fails, skipping the
test.

Incidentally, this is useful for developing QDnsLookup itself, because
some otherwise-reasonable servers are known to fail for some queries.
For example, dnsmasq doesn't like queries of type ANY:

SKIP   : tst_QDnsLookup::lookup(any-a-single) Server refused or was unable to answer query; a-single type ANY: Server failure
SKIP   : tst_QDnsLookup::lookup(any-a-plus-aaaa) Server refused or was unable to answer query; a-plus-aaaa type ANY: Server failure
SKIP   : tst_QDnsLookup::lookup(any-multi) Server refused or was unable to answer query; multi type ANY: Server failure

Now I can get it to pass with QTEST_DNS_SERVER='[2001:4860:4860::8888]':

PASS   : tst_QDnsLookup::lookup(any-a-single)
PASS   : tst_QDnsLookup::lookup(any-a-plus-aaaa)
PASS   : tst_QDnsLookup::lookup(any-multi)

Note for the future: setting a non-default server may exercise different
code paths inside QDnsLookup, so this is not a replacement for having
proper DNS servers in the CI.

Fixes: QTBUG-129335
Change-Id: I81dcd4834972efa84c9ffffdd8aaafb68f20560b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 10fea78bdcad2086c980fa1c1bbcd5bb543e4366)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-03 03:43:01 +00:00
Thiago Macieira 5ce4677f2e tst_QDnsLookup: check for DNS server sanity
Instead of failing tst_QDnsLookup and blaming the class for problems,
let's first verify that the resolver can resolve an address. If it can't
and we're not in the CI, then just skip the test.

I chose "a-multi" because a) it required the least variability in the
command-line and b) it has more than one RR in the RR set so it may find
more problems than "a-single".

Output when I forced a domain that doesn't exist:

QWARN  : tst_QDnsLookup::initTestCase() Default DNS server in this
system cannot correctly resolve "a-multix.test.qt-project.org"
QWARN  : tst_QDnsLookup::initTestCase() Please check if you are
connected to the Internet.
QDEBUG : tst_QDnsLookup::initTestCase() Output was:
Server:		127.0.0.53
Address:	127.0.0.53#53

** server can't find a-multix.test.qt-project.org: NXDOMAIN

SKIP   : tst_QDnsLookup::initTestCase() DNS server does not appear to
work

Task-number: QTBUG-129335
Change-Id: Id2dcc2ce7cfdd83c556ffffddb88a1f1b4339606
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 40986460e3f372cdb42ad80377455dc43b7cdb42)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-03 03:43:00 +00:00
Thiago Macieira ea871ee2e2 tst_QDnsLookup: don't require "localhost" to resolve
It must for QHostInfo, but DNS servers are not required to have that
label. It appears to be a good practice the majority of admins follow,
but it's not universal, so we cannot require it.

But if it does resolve, then RFC 2606 requires it resolve to 127.0.0.1.

Task-number: QTBUG-129335
Change-Id: Ib3b11de6616665658a20fffd754f2fbd78780b1c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 252bd7c67ce7a0ed3c41059f551f87f0f77b5606)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-03 03:42:59 +00:00
Tor Arne Vestbø fb69c5a354 tst_QDnsLookup::lookupReuse(): Rewrite using lookupCommon helper
Task-number: QTBUG-129335
Change-Id: I8417ff9e76076d0b1a40270edc1b2692a122657f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 41768db300b70dda36344ab1cafb6b99937da435)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-02 12:43:37 +00:00
Tor Arne Vestbø d8c7364ffe tst_Http2: Ensure each test uses temporary keychain if needed
The duplicateRequestsWithAborts test was missing this, causing failures
on macOS 14. Instead of adding it to each test function, we now set up
the temporary key chain in init(), and restore things in cleanup().

Task-number: QTBUG-119616
Change-Id: Ia9d80ae632774b8628417ad30d354a22b6a4916e
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit 882e5d72fc2dcca3c35035564fbb9ce5abc4bc4c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-28 16:00:58 +00:00
Timur Pocheptsov 3ba0bb61ad tst_QHostInfo: re-enable back the test on macOS
It went unnoticed (by me) the test was disabled via *.pro and later CMakeLists.txt
rather than BLACKLIST I was checking back then.

Fixes: QTBUG-129349
Change-Id: I509485bac9f32d544ef4bec120590a00d85ed608
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit e498a076ae035588ed6f29e91a20eb727d608342)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-26 18:10:35 +00:00
Michał Łoś 0c4f0b557e Enable compilation of qtbase with localserver off
Since we will need to turn off this feature for certain platforms, code
must compile with QT_FEATURE_localserver turned off, which now can't.
Fix this by disabling parts of code requiring QT_FEATURE_localserver.

Task-number: QTBUG-115777
Change-Id: I6d78030db67ee679d6877b48a437db90a6e47a02
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 5bbb05c72c8b8f2d33beae722a704a1c293a55ea)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-19 15:09:47 +00:00
Mårten Nordheim 16ed1fe089 tst_qnetworkreply: Speed up moreActivitySignals
Going from 40 seconds to 1.
The issue is that wait() doesn't care if there was
a signal emitted already, it will just wait 5 seconds for a new
one. But we don't care, we just want to know that there was 1.

Pick-to: 6.7 6.5
Change-Id: I96f1f00bc6171ccc6e5b2f033fa407de5cf0c0c3
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit 65494fbd3dff16d4476b5ac8c04df830d9fd61e6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-06 14:38:30 +00:00
Mårten Nordheim 6e98673846 tst_qnetworkreply: localhost may resolve to ipv4 and 6
On some platforms, localhost resolves to both ipv4 and ipv6 addresses.
In that case we might get multiple emissions of the
socketStartedConnecting signal, for Happy Eyeballs.

Pick-to: 6.7 6.5
Change-Id: Ib39a167bdde2089106c89a3e297cbb0ad2f357d9
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit 13a0f294b5ef2ec8a2057d72365f989ddf6290de)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-06 14:38:22 +00:00
Liang Qi 134f23d921 tests: blacklist tst_QTcpServer::qtbug6305() on macos-12 arm
Task-number: QTBUG-127568
Change-Id: I1651f3344c024c5448bf9d04b477b181ff6df97a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit c3abc0446cf792a52221b11132f55e933eba9f89)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-23 20:04:26 +00:00
Lena Biliaieva 88ae8785ef QHttp2Connection test: silence conversion warning
Follow-Up to: 6aa1cb05e357cf4221aaedd4cf742c45983af446

Change-Id: Ie355c2813f38aa6097fe3bbcdd1f021fd1f0d791
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
(cherry picked from commit 4a44a8a8a5768b3ffaa3cb00f995bfee792ca5c2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-14 12:20:34 +00:00
Mårten Nordheim a903414898 QNonContiguousByteDeviceByteArrayImpl: store value not pointer
Storing a pointer was fine when used with the QBuffer version, but
that means you have to keep the QBArray alive outside the class
itself.

Just store the value and it is a little easier to use.

Changes in this cherry-pick: The dev patch chain has the test update in
the wrong commit, so cherry-picked it along with this.
And apparently I also forgot to commit a bug-fix to this commit as well,
the bug anyway disappeared in dev when I deleted the class and
redirected everything to the ByteArray class.

Change-Id: Ic02e0b4627fde2b5fdd7e5fb69a94e06aa768ab9
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
(cherry picked from commit 67140afca21efae75aad35f63ca1d7211fe6ec3a)
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-08-08 00:33:14 +02:00
Matthias Rauter a3e4a7eecb Ensure that RST_STREAM is sent following RFC 9113
RFC 9913 differentiates between stream errors and connection errors.
Some error handling only requires stream errors in the form of
RST_STREAM frames, while other sever errors require connection errors
in the from of GOAWAY frames.

This patch streamlines the sending of RST_STREAM frames, and ensures
that they are sent whenever mandated by RFC 9113. In some cases this
was missing, in some cases we were sending connection errors instead
of stream errors.

Further this patch adds tests to ensure the correct behavior.

Fixes: QTBUG-122345
Pick-to: 6.7
Change-Id: Ic93ae7a358a4eb551aa23342a6683cdd5dd0abb0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit d17d260948e16549d82f1fdd4dec98d246b0622e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-07 19:56:20 +00:00
Mate Barany 59268b6d54 Change type of variable qssl_dhparams_default_base64
From const char* to const char[] to address a
"Character pointer is not const" Axivion warning.

Task-number: QTBUG-125026
Pick-to: 6.7 6.5
Change-Id: I0d6606c6abde5b01ec250ffb4595c89a497b7c29
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit fd8cec34965afc8ca6d7f5e844e8aab44e182c90)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-01 00:43:20 +00:00
Mårten Nordheim 78e167ab7b tst_http2: stabilize duplicateRequestsWithAborts for macos
The test relies on things ending up in the h2RequestsToSend container
internally. For h2c we would have to use the http1 upgrade mechanism,
and while I have not verified it, it seems to not reliably put
enough requests in the container, and so the test is flaky for macos,
which is the only platform where we use h2c. In CI at least.

Fix it by forcing it by using h2 direct, which will work even on macOS
without server-side ALPN.

Pick-to: 6.7 6.5 6.2
Change-Id: I55816d400baa831524100f075e1b50fd3d9781a6
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit 4e827e42e339a2774be26ba844bd5e87a14d83b5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-22 14:47:51 +00:00
Lena Biliaieva c373e728c8 QHttp2Connection: Add test for CONTINUATION frames
Task-number: QTBUG-122458
Change-Id: I6c87a7361852bb04173f0216e69cd7c5309a242b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 6aa1cb05e357cf4221aaedd4cf742c45983af446)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-17 10:32:58 +00:00
Marc Mutz 678c839575 QFormDataBuilder: add options
There are (at least) three RFCs, all non-obsolete, purporting to guard
the formatting of multipart/form-data filename parameters, and they
all disagree: RFC 6266, RFC 7578 and RFC 8187. There is also
considerable implementation divergence.

So, to not have to hard-code any one of the different strategies, add
Options controlling the formatting.

Found to be required in implementation review.

Task-number: QTBUG-125985
Change-Id: Ibc82ff8a3460580ee70eafcaf9b88de36751940d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
(cherry picked from commit 49ab4f156b7d1a0593f25680d0b841d2dc4c348e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-12 11:45:55 +00:00
Volker Hilsheimer 0d7b42d92b HTTP2: refactor setting of temporary key chain into helper
Remove duplicated comment and code that sets and resets the environment
variable. As a side effect, restore the environment variable to the
value that was set before overwriting it, instead of un-setting it
bluntly.

Pick-to: 6.7 6.5
Change-Id: Ife0b2631aff27dbcb23079c2162ffed797b351dc
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit f984a6ab7a99ace65e0d73c3f37ef6ad79dd0aa0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-10 01:50:21 +00:00
Volker Hilsheimer e25f619663 HTTP2: use temporary keychain in the abortOnEncrypted test function
On macOS with secure transport, set QT_SSL_USE_TEMPORARY_KEYCHAIN
environment variable to avoid the permission UI, which fails the test.

Amends b1e75376cc3adfc7da5502a277dfe9711f3e0536, and makes the test pass
reliably on a local machine.

Pick-to: 6.7 6.5 6.2 5.15 5.12
Change-Id: Id70ceaecfa523d5183236464fe6cfaf4cdbadf4a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 14a61026216d20eb3a2893420b7d51374e820b44)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-10 01:50:17 +00:00
Tor Arne Vestbø 5397e0ddd1 Blacklist tst_Http2::duplicateRequestsWithAborts on macOS ARM
Task-number: QTBUG-119616
Change-Id: Ic02d423ef8a0cb9ab71d293428cb7d66ced19cdf
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit c4249b0f1477597c0ae9b56df5f893bd1b337d83)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-08 11:30:37 +00:00
Mate Barany 04787eef80 Apply the PIMPL idiom to QFormDataPartBuilder
Change QFormDataBuilderPrivate to store a vector of
QFormDataPartBuilderPrivates and pimplify QFormDataPartBuilder such that
it stores a pointer to the QFormDataBuilderPrivate and an index into the
vector. This makes it robust against QFDP::m_parts reallocations and we
can make QFDBP copyable which has the benefit that if the user wants to
"go back" to an earlier part, she can do so by storing the result of the
original part() call by value.

Found in API review.

Task-number: QTBUG-125985
Change-Id: I56e9018e539457e9494751bdb62509f84a680889
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit aca8235c753d673abe7442cdf8b628fe4e05c471)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-05 15:55:31 +00:00
Mårten Nordheim 0fb43e4395 HTTP2: Delay any communication until encrypted() can be responded to
We have the encrypted() signal that lets users do extra checks on the
established connection. It is emitted as BlockingQueued, so the HTTP
thread stalls until it is done emitting. Users can potentially call
abort() on the QNetworkReply at that point, which is passed as a Queued
call back to the HTTP thread. That means that any currently queued
signal emission will be processed before the abort() call is processed.

In the case of HTTP2 it is a little special since it is multiplexed and
the code is built to start requests as they are available. This means
that, while the code worked fine for HTTP1, since one connection only
has one request, it is not working for HTTP2, since we try to send more
requests in-between the encrypted() signal and the abort() call.

This patch changes the code to delay any communication until the
encrypted() signal has been emitted and processed, for HTTP2 only.
It's done by adding a few booleans, both to know that we have to return
early and so we can keep track of what events arose and what we need to
resume once enough time has passed that any abort() call must have been
processed.

Fixes: QTBUG-126610
Pick-to: 6.7 6.5 6.2 5.15 5.12
Change-Id: Ic25a600c278203256e35f541026f34a8783235ae
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit b1e75376cc3adfc7da5502a277dfe9711f3e0536)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-07-03 06:02:32 +00:00
Marc Mutz e2ffa8ddf6 Port tst_QFormDataBuilder to new style [6/6]: picksUtf8NameEncodingIfAsciiDoesNotSuffice()
We don't want to have to rely on QDebug:toString() and the private
QFormDataPartBuilder::build() function for checks, so use the
framework originally introduced by Máté for the the moveSemantics()
test for picksUtf8NameEncodingIfAsciiDoesNotSuffice(), too.

Requires to revert the needles from QString back to QByteArray.

This completes the port away from QFormDataPartBuilder::build() use in
the tests, allowing us to remove the tst_QFormDataBuilder friend
declaration and unexport build().

Task-number: QTBUG-125985
Change-Id: Icae84f54c6f768e097b36b4c4f964eeb6d676809
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
(cherry picked from commit d0b0fe76663a4c7fe007cb66afa936ea7fe3d918)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-20 23:11:01 +00:00
Marc Mutz 53d9f99a08 Port tst_QFormDataBuilder to new style [5/6]: specifyMimeType()
We don't want to have to rely on QDebug:toString() and the private
QFormDataPartBuilder::build() function for checks, so use the
framework originally introduced by Máté for the the moveSemantics()
test for specifyMimeType(), too.

Requires to actually open the QBuffer and to revert the needles from
QString back to QByteArray.

Also anchor the needle between two CRLFs, because they each represent
one full header field. This is like anchoring a regex with ^~~~$.

As a drive-by, use QVERIFY2().

Task-number: QTBUG-125985
Change-Id: I8f7830e49d05044ef7388338498c96334a489c90
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
(cherry picked from commit 9bcf320fc1d3b484a39d692fd2c69c96f05e63e4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-20 23:10:55 +00:00
Marc Mutz 1fc54987d4 Port tst_QFormDataBuilder to new style [4/6]: setHeadersDoesNotAffectHeaderFieldsManagedByBuilder()
We don't want to have to rely on QDebug:toString() and the private
QFormDataPartBuilder::build() function for checks, so use the
framework originally introduced by Máté for the the moveSemantics()
test for setHeadersDoesNotAffectHeaderFieldsManagedByBuilder(), too.

Requires to actually open the QBuffer and to revert the needles from
QString back to QByteArray.

Also anchor the needles with a CRLF on each side, because they each
represent one full header field. This is like anchoring a regex using
^~~~$.

As a drive-by, fix indentation and brace placement of initializer_list
QList consruction and rely on CTAD to deduce QByteArrayList from QList{}.

Task-number: QTBUG-125985
Change-Id: I405b5d67212e906a3b914d9e5b815835bdee5bc6
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
(cherry picked from commit ab859d5f96855eeec50f3b39c925203ba7def73f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-20 23:10:47 +00:00
Marc Mutz a8f7a59b07 tst_QFormDataBuilder: give \r\n a symbolic name
... CRLF, what else?

Change-Id: Ibefb83495c34034a6727a0eaa42d8b312e0594ac
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
(cherry picked from commit aeb1b9b48746395fc6680aa3fdda3469826b7ae8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-20 23:10:41 +00:00
Marc Mutz df6a26d9f0 Port tst_QFormDataBuilder to new style [3/6]: picksUtf8FilenameEncodingIfAsciiDontSuffice()
We don't want to have to rely on QDebug:toString() and the private
QFormDataPartBuilder::build() function for checks, so use the
framework originally introduced by Máté for the the moveSemantics()
test for picksUtf8FilenameEncodingIfAsciiDontSuffice(), too.

Requires to actually open the QBuffer and to revert the needles from
QString back to QByteArray.

Task-number: QTBUG-125985
Change-Id: I13c41e8df86296ae8652c460039798eb529d4628
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
(cherry picked from commit 2541f1945d2a64de7b2c13465a178ef70d96da89)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-20 23:10:35 +00:00
Marc Mutz 95590adb55 Port tst_QFormDataBuilder to new style [2/6]: escapesBackslashAndQuotesInFilenameAndName()
We don't want to have to rely on QDebug:toString() and the private
QFormDataPartBuilder::build() function for checks, so use the
framework originally introduced by Máté for the the moveSemantics()
test for escapesBackslashAndQuotesInFilenameAndName(), too.

Requires to actually open dummy_file (so make it a QBuffer, because
there's no file of that name in the filesystem) and to revert the
needles from QString back to QByteArray.

Task-number: QTBUG-125985
Change-Id: I888b3cac45ed24b2e877dc1642a95e3f1d64f2ff
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
(cherry picked from commit 14f68c9d44472966a66b5cf3b16f4fc7f60068ca)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-20 23:10:28 +00:00
Marc Mutz 7c9e8b1613 Port tst_QFormDataBuilder to new style [1/6]: generateQHttpPartWithDevice()
We don't want to have to rely on QDebug:toString() and the private
QFormDataPartBuilder::build() function for checks, so use the
framework originally introduced by Máté for the the moveSemantics()
test for generateQHttpPartWithDevice(), too.

Requires to actually open data_file and to revert the needles from
QString back to QByteArray.

Task-number: QTBUG-125985
Change-Id: Ie4518fedb58530ae98b44f1ba9e000e6f088ba86
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
(cherry picked from commit 4b21146ded83badfeb9f2c905f6602ff460adc63)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-20 23:10:22 +00:00
Marc Mutz ac1e88f58a tst_QFormDataBuilder: DRY the moveSemantics() test
Packages everything needed to build the actual serialization into a
helper function that's parametrized with a function_ref. Said helper
provides the function_ref with a default-constructed QFormDataBuilder
as an argument to the function, but since we're checking move
semantics here, it also expects to receive, via the return type, the
builder object to eventually use for building. This need not be the
same as the one it originally supplied.

If this looks a bit complicated, it's a necessary evil for
conveniently rolling out this way of performing the test to the rest
of the test functions, to eventually, finally get rid of using QDebug
to introspect individual QHttpParts when, in reality, we're only
interested in the QHttpMultiPart's wire serialization (iow: the
observable behavior).

Centralize the QSKIP in the helper function. This increases compile
coverage of the rest of the code, but requires QTEST_THROW_ON_SKIP,
so add a check for that alongside the QTEST_THROW_ON_FAIL one.

Task-number: QTBUG-125985
Change-Id: Ib6217a02159c79f48f0036e90d7bbbf43e69d0ba
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
(cherry picked from commit 9fcafa715ecb1c6e45fc51d599178bbde3cc1b12)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-20 23:10:15 +00:00
Marc Mutz 511e7fc9e8 tst_QFormDataBuilder: QVERIFY that QIODevice::open() succeeded
... so we don't have to guess around when the follow-up
checkBodyPartsAreEquivalent() fails.

Task-number: QTBUG-125985
Change-Id: I008eb7a1fa1c5457a5405838730d9e98b1cc20b4
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
(cherry picked from commit 4da130838ba0a0f4f7c659f8c58f7bb4304b032c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-20 23:10:08 +00:00
Mate Barany 4ca0c6db5e Add move semantics autotest for QFormDataBuilder
Change-Id: If9df38f0afd09218c15587b2864edb957cbbdaac
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 12d2ba9c913d03d637ffb9d123949a5f45e69e5e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-20 19:30:13 +00:00
Juha Vuolle 78784065a8 Accept QASV for multipart 'name' field
And adjust the encoding of 'name' parameter to  always
use UTF-8 / ASCII. This aligns with how other frameworks
behave. Also amended docs to recommend ASCII for 'name'.

Found in API review.

Change-Id: I54d1148bf95dece54b75c76914c49985da05e0b2
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 6b23a3c5e4316c5f889ea5e9bbfd785b78716268)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-18 17:08:34 +00:00
Juha Vuolle b5dde79bc4 Adjust multipart 'filename' parameter encoding
The RFCs around these encodings are loose and allow
several ways for dealing with non-ASCII characters.
The encoding introduced in this commit should be
interoperable and aligns with other frameworks
(checked Curl, JS FormData, Postman, and Python
requests).

This consists of several adjustments:

1. Enclose the filename attribute in double quotes
2. If filename contains only ASCII characters, use them as-is
3. If filename contains characters beyond ASCII:
3.1. Encode them directly as raw UTF-8 to filename=
3.2. Set an additional filename*= parameter with
     percent encoded UTF-8. This is a legacy encoding
     for compatibility.

Task-number: QTBUG-125985
Change-Id: I5a6ad5388e4bb69e142caa7f6de7127526f441ad
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 8c8a0c06d4f77ba8a707ec0a101b423543bf30f0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-18 17:08:31 +00:00
Mate Barany 0a57b0e542 Refactor test cases in tst_qformdatabuilder
Hide the construction details of QFormDataPartBuilder, change
the verification to be QString based instead of QByteArray based,
and use raw string literals (where useful) for readability.

Task-number: QTBUG-114647
Change-Id: I16fb6c943cf6fd7385e78bbffe3b2780ab0a6ac8
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit cb8abb718da4e18232de525ef1bb611f3a5dd929)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-18 17:08:21 +00:00
Juha Vuolle 34f6210bb6 Relax QHttpHeaders value field checks to allow UTF-8
UTF-8 doesn't per se contain illegal characters from
an HTTP header RFC point of view. UTF-8 is the dominant
character encoding outside of ASCII, and is used
directly at least with HTTP multipart headers.

[ChangeLog][QtNetwork][QHttpHeaders] Allows UTF-8 in header
values now.

Task-number: QTBUG-125985
Pick-to: 6.7
Change-Id: I2d8d8f00855c96c1d2ba190f2e27e2d48fcd4975
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit f39b39b8c72b5c3428396d5e74cf15cafd5bbc42)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-18 04:53:43 +00:00
Marc Mutz 8bc09e9db3 tst_QNetworkReply: port _WITH_TIMEOUT calls to chrono literals
Dogfooding the new 6.8 feature.

Change-Id: Ic4c371896fcab0c94cef76341a6ef97763127968
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit 34089abeeac14a6437851530aa25f8b31a22acf1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-17 23:17:49 +00:00
Łukasz Matysiak 45d87f7bab Skip tst_QNetworkReply::contentEncodingBigPayload on 32b arch
The test requires allocating 4GB of memory to handle a big file.
On a 32b architecture, this leads to a std::bad_alloc exception and
abort in result (tested on VxWorks 24.03 on an imx6 board).
Because of that, the test can't work properly and it can't be
blacklisted.

Work around the issue by skipping the test.

Pick-to: 6.7
Task-number: QTBUG-115777
Change-Id: I46002a27aed09706cd61d2e2c8d4bd1e12a16c36
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 4d2744e4345193cdf7ec2bbf06b0a0d169827d8b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-14 14:59:03 +00:00
Mate Barany 885a49548d Add some missing tests for QFormDataBuilder
Test the setHeaders method and the option of manually setting the mime
type.

Task-number: QTBUG-114647
Change-Id: I86644b243830259156e60239adf370e5894450dc
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
(cherry picked from commit 132498a69a626be6feaf1855cf63dd79d1ac9445)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-13 20:34:42 +00:00
Mårten Nordheim dbb945fd43 Update public suffix list
Version 903a83ff7bfc3148e3692e09396f9f3bdc9462ef, fetched on
2024-06-05.

[ChangeLog][Third-Party Code] Updated the public suffix list to upstream
SHA 903a83ff7bfc3148e3692e09396f9f3bdc9462ef.

Pick-to: 6.7 6.5 6.2 5.15
Task-number: QTBUG-126060
Change-Id: I96320b5df1a3573ab9198ad412fc1eca55204c02
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit c0d5c1b2fef140a44b6512ee79ba7fb67187a39c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-06-07 06:59:21 +00:00
Jari Helaakoski 313392ec6b Fix compilation issues when configuration features are disabled
Commit fixes settings and http features

Task-number: QTBUG-122999
Change-Id: Iff94e9e4f7122a35000376e59cdea2a93e6a7f40
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit ba672abfaed6fa8adde44b32c7f43c91630b5eeb)
2024-06-05 08:55:18 +00:00
Marc Mutz 5677c111cb QFormData(Part)Builder: simplify filename formatting
We don't need the bodyName member, because it's the same as
originalBodyName, just encoded, and we can delay the encoding to
build() time.

This is not worse than the old code, since we anyway toString() the
QAnyStringView unconditionally.

So we don't need to visit the QASV and implement RFC2232 encoding for
all three view types, we can just use the QString version, after
toString().

This not only has the advantage of less code and not storing duplicate
data, but we now also encode u8"ä.txt" the same as "ä.txt"_L1 and
u"ä.txt", ie. using latin1, as required by Postel's Law, and not as
UTF-8, as the old code did.

Change-Id: If82a33a1cd09b859b3a4450a60083b1d3aedf7bc
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2024-05-30 20:52:42 +02:00
Mate Barany 32610561e3 Add convenience classes to generate QHttpMultipart messages
Constructing and composing a QHttpMultipart contains some aspects that
are possible candidates for automating, such as setting the headers
manually for each included part. As a reference, when issuing a default
multipart with CURL, one does not need to manually set the headers.

Add the class QFormDataPartBuilder to simplify the construction of
QHttpPart objects.

Add the class QFormDataBuilder to simplify the construction of
QHttpMultiPart objects.

[ChangeLog][QtNetwork][QFormDataBuilder] New class to help constructing
multipart/form-data QHttpMultiParts.

Fixes: QTBUG-114647
Change-Id: Ie035dabc01a9818d65a67c239807b50001fd984a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2024-05-30 18:52:42 +00:00
Mårten Nordheim 48aad482a8 Http: Add support for full localsocket paths
[ChangeLog][QtNetwork][QNetworkAccessManager] QNetworkAccessManager now
supports using full local server name, as in, named pipes on Windows or path to
socket objects on Unix.

Task-number: QTBUG-102855
Change-Id: Ifc743f5025b3d8d0b558ecffff437881897915d9
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2024-05-24 22:36:59 +02:00
Assam Boudjelthia f1c6c66985 Android: prefer wlan IPv6 connection over other interfaces
Android doesn't allow connection from interfaces like (radio0, eth0,
etc.) when wlan0 is already connected, so prefer testing that.

Task-number: QTBUG-125023
Change-Id: Id48a6717755edc22909a4a0d58631d8132a42b1a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-05-23 10:26:20 +03:00
Marc Mutz 658939dae2 tst_http2: fix -Wunused-parameter warning
Amends 4f9387f2ae.

Pick-to: 6.7 6.5
Change-Id: I3e58967e05afad9f1a0dd581c3795e4f4c8c8de5
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2024-05-22 15:47:50 +02:00
Mårten Nordheim 68ceb847d6 QNetworkReply: Add a separate test for self-contained tests
Nothing there should rely on the network testing server.
Part of this will also be testing the local/unix domain socket support.

Task-number: QTBUG-102855
Change-Id: Icf3b0bd9370ec62e003862caf4cd3ed38d875bac
Reviewed-by: Mate Barany <mate.barany@qt.io>
2024-05-16 19:40:03 +02:00
Jari Helaakoski 0ae44ccc6f Improve test compilation setup with QtLite configuration
Functional fix will come later via separate tasks.

Task-number: QTBUG-122999
Change-Id: Ib805740c87ff21cea5a186add71cc594ab4d4df1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-05-10 09:04:44 +00:00