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
3 changes: 2 additions & 1 deletion apps/dav/lib/Command/CreateCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use OCP\IGroupManager;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\L10N\IFactory;
use OCP\Security\ISecureRandom;
use OCP\Server;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -66,7 +67,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
Server::get(ProxyMapper::class),
Server::get(KnownUserService::class),
Server::get(IConfig::class),
\OC::$server->getL10NFactory(),
Server::get(IFactory::class),
);
$random = Server::get(ISecureRandom::class);
$logger = Server::get(LoggerInterface::class);
Expand Down
3 changes: 2 additions & 1 deletion apps/dav/lib/Files/RootCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace OCA\DAV\Files;

use OCP\Files\FileInfo;
use OCP\Files\IRootFolder;
use OCP\IUserSession;
use OCP\Server;
use Sabre\DAV\INode;
Expand Down Expand Up @@ -35,7 +36,7 @@ public function getChildForPrincipal(array $principalInfo) {
// in the future this could be considered to be used for accessing shared files
return new SimpleCollection($name);
}
$userFolder = \OC::$server->getUserFolder();
$userFolder = Server::get(IRootFolder::class)->getUserFolder($user->getUID());
if (!($userFolder instanceof FileInfo)) {
throw new \Exception('Home does not exist');
}
Expand Down
3 changes: 2 additions & 1 deletion apps/dav/lib/RootCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
use OCP\IGroupManager;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\L10N\IFactory;
use OCP\Security\ISecureRandom;
use OCP\Server;
use OCP\SystemTag\ISystemTagManager;
Expand Down Expand Up @@ -75,7 +76,7 @@ public function __construct() {
$proxyMapper,
Server::get(KnownUserService::class),
Server::get(IConfig::class),
\OC::$server->getL10NFactory()
Server::get(IFactory::class)
);

$groupPrincipalBackend = new GroupPrincipalBackend($groupManager, $userSession, $shareManager, $config);
Expand Down
6 changes: 4 additions & 2 deletions apps/files_sharing/tests/ExternalStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
use OCP\Http\Client\IClient;
use OCP\Http\Client\IClientService;
use OCP\Http\Client\IResponse;
use OCP\ICertificateManager;
use OCP\Server;

