Skip to content

Commit

Permalink
Added step to check mtime for author
Browse files Browse the repository at this point in the history
  • Loading branch information
Talank committed Jul 1, 2020
1 parent e394902 commit 21e4638
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 11 deletions.
26 changes: 25 additions & 1 deletion tests/TestHelpers/WebDavHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ public static function isValidDavChunkingCombination(
* @return string
* @throws Exception
*/
public function getMtimeOfFileinPublicLinkShare(
public static function getMtimeOfFileinPublicLinkShare(
$baseUrl,
$fileName,
$token,
Expand All @@ -526,4 +526,28 @@ public function getMtimeOfFileinPublicLinkShare(

return $xmlPart[0]->__toString();
}

/**
* get Mtime of a resource
*
* @param string $user
* @param string $password
* @param string $baseUrl
* @param string $resource
*
* @return string
* @throws Exception
*/
public static function getMtimeOfResource($user,
$password,
$baseUrl,
$resource
) {
$response = self::propfind(
$baseUrl, $user, $password, $resource, ["getlastmodified"]
);
$responseXmlObject = HttpRequestHelper::getResponseXml($response);
$xmlpart = $responseXmlObject->xpath("//d:getlastmodified");
return $xmlpart[0]->__toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -771,13 +771,15 @@ Feature: create a public link share
| new |

@issue-ocis-reva-49 @issue-37605
Scenario: Get the mtime of a file inside a folder shared by public link using new dav version
Scenario: Get the mtime of a file inside a folder shared by public link using new webDAV version
Given user "Alice" has created folder "testFolder"
And user "Alice" has created a public link share with settings
| path | /testFolder |
| permissions | read,update,create,delete |
When the public uploads file "file.txt" to the last shared folder with mtime "Thu, 08 Aug 2019 04:18:13 GMT" using the new public WebDAV API
Then as "Alice" file "testFolder/file.txt" should exist
And as "Alice" the mtime of the file "testFolder/file.txt" should not be "Thu, 08 Aug 2019 04:18:13 GMT"
# And as "Alice" the mtime of the file "testFolder/file.txt" should be "Thu, 08 Aug 2019 04:18:13 GMT"
And the mtime of file "file.txt" in the last shared public link using the WebDAV API should not be "Thu, 08 Aug 2019 04:18:13 GMT"
# And the mtime of file "file.txt" in the the last shared public link using the WebDAV API should be "Thu, 08 Aug 2019 04:18:13 GMT"

Expand All @@ -791,5 +793,7 @@ Feature: create a public link share
And the public uploads file "file.txt" to the last shared folder with mtime "Thu, 08 Aug 2019 04:18:13 GMT" using the new public WebDAV API
Then the HTTP status code should be "204"
Then as "Alice" file "/testFolder/file.txt" should exist
And as "Alice" the mtime of the file "testFolder/file.txt" should not be "Thu, 08 Aug 2019 04:18:13 GMT"
# And as "Alice" the mtime of the file "testFolder/file.txt" should be "Thu, 08 Aug 2019 04:18:13 GMT"
And the mtime of file "file.txt" in the last shared public link using the WebDAV API should not be "Thu, 08 Aug 2019 04:18:13 GMT"
# And the mtime of file "file.txt" in the last shared public link using the WebDAV API should be "Thu, 08 Aug 2019 04:18:13 GMT"
6 changes: 3 additions & 3 deletions tests/acceptance/features/bootstrap/PublicWebDavContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -929,12 +929,12 @@ public function theMtimeOfFileInTheLastSharedPublicLinkUsingTheWebdavApiShouldBe
$mtime = \implode(" ", $mtime);
Assert::assertContains(
$mtime,
(new TestHelpers\WebDavHelper)->getMtimeOfFileinPublicLinkShare($baseUrl, $fileName, $token)
\TestHelpers\WebDavHelper::getMtimeOfFileinPublicLinkShare($baseUrl, $fileName, $token)
);
} else {
Assert::assertEquals(
$mtime,
(new TestHelpers\WebDavHelper)->getMtimeOfFileinPublicLinkShare($baseUrl, $fileName, $token)
\TestHelpers\WebDavHelper::getMtimeOfFileinPublicLinkShare($baseUrl, $fileName, $token)
);
}
}
Expand All @@ -957,7 +957,7 @@ public function theMtimeOfFileInTheLastSharedPublicLinkUsingTheWebdavApiShouldNo
$baseUrl = $this->featureContext->getBaseUrl();
Assert::assertNotEquals(
$mtime,
(new TestHelpers\WebDavHelper)->getMtimeOfFileinPublicLinkShare($baseUrl, $fileName, $token)
\TestHelpers\WebDavHelper::getMtimeOfFileinPublicLinkShare($baseUrl, $fileName, $token)
);
}

Expand Down
30 changes: 24 additions & 6 deletions tests/acceptance/features/bootstrap/WebDav.php
Original file line number Diff line number Diff line change
Expand Up @@ -2107,13 +2107,31 @@ public function theMtimeOfTheFileShouldBe(
) {
$user = $this->getActualUsername($user);
$password = $this->getPasswordForUser($user);
$this->response = WebDavHelper::propfind(
$this->getBaseUrl(), $user, $password, $resource, ["getlastmodified"]
);
$responseXmlObject = HttpRequestHelper::getResponseXml($this->response);
$xmlpart = $responseXmlObject->xpath("//d:getlastmodified");
$baseUrl = $this->getBaseUrl();
Assert::assertEquals(
$mtime, $xmlpart[0]->__toString()
$mtime,
\TestHelpers\WebDavHelper::getMtimeOfResource($user, $password, $baseUrl, $resource)
);
}

/**
* @Then as :user the mtime of the file :resource should not be :mtime
*
* @param string $user
* @param string $resource
* @param string $mtime
*
* @return void
*/
public function theMtimeOfTheFileShouldNotBe(
$user, $resource, $mtime
) {
$user = $this->getActualUsername($user);
$password = $this->getPasswordForUser($user);
$baseUrl = $this->getBaseUrl();
Assert::assertNotEquals(
$mtime,
\TestHelpers\WebDavHelper::getMtimeOfResource($user, $password, $baseUrl, $resource)
);
}

Expand Down

0 comments on commit 21e4638

Please sign in to comment.