X Tutup
Skip to content

Commit a20834d

Browse files
jasson99phil-davis
authored andcommitted
Add acceptance test to get the size of the file
1 parent 371fce6 commit a20834d

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

tests/acceptance/features/apiSharePublicLink1/createPublicLinkShare.feature

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,3 +505,13 @@ Feature: create a public link share
505505
When the public downloads file "parent.txt" from inside the last public shared folder using the old public WebDAV API
506506
Then the value of the item "//s:message" in the response should be ""
507507
And the HTTP status code should be "404"
508+
509+
Scenario: Get the size of a file shared by public link
510+
Given the administrator has enabled DAV tech_preview
511+
And user "user0" has uploaded file with content "This is a test file" to "test-file.txt"
512+
And user "user0" has created a public link share with settings
513+
| path | test-file.txt |
514+
| permissions | read |
515+
When the public gets the size of the last shared public link using the WebDAV API
516+
Then the HTTP status code should be "207"
517+
And the size of the file should be "19"

tests/acceptance/features/apiWebdavOperations/downloadFile.feature

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,9 @@ Feature: download file
8080
| dav_version |
8181
| old |
8282
| new |
83+
84+
Scenario: Get the size of a file
85+
Given user "user0" has uploaded file with content "This is a test file" to "test-file.txt"
86+
When user "user0" gets the size of file "test-file.txt" using the WebDAV API
87+
Then the HTTP status code should be "207"
88+
And the size of the file should be "19"

tests/acceptance/features/bootstrap/WebDav.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,53 @@ public function downloadFileAsUserUsingPassword(
10881088
);
10891089
}
10901090

1091+
/**
1092+
* @When the public gets the size of the last shared public link using the WebDAV API
1093+
*
1094+
* @return void
1095+
* @throws Exception
1096+
*/
1097+
public function publicGetsSizeOfLastSharedPublicLinkUsingTheWebdavApi() {
1098+
$tokenArray = $this->getLastShareData()->data->token;
1099+
$token = (string)$tokenArray[0];
1100+
$url = $this->getBaseUrl() . "/remote.php/dav/public-files/{$token}";
1101+
$this->response = HttpRequestHelper::sendRequest(
1102+
$url, "PROPFIND", null, null, null
1103+
);
1104+
}
1105+
1106+
/**
1107+
* @When user :user gets the size of file :resource using the WebDAV API
1108+
*
1109+
* @param $user
1110+
* @param $resource
1111+
*
1112+
* @return void
1113+
* @throws Exception
1114+
*/
1115+
public function userGetsSizeOfFileUsingTheWebdavApi($user, $resource) {
1116+
$headers = $this->guzzleClientHeaders;
1117+
$password = $this->getPasswordForUser($user);
1118+
$url = $this->getBaseUrl() . "/remote.php/dav/files/{$user}/{$resource}";
1119+
$this->response = HttpRequestHelper::sendRequest(
1120+
$url, "PROPFIND", $user, $password, $headers, null, null, null
1121+
);
1122+
}
1123+
1124+
/**
1125+
* @Then the size of the file should be :size
1126+
*
1127+
* @param $size
1128+
*
1129+
* @return void
1130+
*/
1131+
public function theSizeOfTheFileShouldBe($size) {
1132+
$responseXml = HttpRequestHelper::getResponseXml($this->response);
1133+
$responseXml->registerXPathNamespace('d', 'DAV:');
1134+
$xmlPart = $responseXml->xpath("//d:prop/d:getcontentlength");
1135+
Assert::assertEquals($size, (string) $xmlPart[0]);
1136+
}
1137+
10911138
/**
10921139
* @Then the following headers should be set
10931140
*

0 commit comments

Comments
 (0)
X Tutup