[frameworks/kdav] autotests: Adapt tests

Kevin Ottens <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 73f3a1dc7f0890475be5a6bccfa4fdf2f07add1f by Kevin Ottens, on behalf of Carl Schwan.
Committed on 28/07/2026 at 19:47.
Pushed by ervin into branch 'master'.

Adapt tests

- Remove some KIO leftovers
- Return Http 1.0 response as fakeserver is not 100% compliant with the
  http 1.1 spec in regard to disconnection

M  +3    -3    autotests/davcollectioncreatejobtest.cpp
M  +5    -1    autotests/fakeserver.cpp

https://invent.kde.org/frameworks/kdav/-/commit/73f3a1dc7f0890475be5a6bccfa4fdf2f07add1f

diff --git a/autotests/davcollectioncreatejobtest.cpp b/autotests/davcollectioncreatejobtest.cpp
index cc0429d..180449c 100644
--- a/autotests/davcollectioncreatejobtest.cpp
+++ b/autotests/davcollectioncreatejobtest.cpp
@@ -52,7 +52,7 @@ void DavCollectionCreateJobTest::createCalDavCollection()
 
     fakeServer.addScenario({
         "C: MKCOL /caldav/new-calendar/ HTTP/1.1",
-        "B: <?xml version=\"1.0\"?>",
+        "B: <?xml version=\"1.0\" encoding=\"utf-8\"?>",
         "B: <D:mkcol xmlns:D=\"DAV:\" xmlns:I=\"http://apple.com/ns/ical/\" xmlns:C=\"urn:ietf:params:xml:ns:caldav\">",
         "B:     <D:set>",
         "B:         <D:prop>",
@@ -117,7 +117,7 @@ void DavCollectionCreateJobTest::createCardDavCollection()
 
     fakeServer.addScenario({
         "C: MKCOL /carddav/new-addressbook/ HTTP/1.1",
-        "B: <?xml version=\"1.0\"?>",
+        "B: <?xml version=\"1.0\" encoding=\"utf-8\"?>",
         "B: <D:mkcol xmlns:D=\"DAV:\" xmlns:C=\"urn:ietf:params:xml:ns:carddav\">",
         "B:     <D:set>",
         "B:         <D:prop>",
@@ -155,7 +155,7 @@ void DavCollectionCreateJobTest::createCollectionError()
 
     fakeServer.addScenario({
         "C: MKCOL /caldav/new-calendar/ HTTP/1.1",
-        "B: <?xml version=\"1.0\"?>",
+        "B: <?xml version=\"1.0\" encoding=\"utf-8\"?>",
         "B: <D:mkcol xmlns:D=\"DAV:\" xmlns:I=\"http://apple.com/ns/ical/\" xmlns:C=\"urn:ietf:params:xml:ns:caldav\">",
         "B:     <D:set>",
         "B:         <D:prop>",
diff --git a/autotests/fakeserver.cpp b/autotests/fakeserver.cpp
index 2b2bde6..d622275 100644
--- a/autotests/fakeserver.cpp
+++ b/autotests/fakeserver.cpp
@@ -148,7 +148,8 @@ void FakeServer::writeServerPart(QTcpSocket *clientSocket, int scenarioNumber)
 
     if (!scenario.isEmpty() && scenario.first().startsWith("X")) {
         scenario.takeFirst();
-        clientSocket->close();
+        clientSocket->flush();
+        clientSocket->disconnectFromHost();
     }
 
     if (!scenario.isEmpty()) {
@@ -209,6 +210,9 @@ void FakeServer::readClientPart(QTcpSocket *socket, int *scenarioNumber)
         line = socket->readLine();
     }
 
+    // read content
+    socket->readAll();
+
     while (!scenario.isEmpty() && scenario.first().startsWith("C: ")) {
         QByteArray expected = scenario.takeFirst().mid(3) + "\r\n";
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.