Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests-only][full-ci]Spaces implementation in checksums api features (apiMain) #39678

Closed
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
40 changes: 39 additions & 1 deletion CHANGELOG.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<h2 id="unreleased" class="version"> Changelog for ownCloud Core [unreleased] (UNRELEASED)</h2>
<p>The following sections list the changes in ownCloud core unreleased relevant to ownCloud admins and users.</p>
<p>
<a href="https://github.com/owncloud/core/compare/v10.9.0...master">Full list of changes in unreleased </a>
<a href="https://github.com/owncloud/core/compare/v10.9.1...master">Full list of changes in unreleased </a>
</p>
<h3 id="unreleased-summary">Summary</h3>
<ul class="summary">
Expand All @@ -11,6 +11,7 @@ <h3 id="unreleased-summary">Summary</h3>
<li class="type-bugfix changelog-item">Bugfix - Set page title for the tags file list: <a href="https://github.com/owncloud/core/issues/39556">#39556</a></li>
<li class="type-bugfix changelog-item">Bugfix - Don't resend invitation mail if a user is guest: <a href="https://github.com/owncloud/core/pull/39602">#39602</a></li>
<li class="type-bugfix changelog-item">Bugfix - Prevent encrypted files from being corrupted when overwriting them: <a href="https://github.com/owncloud/core/pull/39623">#39623</a></li>
<li class="type-bugfix changelog-item">Bugfix - Fix files:checksums:verify for a single file: <a href="https://github.com/owncloud/core/pull/39683">#39683</a></li>
<li class="type-change changelog-item">Change - Update PHP dependencies: <a href="https://github.com/owncloud/core/pull/39526">#39526</a></li>
<li class="type-change changelog-item">Change - Update Symfony components: <a href="https://github.com/owncloud/core/pull/39526">#39526</a></li>
<li class="type-enhancement changelog-item">Enhancement - Allow OPTIONS request handling in framework controllers: <a href="https://github.com/owncloud/core/pull/38758">#38758</a></li>
Expand Down Expand Up @@ -49,6 +50,12 @@ <h3 id="unreleased-details">Details</h3>
</p>
<p>https://github.com/owncloud/core/pull/39623<br></p>
</li>
<li class="type-bugfix changelog-item">
<p>Bugfix - Fix files:checksums:verify for a single file: <a href="https://github.com/owncloud/core/pull/39683">#39683</a></p>
<p>Fixed an issue where running files:checksums:verify for a single file would fail.
</p>
<p>https://github.com/owncloud/core/pull/39683<br></p>
</li>
<li class="type-change changelog-item">
<p>Change - Update PHP dependencies: <a href="https://github.com/owncloud/core/pull/39526">#39526</a></p>
<p>The following have been updated: - christophwurst/id3parser (v0.1.3 to v0.1.4) -
Expand Down Expand Up @@ -78,6 +85,37 @@ <h3 id="unreleased-details">Details</h3>
<p>https://github.com/owncloud/core/pull/38758<br></p>
</li>
</ul>
<h2 id="10.9.1" class="version"> Changelog for ownCloud Core [10.9.1] (2021-12-28)</h2>
<p>The following sections list the changes in ownCloud core 10.9.1 relevant to ownCloud admins and users.</p>
<p>
<a href="https://github.com/owncloud/core/compare/v10.9.0...v10.9.1">Full list of changes in 10.9.1</a>
</p>
<h3 id="10.9.1-summary">Summary</h3>
<ul class="summary">
<li class="type-bugfix changelog-item">Bugfix - Getting the file owner for share recipients: <a href="https://github.com/owncloud/core/pull/39670">#39670</a></li>
<li class="type-bugfix changelog-item">Bugfix - Prevent version author from being overwritten with wrong uid: <a href="https://github.com/owncloud/core/pull/39673">#39673</a></li>
</ul>
<h3 id="10.9.1-details">Details</h3>
<ul class="details">
<li class="type-bugfix changelog-item">
<p>Bugfix - Getting the file owner for share recipients: <a href="https://github.com/owncloud/core/pull/39670">#39670</a></p>
<p>Fixed a bug where a wrong file owner was retrieved when saving version authors. This scenario
happened for share recipients if they had a file with the same name as the shared file.
</p>
<p>https://github.com/owncloud/core/issues/39662<br>
</p>
<p>https://github.com/owncloud/core/pull/39670<br></p>
</li>
<li class="type-bugfix changelog-item">
<p>Bugfix - Prevent version author from being overwritten with wrong uid: <a href="https://github.com/owncloud/core/pull/39673">#39673</a></p>
<p>Fixed an issue where restoring a previous version could lead to a wrong version author being
saved, basically overwriting the correct author.
</p>
<p>https://github.com/owncloud/core/issues/39672<br>
</p>
<p>https://github.com/owncloud/core/pull/39673<br></p>
</li>
</ul>
<h2 id="10.9.0" class="version"> Changelog for ownCloud Core [10.9.0] (2021-12-20)</h2>
<p>The following sections list the changes in ownCloud core 10.9.0 relevant to ownCloud admins and users.</p>
<p>
Expand Down
41 changes: 40 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Changelog for ownCloud Core [unreleased] (UNRELEASED)
The following sections list the changes in ownCloud core unreleased relevant to
ownCloud admins and users.

