From c3a7892889d24230f5d6f0853d220532efee612b Mon Sep 17 00:00:00 2001 From: Saw-jan Date: Mon, 8 Dec 2025 16:04:12 +0545 Subject: [PATCH] test: proper resource existence check Signed-off-by: Saw-jan --- tests/acceptance/bootstrap/WebDav.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/tests/acceptance/bootstrap/WebDav.php b/tests/acceptance/bootstrap/WebDav.php index e75210179c..e05aa733d3 100644 --- a/tests/acceptance/bootstrap/WebDav.php +++ b/tests/acceptance/bootstrap/WebDav.php @@ -1264,20 +1264,18 @@ trait WebDav { $type ); $statusCode = $response->getStatusCode(); - if ($statusCode < 400 || $statusCode > 499) { - try { - $responseXmlObject = HttpRequestHelper::getResponseXml( - $response, - __METHOD__ - ); - } catch (Exception $e) { - Assert::fail( - "$entry '$path' should not exist. But API returned $statusCode without XML in the body" - ); - } + // when checking path with '..' it may return 405 Method Not Allowed + if ($statusCode === 404 || $statusCode === 405) { + return; + } + if ($statusCode === 207) { + $responseXmlObject = HttpRequestHelper::getResponseXml( + $response, + __METHOD__ + ); Assert::assertTrue( $this->isEtagValid($this->getEtagFromResponseXmlObject($responseXmlObject)), - "$entry '$path' should not exist. But API returned $statusCode without an etag in the body" + "$entry '$path' should not exist but found with invalid etag." ); $isCollection = $responseXmlObject->xpath("//d:prop/d:resourcetype/d:collection"); if (\count($isCollection) === 0) { @@ -1291,7 +1289,11 @@ trait WebDav { "$entry '$path' should not exist. But it does." ); } + return; } + Assert::fail( + "$entry '$path' should not exist. But API returned $statusCode without XML in the body" + ); } /**