Skip to content
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ You can use the `\Psr\Container\ContainerInterface`, see [dependency injection](

# Testing
Front-end tests (Vitest for unit/component, Playwright for end-to-end) are documented in [TESTING.md](TESTING.md).

4 changes: 1 addition & 3 deletions tests/stubs/doctrine_dbal_driver_exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,5 @@ interface Exception extends Throwable
*
* @return string|null
*/
public function getSQLState()
{
}
public function getSQLState();
}
8 changes: 2 additions & 6 deletions tests/stubs/oc_hooks_emitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ interface Emitter {
* @return void
* @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher::addListener
*/
public function listen($scope, $method, callable $callback)
{
}
public function listen($scope, $method, callable $callback);

/**
* @param string $scope optional
Expand All @@ -36,7 +34,5 @@ public function listen($scope, $method, callable $callback)
* @return void
* @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher::removeListener
*/
public function removeListener($scope = null, $method = null, ?callable $callback = null)
{
}
public function removeListener($scope = null, $method = null, ?callable $callback = null);
}
1 change: 1 addition & 0 deletions tests/stubs/oca_dav_carddav_contactsmanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/

namespace OCA\DAV\CardDAV;

use OCA\DAV\AppInfo\Application;
Expand Down
230 changes: 180 additions & 50 deletions tests/stubs/oca_files_sharing_external_storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,124 @@
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/

namespace OCA\Files_Sharing\External;

use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use OC\Files\Storage\BearerAuthAwareSabreClient;
use OC\Files\Storage\DAV;
use OC\ForbiddenException;
use OCA\Files_Sharing\External\Manager as ExternalShareManager;
use OCA\Files_Sharing\ISharedStorage;
use OCP\AppFramework\Http;
use OCP\Constants;
use OCP\Federation\ICloudId;
use OCP\Files\Cache\ICache;
use OCP\Files\Cache\IScanner;
use OCP\Files\Cache\IWatcher;
use OCP\Files\NotFoundException;
use OCP\Files\Storage\IDisableEncryptionStorage;
use OCP\Files\Storage\IReliableEtagStorage;
use OCP\Files\Storage\IStorage;
use OCP\Files\StorageInvalidException;
use OCP\Files\StorageNotAvailableException;
use OCP\Http\Client\IClientService;
use OCP\Http\Client\LocalServerException;
use OCP\IAppConfig;
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IUserSession;
use OCP\OCM\Exceptions\OCMArgumentException;
use OCP\OCM\Exceptions\OCMProviderException;
use OCP\OCM\IOCMDiscoveryService;
use OCP\Server;
use OCP\Share\IManager as IShareManager;
use Psr\Log\LoggerInterface;

