Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions apps/dav/lib/Connector/Sabre/FilesPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class FilesPlugin extends ServerPlugin {
const OWNER_DISPLAY_NAME_PROPERTYNAME = '{http://owncloud.org/ns}owner-display-name';
const CHECKSUMS_PROPERTYNAME = '{http://owncloud.org/ns}checksums';
const DATA_FINGERPRINT_PROPERTYNAME = '{http://owncloud.org/ns}data-fingerprint';
const PRIVATE_LINK_PROPERTYNAME = '{http://owncloud.org/ns}privatelink';

/**
* Reference to main server object
Expand Down Expand Up @@ -140,6 +141,7 @@ public function initialize(\Sabre\DAV\Server $server) {
$server->protectedProperties[] = self::OWNER_DISPLAY_NAME_PROPERTYNAME;
$server->protectedProperties[] = self::CHECKSUMS_PROPERTYNAME;
$server->protectedProperties[] = self::DATA_FINGERPRINT_PROPERTYNAME;
$server->protectedProperties[] = self::PRIVATE_LINK_PROPERTYNAME;

// normally these cannot be changed (RFC4918), but we want them modifiable through PROPPATCH
$allowedProperties = ['{DAV:}getetag'];
Expand Down Expand Up @@ -308,6 +310,11 @@ public function handleGetProperties(PropFind $propFind, \Sabre\DAV\INode $node)
$propFind->handle(self::SIZE_PROPERTYNAME, function() use ($node) {
return $node->getSize();
});

$propFind->handle(self::PRIVATE_LINK_PROPERTYNAME, function() use ($node) {
return \OC::$server->getURLGenerator()
->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileId' => $node->getInternalFileId()]);
});
}

if ($node instanceof \OCA\DAV\Connector\Sabre\Node) {
Expand Down
1 change: 1 addition & 0 deletions apps/files/lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public function getCapabilities() {
'preferredUploadType' => 'SHA1'
],
'files' => [
'privateLinks' => true,
'bigfilechunking' => true,
'blacklisted_files' => $this->config->getSystemValue('blacklisted_files', ['.htaccess']),
],
Expand Down
30 changes: 30 additions & 0 deletions tests/integration/features/bootstrap/WebDav.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,36 @@ public function theSingleResponseShouldContainAPropertyWithValue($key, $expected
}
}

/**
* @Then the single response should contain a property :key with value like :regex
* @param string $key
* @param string $regex
* @throws \Exception
*/
public function theSingleResponseShouldContainAPropertyWithValueLike($key, $regex) {
$keys = $this->response;
if (!array_key_exists($key, $keys)) {
throw new \Exception("Cannot find property \"$key\" with \"$regex\"");
}

$value = $keys[$key];
if ($value instanceof ResourceType) {
$value = $value->getValue();
if (empty($value)) {
$value = '';
} else {
$value = $value[0];
}
}

if (preg_match($regex, $value)) {
return 0;
} else {
throw new \Exception("Property \"$key\" found with value \"$value\", expected \"$regex\"");
}
}


/**
* @Then the response should contain a share-types property with
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,3 +593,12 @@ Feature: webdav-related-new-endpoint
And user "user0" uploads new chunk file "3" with "CCCCC" to id "chunking-42"
When user "user0" moves new chunk file with id "chunking-42" to "/myChunkedFile.txt" with size 15
Then the HTTP status code should be "201"

Scenario: Retrieving private link
Given using new dav path
And user "user0" exists
And as an "user0"
And user "user0" uploads file "data/textfile.txt" to "/somefile.txt"
Then as "user0" gets properties of file "/somefile.txt" with
|{http://owncloud.org/ns}privatelink|
And the single response should contain a property "{http://owncloud.org/ns}privatelink" with value like "/(\/index.php\/f\/[0-9]*)/"
11 changes: 11 additions & 0 deletions tests/integration/features/webdav-related-old-endpoint.feature
Original file line number Diff line number Diff line change
Expand Up @@ -507,3 +507,14 @@ Feature: webdav-related-old-endpoint
And as "user1" the folder "/folderB/ONE" exists
And as "user1" the folder "/folderB/ONE/TWO" exists
And user "user1" checks id of file "/folderB/ONE"


Scenario: Retrieving private link
Given using old dav path
And user "user0" exists
And as an "user0"
And user "user0" uploads file "data/textfile.txt" to "/somefile.txt"
Then as "user0" gets properties of file "/somefile.txt" with
|{http://owncloud.org/ns}privatelink|
And the single response should contain a property "{http://owncloud.org/ns}privatelink" with value like "/(\/index.php\/f\/[0-9]*)/"