/**
* Tests for the external Storage class for remote shares.
*/
#[\PHPUnit\Framework\Attributes\Group(name: 'DB')]
class ExternalStorageTest extends \Test\TestCase {
public static function optionsProvider() {
public static function optionsProvider(): array {
return [
[
'http://remoteserver:8080/owncloud',
Expand Down Expand Up @@ -54,7 +56,7 @@ public static function optionsProvider() {
}

private function getTestStorage($uri) {
$certificateManager = \OC::$server->getCertificateManager();
$certificateManager = Server::get(ICertificateManager::class);
$httpClientService = $this->createMock(IClientService::class);
$manager = $this->createMock(ExternalShareManager::class);
$client = $this->createMock(IClient::class);
Expand Down
8 changes: 5 additions & 3 deletions apps/testing/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\IAppConfig;
use OCP\IGroupManager;
use OCP\IUserManager;
use OCP\Settings\Events\DeclarativeSettingsGetValueEvent;
use OCP\Settings\Events\DeclarativeSettingsRegisterFormEvent;
use OCP\Settings\Events\DeclarativeSettingsSetValueEvent;
Expand Down Expand Up @@ -67,9 +69,9 @@ public function register(IRegistrationContext $context): void {

public function boot(IBootContext $context): void {
$server = $context->getServerContainer();
$config = $server->getConfig();
if ($config->getAppValue(self::APP_ID, 'enable_alt_user_backend', 'no') === 'yes') {
$userManager = $server->getUserManager();
$config = $server->get(IAppConfig::class);
if ($config->getValueBool(self::APP_ID, 'enable_alt_user_backend')) {
$userManager = $server->get(IUserManager::class);

// replace all user backends with this one
$userManager->clearBackends();
Expand Down
8 changes: 3 additions & 5 deletions build/integration/features/bootstrap/CalDavContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
use Psr\Http\Message\ResponseInterface;

class CalDavContext implements \Behat\Behat\Context\Context {
/** @var string */
private $baseUrl;
/** @var Client */
private $client;
/** @var ResponseInterface */
Expand All @@ -24,9 +22,9 @@ class CalDavContext implements \Behat\Behat\Context\Context {
/**
* @param string $baseUrl
*/
public function __construct($baseUrl) {
$this->baseUrl = $baseUrl;

public function __construct(
private $baseUrl,
) {
// in case of ci deployment we take the server url from the environment
$testServerUrl = getenv('TEST_SERVER_URL');
if ($testServerUrl !== false) {
Expand Down
11 changes: 3 additions & 8 deletions build/integration/features/bootstrap/CardDavContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,16 @@
use GuzzleHttp\Message\ResponseInterface;

class CardDavContext implements \Behat\Behat\Context\Context {
/** @var string */
private $baseUrl;
/** @var Client */
private $client;
/** @var ResponseInterface */
private $response;
/** @var string */
private $responseXml = '';

/**
* @param string $baseUrl
*/
public function __construct($baseUrl) {
$this->baseUrl = $baseUrl;

public function __construct(
private string $baseUrl,
) {
// in case of ci deployment we take the server url from the environment
$testServerUrl = getenv('TEST_SERVER_URL');
if ($testServerUrl !== false) {
Expand Down
11 changes: 3 additions & 8 deletions build/integration/features/bootstrap/ChecksumsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,14 @@
use GuzzleHttp\Message\ResponseInterface;

class ChecksumsContext implements \Behat\Behat\Context\Context {
/** @var string */
private $baseUrl;
/** @var Client */
private $client;
/** @var ResponseInterface */
private $response;

/**
* @param string $baseUrl
*/
public function __construct($baseUrl) {
$this->baseUrl = $baseUrl;

public function __construct(
private string $baseUrl,
) {
// in case of ci deployment we take the server url from the environment
$testServerUrl = getenv('TEST_SERVER_URL');
if ($testServerUrl !== false) {
Expand Down
9 changes: 4 additions & 5 deletions build/integration/features/bootstrap/CommandLineContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ class CommandLineContext implements \Behat\Behat\Context\Context {
private $lastTransferPath;

private $featureContext;
private $localBaseUrl;
private $remoteBaseUrl;

public function __construct($ocPath, $baseUrl) {
public function __construct(
$ocPath,
private $baseUrl,
) {
$this->ocPath = rtrim($ocPath, '/') . '/';
$this->localBaseUrl = $baseUrl;
$this->remoteBaseUrl = $baseUrl;
}

/**
Expand Down
8 changes: 3 additions & 5 deletions build/integration/features/bootstrap/CommentsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
require __DIR__ . '/autoload.php';

class CommentsContext implements \Behat\Behat\Context\Context {
/** @var string */
private $baseUrl;
/** @var array */
private $response;
/** @var int */
Expand All @@ -20,9 +18,9 @@ class CommentsContext implements \Behat\Behat\Context\Context {
/**
* @param string $baseUrl
*/
public function __construct($baseUrl) {
$this->baseUrl = $baseUrl;

public function __construct(
private $baseUrl,
) {
// in case of ci deployment we take the server url from the environment
$testServerUrl = getenv('TEST_SERVER_URL');
if ($testServerUrl !== false) {
Expand Down
2 changes: 2 additions & 0 deletions build/integration/features/bootstrap/ConversionsContext.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
Expand Down
2 changes: 2 additions & 0 deletions build/integration/features/bootstrap/DavFeatureContext.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
use Psr\Http\Message\ResponseInterface;

class PrincipalPropertySearchContext implements Context {
private string $baseUrl;
private Client $client;
private ResponseInterface $response;

public function __construct(string $baseUrl) {
$this->baseUrl = $baseUrl;

public function __construct(
private string $baseUrl,
) {
// in case of ci deployment we take the server url from the environment
$testServerUrl = getenv('TEST_SERVER_URL');
if ($testServerUrl !== false) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
30 changes: 18 additions & 12 deletions build/integration/features/bootstrap/RemoteContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
use Behat\Behat\Context\Context;
use OC\Remote\Api\OCS;
use OC\Remote\Credentials;
use OC\Remote\Instance;
use OC\Remote\User;
use OCP\Http\Client\IClientService;
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\Server;
use PHPUnit\Framework\Assert;

require __DIR__ . '/autoload.php';
Expand All @@ -14,26 +21,25 @@
* Remote context.
*/
class RemoteContext implements Context {
/** @var \OC\Remote\Instance */
/** @var Instance */
protected $remoteInstance;

/** @var \OC\Remote\Credentials */
/** @var Credentials */
protected $credentails;

/** @var \OC\Remote\User */
/** @var User */
protected $userResult;

protected $remoteUrl;

protected $lastException;

public function __construct($remote) {
public function __construct(
private string $remote,
) {
require_once __DIR__ . '/../../../../lib/base.php';
$this->remoteUrl = $remote;
}

protected function getApiClient() {
return new \OC\Remote\Api\OCS($this->remoteInstance, $this->credentails, \OC::$server->get(IClientService::class));
return new OCS($this->remoteInstance, $this->credentails, Server::get(IClientService::class));
}

/**
Expand All @@ -43,13 +49,13 @@ protected function getApiClient() {
*/
public function selectRemoteInstance($remoteServer) {
if ($remoteServer == 'REMOTE') {
$baseUri = $this->remoteUrl;
$baseUri = $this->remote;
} else {
$baseUri = 'nonexistingnextcloudserver.local';
}
$this->lastException = null;
try {
$this->remoteInstance = new \OC\Remote\Instance($baseUri, \OC::$server->getMemCacheFactory()->createLocal(), \OC::$server->get(IClientService::class));
$this->remoteInstance = new Instance($baseUri, Server::get(ICacheFactory::class)->createLocal(), Server::get(IClientService::class));
// trigger the status request
$this->remoteInstance->getProtocol();
} catch (\Exception $e) {
Expand All @@ -63,7 +69,7 @@ public function selectRemoteInstance($remoteServer) {
*/
public function theRemoteVersionShouldBe($version) {
if ($version === '__current_version__') {
$version = \OC::$server->getConfig()->getSystemValue('version', '0.0.0.0');
$version = Server::get(IConfig::class)->getSystemValue('version', '0.0.0.0');
}

Assert::assertEquals($version, $this->remoteInstance->getVersion());
Expand All @@ -83,7 +89,7 @@ public function theRemoteProtocolShouldBe($protocol) {
* @param string $password
*/
public function usingCredentials($user, $password) {
$this->credentails = new \OC\Remote\Credentials($user, $password);
$this->credentails = new Credentials($user, $password);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions build/integration/features/bootstrap/SetupContext.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
2 changes: 2 additions & 0 deletions build/integration/features/bootstrap/ShareesContext.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
Expand Down
4 changes: 2 additions & 2 deletions build/integration/features/bootstrap/Sharing.php
Original file line number Diff line number Diff line change
Expand Up @@ -619,9 +619,9 @@ private function assertFieldIsInReturnedShare(string $field, string $contentExpe
} elseif ($contentExpected === 'A_TOKEN') {
// A token is composed by 15 characters from
// ISecureRandom::CHAR_HUMAN_READABLE.
Assert::assertRegExp('/^[abcdefgijkmnopqrstwxyzABCDEFGHJKLMNPQRSTWXYZ23456789]{15}$/', (string)$returnedShare->$field, "Field '$field' is not a token");
Assert::assertMatchesRegularExpression('/^[abcdefgijkmnopqrstwxyzABCDEFGHJKLMNPQRSTWXYZ23456789]{15}$/', (string)$returnedShare->$field, "Field '$field' is not a token");
} elseif (strpos($contentExpected, 'REGEXP ') === 0) {
Assert::assertRegExp(substr($contentExpected, strlen('REGEXP ')), (string)$returnedShare->$field, "Field '$field' does not match");
Assert::assertMatchesRegularExpression(substr($contentExpected, strlen('REGEXP ')), (string)$returnedShare->$field, "Field '$field' does not match");
} else {
Assert::assertEquals($contentExpected, (string)$returnedShare->$field, "Field '$field' does not match");
}
Expand Down
2 changes: 2 additions & 0 deletions build/integration/features/bootstrap/SharingContext.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
8 changes: 3 additions & 5 deletions build/integration/features/bootstrap/TagsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
use GuzzleHttp\Message\ResponseInterface;

class TagsContext implements \Behat\Behat\Context\Context {
/** @var string */
private $baseUrl;
/** @var Client */
private $client;
/** @var ResponseInterface */
Expand All @@ -22,9 +20,9 @@ class TagsContext implements \Behat\Behat\Context\Context {
/**
* @param string $baseUrl
*/
public function __construct($baseUrl) {
$this->baseUrl = $baseUrl;

public function __construct(
private $baseUrl,
) {
// in case of ci deployment we take the server url from the environment
$testServerUrl = getenv('TEST_SERVER_URL');
if ($testServerUrl !== false) {
Expand Down
2 changes: 2 additions & 0 deletions build/integration/features/bootstrap/autoload.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
Loading
Loading