-
Notifications
You must be signed in to change notification settings - Fork 142
fix: do not fetch remote collabora url for own server #4714
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types = 1); | ||
|
|
||
| /** | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace Tests\Richdocuments; | ||
|
|
||
| use OCA\Federation\TrustedServers; | ||
| use OCA\Richdocuments\AppConfig; | ||
| use OCA\Richdocuments\Service\FederationService; | ||
| use OCA\Richdocuments\TokenManager; | ||
| use OCP\Http\Client\IClientService; | ||
| use OCP\ICacheFactory; | ||
| use OCP\IRequest; | ||
| use OCP\IURLGenerator; | ||
| use OCP\Security\ITrustedDomainHelper; | ||
| use PHPUnit\Framework\TestCase; | ||
| use Psr\Log\LoggerInterface; | ||
|
|
||
| class FederationServiceTest extends TestCase { | ||
| public const NEXTCLOUD_ADDRESS = 'https://nextcloud.local'; | ||
| public const COLLABORA_ADDRESS = 'https://collabora.local'; | ||
|
|
||
| public function setUp(): void { | ||
| parent::setUp(); | ||
|
|
||
| $this->cacheFactory = $this->createMock(ICacheFactory::class); | ||
| $this->clientService = $this->createMock(IClientService::class); | ||
| $this->logger = $this->createMock(LoggerInterface::class); | ||
| $this->tokenManager = $this->createMock(TokenManager::class); | ||
| $this->appConfig = $this->createStub(AppConfig::class); | ||
| $this->request = $this->createMock(IRequest::class); | ||
| $this->urlGenerator = $this->createMock(IURLGenerator::class); | ||
| $this->trustedDomainHelper = $this->createStub(ITrustedDomainHelper::class); | ||
|
|
||
| $this->federationService = new FederationService( | ||
| $this->cacheFactory, | ||
| $this->clientService, | ||
| $this->logger, | ||
| $this->tokenManager, | ||
| $this->appConfig, | ||
| $this->request, | ||
| $this->urlGenerator, | ||
| $this->trustedDomainHelper | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * @test | ||
| * @testdox returns own instance's Collabora URL | ||
| */ | ||
| public function getRemoteCollaboraURLFromOwnInstance(): void { | ||
| // Ensure that trusted domains can be used for federated editing | ||
| $this->appConfig->method('isTrustedDomainAllowedForFederation') | ||
| ->willReturn(true); | ||
| $this->appConfig->method('getCollaboraUrlInternal') | ||
| ->willReturn(self::COLLABORA_ADDRESS); | ||
|
|
||
| $this->trustedDomainHelper->method('isTrustedUrl') | ||
| ->with(self::NEXTCLOUD_ADDRESS) | ||
| ->willReturn(true); | ||
|
|
||
| // Create a stub TrustedServers class which always tells us | ||
| // the server is trusted | ||
| $trustedServers = $this->createStub(TrustedServers::class); | ||
| $trustedServers->method('isTrustedServer') | ||
| ->with('nextcloud.local') | ||
| ->willReturn(true); | ||
|
|
||
| // Do some reflection property manipulation to set the TrustedServers object | ||
| // It would be nice if the TrustedServers were passed into FederationService | ||
| // instead of being set manually in the constructor to make testing easier | ||
| $reflection = new \ReflectionClass($this->federationService); | ||
| $reflectionProperty = $reflection->getProperty('trustedServers'); | ||
| $reflectionProperty->setAccessible(true); | ||
| $reflectionProperty->setValue($this->federationService, $trustedServers); | ||
|
|
||
| $this->assertEquals(self::COLLABORA_ADDRESS, $this->federationService->getRemoteCollaboraURL(self::NEXTCLOUD_ADDRESS)); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.