[unreleased]: https://github.com/owncloud/core/compare/v10.9.0...master
[unreleased]: https://github.com/owncloud/core/compare/v10.9.1...master

Summary
-------
Expand All @@ -13,6 +13,7 @@ Summary
* Bugfix - Set page title for the tags file list: [#39556](https://github.com/owncloud/core/issues/39556)
* Bugfix - Don't resend invitation mail if a user is guest: [#39602](https://github.com/owncloud/core/pull/39602)
* Bugfix - Prevent encrypted files from being corrupted when overwriting them: [#39623](https://github.com/owncloud/core/pull/39623)
* Bugfix - Fix files:checksums:verify for a single file: [#39683](https://github.com/owncloud/core/pull/39683)
* Change - Update PHP dependencies: [#39526](https://github.com/owncloud/core/pull/39526)
* Change - Update Symfony components: [#39526](https://github.com/owncloud/core/pull/39526)
* Enhancement - Allow OPTIONS request handling in framework controllers: [#38758](https://github.com/owncloud/core/pull/38758)
Expand Down Expand Up @@ -49,6 +50,12 @@ Details
https://github.com/owncloud/encryption/issues/315
https://github.com/owncloud/core/pull/39623

* Bugfix - Fix files:checksums:verify for a single file: [#39683](https://github.com/owncloud/core/pull/39683)

Fixed an issue where running files:checksums:verify for a single file would fail.

https://github.com/owncloud/core/pull/39683

* Change - Update PHP dependencies: [#39526](https://github.com/owncloud/core/pull/39526)

The following have been updated: - christophwurst/id3parser (v0.1.3 to v0.1.4) -
Expand Down Expand Up @@ -84,6 +91,38 @@ Details

https://github.com/owncloud/core/pull/38758

Changelog for ownCloud Core [10.9.1] (2021-12-28)
=======================================
The following sections list the changes in ownCloud core 10.9.1 relevant to
ownCloud admins and users.

[10.9.1]: https://github.com/owncloud/core/compare/v10.9.0...v10.9.1

Summary
-------

* Bugfix - Getting the file owner for share recipients: [#39670](https://github.com/owncloud/core/pull/39670)
* Bugfix - Prevent version author from being overwritten with wrong uid: [#39673](https://github.com/owncloud/core/pull/39673)

Details
-------

* Bugfix - Getting the file owner for share recipients: [#39670](https://github.com/owncloud/core/pull/39670)

Fixed a bug where a wrong file owner was retrieved when saving version authors. This scenario
happened for share recipients if they had a file with the same name as the shared file.

https://github.com/owncloud/core/issues/39662
https://github.com/owncloud/core/pull/39670

* Bugfix - Prevent version author from being overwritten with wrong uid: [#39673](https://github.com/owncloud/core/pull/39673)

Fixed an issue where restoring a previous version could lead to a wrong version author being
saved, basically overwriting the correct author.

https://github.com/owncloud/core/issues/39672
https://github.com/owncloud/core/pull/39673

Changelog for ownCloud Core [10.9.0] (2021-12-20)
=======================================
The following sections list the changes in ownCloud core 10.9.0 relevant to
Expand Down
2 changes: 1 addition & 1 deletion apps/files/lib/Command/VerifyChecksums.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function execute(InputInterface $input, OutputInterface $output) {
$this->exitStatus = self::EXIT_INVALID_ARGS;
return $this->exitStatus;
}
if ($node === FileInfo::TYPE_FILE) {
if ($node->getType() === FileInfo::TYPE_FILE) {
$this->verifyChecksumsForFile($node, $input, $output);
} else {
$this->verifyChecksumsForFolder($node, $input, $output);
Expand Down
28 changes: 27 additions & 1 deletion apps/files/tests/Command/VerifyChecksumsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private function createFileForUser($uid, $path, $content) {
* @return bool|IUser
*/
private function createRandomUser($number) {
$userName = $this->getUniqueID("$number-verifycheksums");
$userName = $this->getUniqueID("$number-verifychecksums");
$user = $this->createUser($userName);
$this->loginAsUser($userName);

Expand Down Expand Up @@ -271,6 +271,32 @@ public function testOnlyFilesInGivenPathArgumentAreRepaired() {
$this->assertEquals(self::BROKEN_CHECKSUM_STRING, $file4->getChecksum());
}

/**
* @depends testBrokenFilesAreRepairedWithRepairArgument
*/
public function testSingleFileInGivenPathArgumentIsRepaired() {

/** @var File $file1 */
$file1 = $this->testFiles[0]['file'];
/** @var File $file2 */
$file2 = $this->testFiles[1]['file'];

$this->breakChecksum($file1);
$this->breakChecksum($file2);

$this->cmd->execute([
'-r' => null,
'-u' => $this->user1,
'-p' => "dir/nested/somefile.txt"
]);

$this->assertChecksumsAreCorrect([
$this->testFiles[0],
]);

$this->assertEquals(self::BROKEN_CHECKSUM_STRING, $file2->getChecksum());
}

public function testOnlyFilesOfAGivenUserAreRepaired() {

/** @var File $file1 */
Expand Down
55 changes: 43 additions & 12 deletions apps/files_versions/lib/MetaStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,27 +137,56 @@ public function moveCurrentToVersion(string $currentFileName, FileInfo $versionF
* metadata.
*
* @param string $authorUid
* @param string $fileOwner
* @param FileInfo $version
*/
public function createForVersion(string $authorUid, FileInfo $version) {
$path = self::pathToAbsDiskPath($authorUid, $version->getInternalPath()) . self::VERSION_FILE_EXT;
public function createForVersion(string $authorUid, string $fileOwner, FileInfo $version) {
$path = self::pathToAbsDiskPath($fileOwner, $version->getInternalPath()) . self::VERSION_FILE_EXT;
self::writeMetaFile($authorUid, $path);
}

/**
* Retrieve the uid of the user that has authored a given version.
* Retrieve the uid of the user that has authored a given version.
*
* @param FileInfo $versionFile
* @return string|null null if no metadata is available
*/
public function getAuthorUid(FileInfo $versionFile) : ?string {
$metaDataFilePath = $this->dataDir . '/' . $versionFile->getPath() . MetaStorage::VERSION_FILE_EXT;
if (\file_exists($metaDataFilePath)) {
$json = \file_get_contents($metaDataFilePath);
if ($decoded = \json_decode($json, true)) {
if (isset($decoded[MetaPlugin::VERSION_EDITED_BY_PROPERTYNAME])) {
return $decoded[MetaPlugin::VERSION_EDITED_BY_PROPERTYNAME];
}
return $this->getVersionAuthorByPath($metaDataFilePath);
}

return null;
}

/**
* Retrieve the uid of the user that has authored the current version.
*
* @param string $uid
* @param string $filename
* @return string|null null if no metadata is available
*/
public function getCurrentVersionAuthorUid(string $uid, string $filename) : ?string {
$metaDataFilePath = $this->pathToAbsDiskPath($uid, "files_versions$filename" . self::CURRENT_FILE_EXT);
if (\file_exists($metaDataFilePath)) {
return $this->getVersionAuthorByPath($metaDataFilePath);
}

return null;
}

/**
* Retrieve the uid of a given version file path. Presumes that the file exists.
*
* @param string $path
* @return string|null
*/
protected function getVersionAuthorByPath(string $path) : ?string {
$json = \file_get_contents($path);
if ($decoded = \json_decode($json, true)) {
if (isset($decoded[MetaPlugin::VERSION_EDITED_BY_PROPERTYNAME])) {
return $decoded[MetaPlugin::VERSION_EDITED_BY_PROPERTYNAME];
}
}

Expand Down Expand Up @@ -190,13 +219,12 @@ public function deleteCurrent(View $versionsView, string $filename) {
}

/**
*
* After a version is restored, the version's metadata is also restored
* and becomes the current metadata of the file.
*
* @param $uid
* @param $fileToRestore
* @param $target
* @param string $uid
* @param string $fileToRestore
* @param string $target
*/
public function restore(string $uid, string $fileToRestore, string $target) {
$restoreDirName = \dirname($fileToRestore);
Expand All @@ -207,6 +235,9 @@ public function restore(string $uid, string $fileToRestore, string $target) {

if (\file_exists($src)) {
\rename($src, $dst);
} elseif (\file_exists($dst)) {
// Remove current author file in case there is no author to restore
\unlink($dst);
}
}

Expand Down
5 changes: 4 additions & 1 deletion apps/files_versions/lib/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,10 @@ public static function restoreVersion($uid, $filename, $fileToRestore, $revision
if (self::metaEnabled()) {
$versionFileInfo = $users_view->getFileInfo($version);
if ($versionFileInfo && !$versionFileInfo->getStorage()->instanceOfStorage(ObjectStoreStorage::class)) {
self::$metaData->createForVersion($uid, $versionFileInfo);
$versionAuthor = self::$metaData->getCurrentVersionAuthorUid($uid, $filename);
if ($versionAuthor) {
self::$metaData->createForVersion($versionAuthor, $uid, $versionFileInfo);
}
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions changelog/10.9.1_2021-12-28/39673
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: Prevent version author from being overwritten with wrong uid

Fixed an issue where restoring a previous version could lead to a wrong
version author being saved, basically overwriting the correct author.

https://github.com/owncloud/core/pull/39673
https://github.com/owncloud/core/issues/39672
5 changes: 5 additions & 0 deletions changelog/unreleased/39683
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Fix files:checksums:verify for a single file

Fixed an issue where running files:checksums:verify for a single file would fail.

https://github.com/owncloud/core/pull/39683
2 changes: 1 addition & 1 deletion tests/TestHelpers/HttpRequestHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public static function createRequest(
if (strpos($url, "/apps/testing") !== false) {
$oCISServerUrl = \getenv('TEST_SERVER_URL');
$oC10ServerUrl = \getenv('TEST_OC10_URL');

$url = str_replace($oCISServerUrl, $oC10ServerUrl, $url);
} else {
// set 'owncloud-server' selector cookie for oCIS requests
Expand Down
10 changes: 3 additions & 7 deletions tests/TestHelpers/WebDavHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,18 +460,16 @@ public static function makeDavRequest(
):ResponseInterface {
$baseUrl = self::sanitizeUrl($baseUrl, true);

$usingSpacesDavPath = false;
$spaceId = null;
// get space id if testing with spaces dav
if ($davPathVersionToUse === 3) {
$usingSpacesDavPath = true;
$spaceId = self::getPersonalSpaceIdForUser($baseUrl, $user, $password, $xRequestId);
}

if ($doDavRequestAsUser === null) {
$davPath = self::getDavPath($user, $davPathVersionToUse, $type, $usingSpacesDavPath, $spaceId);
$davPath = self::getDavPath($user, $davPathVersionToUse, $type, $spaceId);
} else {
$davPath = self::getDavPath($doDavRequestAsUser, $davPathVersionToUse, $type, $usingSpacesDavPath, $spaceId);
$davPath = self::getDavPath($doDavRequestAsUser, $davPathVersionToUse, $type, $spaceId);
}

//replace %, # and ? and in the path, Guzzle will not encode them
Expand Down Expand Up @@ -536,7 +534,6 @@ public static function makeDavRequest(
* @param string|null $user
* @param int|null $davPathVersionToUse (1|2)
* @param string|null $type
* @param bool $usingSpaces
* @param string|null $spaceId
*
* @return string
Expand All @@ -545,7 +542,6 @@ public static function getDavPath(
?string $user,
?int $davPathVersionToUse = null,
?string $type = "files",
?bool $usingSpaces = false,
?string $spaceId = null
):string {
if ($type === "public-files" || $type === "public-files-old") {
Expand All @@ -560,7 +556,7 @@ public static function getDavPath(
if ($type === "customgroups") {
return "remote.php/dav/";
}
if ($usingSpaces) {
if ($davPathVersionToUse === 3) {
return "dav/spaces/" . $spaceId . '/';
} else {
if ($davPathVersionToUse === 1) {
Expand Down
Loading