class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage, IReliableEtagStorage {
protected IAppConfig $appConfig;

private const int REFRESH_MAX_ATTEMPTS = 3;
private const int REFRESH_BACKOFF_SECONDS = 5;

class Storage implements IDisableEncryptionStorage, IReliableEtagStorage {
public function getWatcher(string $path = '', ?IStorage $storage = null): IWatcher {
}

public function getRemoteUser(): string {
}

public function getRemote(): string {
}

public function getMountPoint(): string {
}

public function getToken(): string {
}

public function getPassword(): ?string {
}

public function getId(): string {
}

public function getCache(string $path = '', ?IStorage $storage = null): ICache {
}

public function getScanner(string $path = '', ?IStorage $storage = null): IScanner {
}

public function hasUpdated(string $path, int $time): bool {
}
/**
* @param array{HttpClientService: IClientService, manager: ExternalShareManager, cloudId: ICloudId, mountpoint: string, token: string, access_token: ?string, access_token_expires: ?int}|array $options
*/
public function __construct($options)
{
}

public function test(): bool {
}
/**
* Refresh the access token. Extends parent to also persist to database.
*
* Uses expiry timestamps instead of a boolean flag so that concurrent
* processes can detect that another process already obtained a fresh token
* and reuse it rather than performing a redundant exchange.
*
* After a failed exchange, a 60-second backoff is applied so that
* subsequent file operations do not hammer the remote token endpoint.
* The DB is still consulted during backoff in case a concurrent process
* succeeded; only the outgoing exchange call is suppressed.
*
* @return string|null the access token (freshly exchanged or reused from
* DB), or null if refresh is currently not possible
*/
#[\Override]
protected function refreshAccessToken(): ?string
{
}

#[\Override]
public function getWatcher(string $path = '', ?IStorage $storage = null): IWatcher
{
}

public function getRemoteUser(): string
{
}

public function getRemote(): string
{
}

public function getMountPoint(): string
{
}

public function getToken(): string
{
}

public function getPassword(): ?string
{
}

#[\Override]
public function getId(): string
{
}

#[\Override]
public function getCache(string $path = '', ?IStorage $storage = null): ICache
{
}

#[\Override]
public function getScanner(string $path = '', ?IStorage $storage = null): IScanner
{
}

#[\Override]
public function hasUpdated(string $path, int $time): bool
{
}

#[\Override]
public function test(): bool
{
}

/**
* Check whether this storage is permanently or temporarily
Expand All @@ -56,28 +132,82 @@ public function test(): bool {
* @throws StorageNotAvailableException
* @throws StorageInvalidException
*/
public function checkStorageAvailability(): void {
}
public function checkStorageAvailability(): void
{
}

public function file_exists(string $path): bool {
}
#[\Override]
public function file_exists(string $path): bool
{
}

public function getShareInfo(int $depth = -1) {
}

public function getOwner(string $path): string|false {
}
/**
* Check if the configured remote is a valid-federated share provider
*/
protected function testRemote(): bool
{
}

public function isSharable(string $path): bool {
}
/**
* Check whether the remote is an ownCloud/Nextcloud. This is needed since some sharing
* features are not standardized.
*
* @throws LocalServerException
*/
public function remoteIsOwnCloud(): bool
{
}

public function getPermissions(string $path): int {
}
/**
* @return mixed
* @throws ForbiddenException
* @throws NotFoundException
* @throws \Exception
*/
public function getShareInfo(int $depth = -1)
{
}

#[\Override]
public function getOwner(string $path): string|false
{
}

#[\Override]
public function isSharable(string $path): bool
{
}

#[\Override]
public function getPermissions(string $path): int
{
}

#[\Override]
public function needsPartFile(): bool
{
}

public function needsPartFile(): bool {
return false;
}
/**
* Translate OCM Permissions to Nextcloud permissions
*
* @param string $ocmPermissions json encoded OCM permissions
* @param string $path path to file
* @return int
*/
protected function ocmPermissions2ncPermissions(string $ocmPermissions, string $path): int
{
}

public function free_space(string $path): int|float|false {
}
/**
* Calculate the default permissions in case no permissions are provided
*/
protected function getDefaultPermissions(string $path): int
{
}

#[\Override]
public function free_space(string $path): int|float|false
{
}
}
17 changes: 2 additions & 15 deletions tests/stubs/oca_user_ldap_mapping_abstractmapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/

namespace OCA\User_LDAP\Mapping;

use Doctrine\DBAL\Exception;
use OCP\DB\IPreparedStatement;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IAppConfig;
use OCP\ICache;
Expand All @@ -28,9 +28,7 @@ abstract class AbstractMapping {
*
* @return string
*/
abstract protected function getTableName(bool $includePrefix = true)
{
}
abstract protected function getTableName(bool $includePrefix = true);

/**
* A month worth of cache time for as good as never changing mapping data.
Expand Down Expand Up @@ -93,17 +91,6 @@ public function isColNameValid($col)
*/
protected function getXbyY($fetchCol, $compareCol, $search)
{
}

/**
* Performs a DELETE or UPDATE query to the database.
*
* @param IPreparedStatement $statement
* @param array $parameters
* @return bool true if at least one row was modified, false otherwise
*/
protected function modify(IPreparedStatement $statement, $parameters)
{
}

/**
Expand Down
6 changes: 4 additions & 2 deletions tests/stubs/oca_user_ldap_mapping_usermapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,17 @@ public function __construct(IDBConnection $dbc, ICacheFactory $cacheFactory, IAp
/**
* @throws HintException
*/
public function map($fdn, $name, $uuid): bool
#[\Override]
public function map($fdn, $name, $uuid): bool
{
}

/**
* returns the DB table name which holds the mappings
* @return string
*/
protected function getTableName(bool $includePrefix = true)
#[\Override]
protected function getTableName(bool $includePrefix = true)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ interface CompletionAwareInterface
* @param CompletionContext $context
* @return array
*/
public function completeOptionValues($optionName, CompletionContext $context)
{
}
public function completeOptionValues($optionName, CompletionContext $context);

/**
* Return possible values for the named argument
Expand All @@ -25,7 +23,5 @@ public function completeOptionValues($optionName, CompletionContext $context)
* @param CompletionContext $context
* @return array
*/
public function completeArgumentValues($argumentName, CompletionContext $context)
{
}
public function completeArgumentValues($argumentName, CompletionContext $context);
}
Loading
Loading