Skip to content

Commit 18a92c2

Browse files
authored
Merge pull request #655 from nextcloud/add-quotaplugin-v2-stable9
[stable9] Adding quota plugin to new dav endpoint
2 parents b4bd126 + 971f22e commit 18a92c2

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

apps/dav/lib/server.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ public function __construct(IRequest $request, $baseUri) {
141141
)
142142
)
143143
);
144+
145+
$this->server->addPlugin(
146+
new \OCA\DAV\Connector\Sabre\QuotaPlugin($view)
147+
);
144148
}
145149
});
146150
}

build/integration/features/bootstrap/WebDav.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,19 @@ public function usingDavPath($davPath) {
4747
$this->davPath = $davPath;
4848
}
4949

50+
51+
/**
52+
* @return string
53+
*/
54+
public function getFilesPath() {
55+
if ($this->davPath === 'remote.php/dav') {
56+
$basePath = '/files/' . $this->currentUser . '/';
57+
} else {
58+
$basePath = '/';
59+
}
60+
return $basePath;
61+
}
62+
5063
public function makeDavRequest($user, $method, $path, $headers, $body = null){
5164
$fullUrl = substr($this->baseUrl, 0, -4) . $this->davPath . "$path";
5265
$client = new GClient();
@@ -347,7 +360,7 @@ public function userDeletesFile($user, $file) {
347360
*/
348361
public function userCreatedAFolder($user, $destination){
349362
try {
350-
$this->response = $this->makeDavRequest($user, "MKCOL", $destination, []);
363+
$this->response = $this->makeDavRequest($user, "MKCOL", $this->getFilesPath() . ltrim($destination, $this->getFilesPath()), []);
351364
} catch (\GuzzleHttp\Exception\ServerException $e) {
352365
// 4xx and 5xx responses cause an exception
353366
$this->response = $e->getResponse();

build/integration/features/webdav-related.feature

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,3 +273,29 @@ Feature: webdav-related
273273
And User "user0" uploads file with content "copytest" to "/copytest.txt"
274274
When User "user0" copies file "/copytest.txt" to "/testcopypermissionsNotAllowed/copytest.txt"
275275
Then the HTTP status code should be "403"
276+
277+
Scenario: Uploading a file having 0B as quota
278+
Given using dav path "remote.php/dav"
279+
And As an "admin"
280+
And user "user0" exists
281+
And user "user0" has a quota of "0 B"
282+
And As an "user0"
283+
When User "user0" uploads file "data/textfile.txt" to "/files/user0/asdf.txt"
284+
Then the HTTP status code should be "507"
285+
Scenario: Uploading a file as recipient using webdav new endpoint having quota
286+
Given using dav path "remote.php/dav"
287+
And As an "admin"
288+
And user "user0" exists
289+
And user "user1" exists
290+
And user "user0" has a quota of "10 MB"
291+
And user "user1" has a quota of "10 MB"
292+
And As an "user1"
293+
And user "user1" created a folder "/testquota"
294+
And as "user1" creating a share with
295+
| path | testquota |
296+
| shareType | 0 |
297+
| permissions | 31 |
298+
| shareWith | user0 |
299+
And As an "user0"
300+
When User "user0" uploads file "data/textfile.txt" to "/files/user0/testquota/asdf.txt"
301+
Then the HTTP status code should be "201"

0 commit comments

Comments
 (0)