Skip to content

Commit

Permalink
Update BlockLegacyClientPluginTest to reflect the new 403 error message.
Browse files Browse the repository at this point in the history
Signed-off-by: Camila Ayres <hello@camilasan.com>
  • Loading branch information
camilasan committed Feb 22, 2024
1 parent 53e8c97 commit 7670c30
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apps/dav/lib/Connector/Sabre/BlockLegacyClientPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function beforeHandler(RequestInterface $request) {
if (isset($versionMatches[1]) &&
version_compare($versionMatches[1], $minimumSupportedDesktopVersion) === -1) {
$customClientDesktopLink = $this->config->getSystemValue('customclient_desktop', 'https://nextcloud.com/install/#install-clients');
throw new \Sabre\DAV\Exception\Forbidden('This version of the client is unsupported. Upgrade to version '.$minimumSupportedDesktopVersion.' or later. Please open '.$customClientDesktopLink.' to download the update.');
throw new \Sabre\DAV\Exception\Forbidden('This version of the client is unsupported. Upgrade to <a href="'.$customClientDesktopLink.'">version '.$minimumSupportedDesktopVersion.' or later</a>.');
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,20 @@ public function oldDesktopClientProvider(): array {
*/
public function testBeforeHandlerException(string $userAgent): void {
$this->expectException(\Sabre\DAV\Exception\Forbidden::class);
$this->expectExceptionMessage('Unsupported client version.');

$this->config
->expects($this->once())
->method('getSystemValue')
->with('customclient_desktop', 'https://nextcloud.com/install/#install-clients')
->willReturn('https://nextcloud.com/install/#install-clients');

$this->config
->expects($this->once())
->method('getSystemValue')
->with('minimum.supported.desktop.version', '2.3.0')
->willReturn('1.7.0');

$this->expectExceptionMessage('This version of the client is unsupported. Upgrade to <a href="https://nextcloud.com/install/#install-clients">version 1.7.0 or later</a>.');

/** @var RequestInterface|MockObject $request */
$request = $this->createMock('\Sabre\HTTP\RequestInterface');
Expand All @@ -74,11 +87,6 @@ public function testBeforeHandlerException(string $userAgent): void {
->with('User-Agent')
->willReturn($userAgent);

$this->config
->expects($this->once())
->method('getSystemValue')
->with('minimum.supported.desktop.version', '2.3.0')
->willReturn('1.7.0');

$this->blockLegacyClientVersionPlugin->beforeHandler($request);
}
Expand Down

0 comments on commit 7670c30

Please sign in to comment.