Merge pull request #654 from nextcloud/add-quotaplugin-v2-stable10

[stable10] Add quotaplugin v2 stable10
This commit is contained in:
Morris Jobke 2016-07-29 14:10:57 +02:00 committed by GitHub
commit 558a8a62a4
3 changed files with 44 additions and 2 deletions

View File

@ -173,6 +173,9 @@ class Server {
) )
) )
); );
$this->server->addPlugin(
new \OCA\DAV\Connector\Sabre\QuotaPlugin($view));
} }
}); });
} }

View File

@ -50,6 +50,18 @@ trait WebDav {
$this->davPath = $davPath; $this->davPath = $davPath;
} }
/**
* @return string
*/
public function getFilesPath() {
if ($this->davPath === 'remote.php/dav') {
$basePath = '/files/' . $this->currentUser . '/';
} else {
$basePath = '/';
}
return $basePath;
}
public function makeDavRequest($user, $method, $path, $headers, $body = null){ public function makeDavRequest($user, $method, $path, $headers, $body = null){
$fullUrl = substr($this->baseUrl, 0, -4) . $this->davPath . "$path"; $fullUrl = substr($this->baseUrl, 0, -4) . $this->davPath . "$path";
$client = new GClient(); $client = new GClient();
@ -413,9 +425,9 @@ trait WebDav {
* @param string $user * @param string $user
* @param string $destination * @param string $destination
*/ */
public function userCreatedAFolder($user, $destination){ public function userCreatedAFolder($user, $destination) {
try { try {
$this->response = $this->makeDavRequest($user, "MKCOL", $destination, []); $this->response = $this->makeDavRequest($user, "MKCOL", $this->getFilesPath() . ltrim($destination, $this->getFilesPath()), []);
} catch (\GuzzleHttp\Exception\ServerException $e) { } catch (\GuzzleHttp\Exception\ServerException $e) {
// 4xx and 5xx responses cause an exception // 4xx and 5xx responses cause an exception
$this->response = $e->getResponse(); $this->response = $e->getResponse();

View File

@ -53,3 +53,30 @@ Feature: dav-v2
Given Logging in using web as "admin" Given Logging in using web as "admin"
When Sending a "PROPFIND" to "/remote.php/dav/files/admin/welcome.txt" with requesttoken When Sending a "PROPFIND" to "/remote.php/dav/files/admin/welcome.txt" with requesttoken
Then the HTTP status code should be "207" Then the HTTP status code should be "207"
Scenario: Uploading a file having 0B as quota
Given using dav path "remote.php/dav"
And As an "admin"
And user "user0" exists
And user "user0" has a quota of "0 B"
And As an "user0"
When User "user0" uploads file "data/textfile.txt" to "/files/user0/asdf.txt"
Then the HTTP status code should be "507"
Scenario: Uploading a file as recipient using webdav new endpoint having quota
Given using dav path "remote.php/dav"
And As an "admin"
And user "user0" exists
And user "user1" exists
And user "user0" has a quota of "10 MB"
And user "user1" has a quota of "10 MB"
And As an "user1"
And user "user1" created a folder "/testquota"
And as "user1" creating a share with
| path | testquota |
| shareType | 0 |
| permissions | 31 |
| shareWith | user0 |
And As an "user0"
When User "user0" uploads file "data/textfile.txt" to "/files/user0/testquota/asdf.txt"
Then the HTTP status code should be "201"