From d17a4f531c4227e90d202cb570bda23cc0795d57 Mon Sep 17 00:00:00 2001 From: Swikriti Tripathi Date: Tue, 23 Feb 2021 16:29:56 +0545 Subject: [PATCH] add tests for counting number of etag element in response of versioned file --- .../features/apiVersions/fileVersions.feature | 10 ++++++++ .../acceptance/features/bootstrap/WebDav.php | 25 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/tests/acceptance/features/apiVersions/fileVersions.feature b/tests/acceptance/features/apiVersions/fileVersions.feature index 4c3e1cc7ee67..7f763cda29fc 100644 --- a/tests/acceptance/features/apiVersions/fileVersions.feature +++ b/tests/acceptance/features/apiVersions/fileVersions.feature @@ -420,3 +420,13 @@ Feature: dav-versions Given user "Alice" has uploaded file with content "uploaded content" to "textfile0.txt" When user "Alice" gets the number of versions of file "textfile0.txt" Then the number of versions should be "0" + + @issue-ocis-1234 + Scenario: the number of etag and last modified element in response changes according to version of the file + Given user "Alice" has uploaded file with content "uploaded content" to "textfile0.txt" + And user "Alice" has uploaded file with content "version 1" to "textfile0.txt" + And user "Alice" has uploaded file with content "version 2" to "textfile0.txt" + When user "Alice" gets the number of versions of file "textfile0.txt" + Then the HTTP status code should be "207" + And the number of etag element in the response should be "2" + And the number of versions should be "2" \ No newline at end of file diff --git a/tests/acceptance/features/bootstrap/WebDav.php b/tests/acceptance/features/bootstrap/WebDav.php index d11654df646e..fad382d66d94 100644 --- a/tests/acceptance/features/bootstrap/WebDav.php +++ b/tests/acceptance/features/bootstrap/WebDav.php @@ -448,6 +448,31 @@ public function theNumberOfVersionsShouldBe($number) { ); } + /** + * @Then the number of etag element in the response should be :arg1 + * + * @param int $number + * + * @return void + * @throws Exception + */ + public function theNumberOfEtagElementInTheResponseShouldBe($number) { + $resXml = $this->getResponseXmlObject(); + if ($resXml === null) { + $resXml = HttpRequestHelper::getResponseXml( + $this->getResponse(), + __METHOD__ + ); + } + $xmlPart = $resXml->xpath("//d:getetag"); + $actualNumber = \count($xmlPart); + Assert::assertEquals( + $number, + $actualNumber, + "Expected number of etag element was '$number', but got '$actualNumber'" + ); + } + /** * @Given /^the administrator has (enabled|disabled) async operations$/ *