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

[stable30] Ci fixes #48205

Merged
merged 17 commits into from
Sep 19, 2024
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
23 changes: 23 additions & 0 deletions apps/dav/lib/Connector/Sabre/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,27 @@ public function __construct($treeOrNode = null) {
self::$exposeVersion = false;
$this->enablePropfindDepthInfinity = true;
}

// Copied from 3rdparty/sabre/dav/lib/DAV/Server.php
// Should be them exact same without the exception output.
public function start(): void {
try {
// If nginx (pre-1.2) is used as a proxy server, and SabreDAV as an
// origin, we must make sure we send back HTTP/1.0 if this was
// requested.
// This is mainly because nginx doesn't support Chunked Transfer
// Encoding, and this forces the webserver SabreDAV is running on,
// to buffer entire responses to calculate Content-Length.
$this->httpResponse->setHTTPVersion($this->httpRequest->getHTTPVersion());

// Setting the base url
$this->httpRequest->setBaseUrl($this->getBaseUri());
$this->invokeMethod($this->httpRequest, $this->httpResponse);
} catch (\Throwable $e) {
try {
$this->emit('exception', [$e]);
} catch (\Exception $ignore) {
}
}
}
}
1 change: 0 additions & 1 deletion apps/dav/lib/Files/ErrorPagePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ public function generateBody(\Throwable $ex, int $httpCode): mixed {
*/
public function sendResponse() {
$this->server->sapi->sendResponse($this->server->httpResponse);
exit();
}

private function acceptHtml(): bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
namespace OCA\DAV\Tests\unit\Connector\Sabre\RequestTest;

use OC\AllConfig;
use OCP\IConfig;

/**
Expand All @@ -31,7 +32,7 @@ protected function setUp(): void {
return $config->getSystemValue($key, $default);
}
});
$this->overwriteService('AllConfig', $mockConfig);
$this->overwriteService(AllConfig::class, $mockConfig);
parent::setUp();
}

Expand Down
42 changes: 41 additions & 1 deletion apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,8 @@ public function dataGetShare() {

$parentFolder = $this->getMockBuilder(Folder::class)->getMock();
$parentFolder->method('getId')->willReturn(3);
$mountPoint = $this->createMock(IMountPoint::class);
$mountPoint->method('getMountType')->willReturn('');

$file = $this->getMockBuilder('OCP\Files\File')->getMock();
$file->method('getId')->willReturn(1);
Expand All @@ -543,6 +545,7 @@ public function dataGetShare() {
$file->method('getSize')->willReturn(123465);
$file->method('getMTime')->willReturn(1234567890);
$file->method('getMimeType')->willReturn('myMimeType');
$file->method('getMountPoint')->willReturn($mountPoint);

$folder = $this->getMockBuilder(Folder::class)->getMock();
$folder->method('getId')->willReturn(2);
Expand All @@ -552,6 +555,7 @@ public function dataGetShare() {
$folder->method('getSize')->willReturn(123465);
$folder->method('getMTime')->willReturn(1234567890);
$folder->method('getMimeType')->willReturn('myFolderMimeType');
$folder->method('getMountPoint')->willReturn($mountPoint);

[$shareAttributes, $shareAttributesReturnJson] = $this->mockShareAttributes();

Expand Down Expand Up @@ -607,6 +611,9 @@ public function dataGetShare() {
'item_size' => 123465,
'item_mtime' => 1234567890,
'attributes' => null,
'item_permissions' => 4,
'is-mount-root' => false,
'mount-type' => '',
];
$data[] = [$share, $expected];

Expand Down Expand Up @@ -661,6 +668,9 @@ public function dataGetShare() {
'item_size' => 123465,
'item_mtime' => 1234567890,
'attributes' => null,
'item_permissions' => 4,
'is-mount-root' => false,
'mount-type' => '',
];
$data[] = [$share, $expected];

Expand Down Expand Up @@ -721,6 +731,9 @@ public function dataGetShare() {
'item_size' => 123465,
'item_mtime' => 1234567890,
'attributes' => null,
'item_permissions' => 4,
'is-mount-root' => false,
'mount-type' => '',
];
$data[] = [$share, $expected];

Expand Down Expand Up @@ -3740,6 +3753,12 @@ public function dataFormatShare() {
$folder->method('getMimeType')->willReturn('myFolderMimeType');
$fileWithPreview->method('getMimeType')->willReturn('mimeWithPreview');

$mountPoint = $this->createMock(IMountPoint::class);
$mountPoint->method('getMountType')->willReturn('');
$file->method('getMountPoint')->willReturn($mountPoint);
$folder->method('getMountPoint')->willReturn($mountPoint);
$fileWithPreview->method('getMountPoint')->willReturn($mountPoint);

$file->method('getPath')->willReturn('file');
$folder->method('getPath')->willReturn('folder');
$fileWithPreview->method('getPath')->willReturn('fileWithPreview');
Expand Down Expand Up @@ -3839,6 +3858,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => '[{"scope":"permissions","key":"download","value":true}]',
'item_permissions' => 1,
], $share, [], false
];
// User backend up
Expand Down Expand Up @@ -3880,6 +3900,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => '[{"scope":"permissions","key":"download","value":true}]',
'item_permissions' => 1,
], $share, [
['owner', $owner],
['initiator', $initiator],
Expand Down Expand Up @@ -3937,6 +3958,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -3990,6 +4012,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 11,
], $share, [], false
];

Expand Down Expand Up @@ -4044,6 +4067,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4095,6 +4119,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4153,6 +4178,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4211,6 +4237,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4263,6 +4290,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4315,6 +4343,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4370,6 +4399,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4422,6 +4452,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4474,6 +4505,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4543,6 +4575,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4598,6 +4631,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, [], false
];

Expand Down Expand Up @@ -4651,6 +4685,7 @@ public function dataFormatShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 11,
], $share, [], false
];

Expand Down Expand Up @@ -4815,6 +4850,7 @@ public function dataFormatRoomShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 1,
], $share, false, []
];

Expand Down Expand Up @@ -4866,6 +4902,7 @@ public function dataFormatRoomShare() {
'is-mount-root' => false,
'mount-type' => '',
'attributes' => null,
'item_permissions' => 9,
], $share, true, [
'share_with_displayname' => 'recipientRoomName'
]
Expand Down Expand Up @@ -4905,11 +4942,14 @@ public function testFormatRoomShare(array $expects, \OCP\Share\IShare $share, bo
->willReturn(true);

$helper = $this->getMockBuilder('\OCA\Talk\Share\Helper\ShareAPIController')
->setMethods(['formatShare'])
->setMethods(['formatShare', 'canAccessShare'])
->getMock();
$helper->method('formatShare')
->with($share)
->willReturn($formatShareByHelper);
$helper->method('canAccessShare')
->with($share)
->willReturn(true);

$this->serverContainer->method('get')
->with('\OCA\Talk\Share\Helper\ShareAPIController')
Expand Down
3 changes: 2 additions & 1 deletion apps/files_sharing/tests/Controller/ShareControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ public function testShowShare() {
'note' => $note,
'hideDownload' => false,
'showgridview' => false,
'label' => ''
'label' => '',
'filename' => $filename,
];

$csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
Expand Down
2 changes: 2 additions & 0 deletions apps/files_sharing/tests/External/CacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use OCP\Contacts\IManager;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\ICloudIdManager;
use OCP\Files\Cache\ICacheEntry;
use OCP\ICacheFactory;
use OCP\IURLGenerator;
use OCP\IUserManager;
Expand Down Expand Up @@ -74,6 +75,7 @@ protected function setUp(): void {
$this->storage,
$this->cloudIdManager->getCloudId($this->remoteUser, 'http://example.com/owncloud')
);
$this->cache->insert('', ['size' => 0, 'mtime' => 0, 'mimetype' => ICacheEntry::DIRECTORY_MIMETYPE]);
$this->cache->put(
'test.txt',
[
Expand Down
1 change: 1 addition & 0 deletions apps/files_trashbin/tests/StorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,7 @@ public function testShouldMoveToTrash($mountPoint, $path, $userExists, $appDisab
$event->expects($this->any())->method('shouldMoveToTrashBin')->willReturn(!$appDisablesTrash);

$userFolder->expects($this->any())->method('getById')->with($fileID)->willReturn([$node]);
$rootFolder->expects($this->any())->method('getById')->with($fileID)->willReturn([$node]);
$rootFolder->expects($this->any())->method('getUserFolder')->willReturn($userFolder);

$storage = $this->getMockBuilder(Storage::class)
Expand Down
15 changes: 1 addition & 14 deletions core/templates/exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,7 @@

style('core', ['styles', 'header', 'exception']);

function print_exception(Throwable $e, \OCP\IL10N $l): void {
print_unescaped('<pre>');
p($e->getTraceAsString());
print_unescaped('</pre>');

if ($e->getPrevious() !== null) {
print_unescaped('<br />');
print_unescaped('<h4>');
p($l->t('Previous'));
print_unescaped('</h4>');

print_exception($e->getPrevious(), $l);
}
}
require_once __DIR__ . '/print_exception.php';

?>
<div class="guest-box wide">
Expand Down
21 changes: 21 additions & 0 deletions core/templates/print_exception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2012-2015 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/

function print_exception(Throwable $e, \OCP\IL10N $l): void {
print_unescaped('<pre>');
p($e->getTraceAsString());
print_unescaped('</pre>');

if ($e->getPrevious() !== null) {
print_unescaped('<br />');
print_unescaped('<h4>');
p($l->t('Previous'));
print_unescaped('</h4>');

print_exception($e->getPrevious(), $l);
}
}
16 changes: 16 additions & 0 deletions core/templates/print_xml_exception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2012-2015 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/

function print_exception(Throwable $e, \OCP\IL10N $l): void {
p($e->getTraceAsString());

if ($e->getPrevious() !== null) {
print_unescaped('<s:previous-exception>');
print_exception($e->getPrevious(), $l);
print_unescaped('</s:previous-exception>');
}
}
10 changes: 1 addition & 9 deletions core/templates/xml_exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,7 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/

function print_exception(Throwable $e, \OCP\IL10N $l): void {
p($e->getTraceAsString());

if ($e->getPrevious() !== null) {
print_unescaped('<s:previous-exception>');
print_exception($e->getPrevious(), $l);
print_unescaped('</s:previous-exception>');
}
}
require_once __DIR__ . '/print_xml_exception.php';

print_unescaped('<?xml version="1.0" encoding="utf-8"?>' . "\n");
?>
Expand Down
Loading
Loading