aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/tests
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2023-06-23 09:50:46 +0200
committerJoas Schilling <coding@schilljs.com>2023-07-11 07:35:50 +0200
commit308fc8d8edcd0cbb2b8554f53af1ab2a7bf4d486 (patch)
tree5c6bd48e99702fb7a87a320b5c46d8ac79ac8ed9 /apps/dav/tests
parent2c6f32cb28416a59084ac3069d06b3fb241fa02c (diff)
downloadnextcloud-server-308fc8d8edcd0cbb2b8554f53af1ab2a7bf4d486.tar.gz
nextcloud-server-308fc8d8edcd0cbb2b8554f53af1ab2a7bf4d486.zip
fix(dav): Use IRequest constant to match version
The pattern matches since a 10 year old client version Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/dav/tests')
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/AuthTest.php20
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php47
2 files changed, 18 insertions, 49 deletions
diff --git a/apps/dav/tests/unit/Connector/Sabre/AuthTest.php b/apps/dav/tests/unit/Connector/Sabre/AuthTest.php
index be841295f0b..b3b3341240a 100644
--- a/apps/dav/tests/unit/Connector/Sabre/AuthTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/AuthTest.php
@@ -301,11 +301,6 @@ class AuthTest extends TestCase {
$this->request
->expects($this->any())
->method('isUserAgent')
- ->with([
- '/^Mozilla\/5\.0 \([A-Za-z ]+\) (mirall|csyncoC)\/.*$/',
- '/^Mozilla\/5\.0 \(Android\) (ownCloud|Nextcloud)\-android.*$/',
- '/^Mozilla\/5\.0 \(iOS\) (ownCloud|Nextcloud)\-iOS.*$/',
- ])
->willReturn(false);
$this->session
->expects($this->any())
@@ -351,11 +346,6 @@ class AuthTest extends TestCase {
$this->request
->expects($this->any())
->method('isUserAgent')
- ->with([
- '/^Mozilla\/5\.0 \([A-Za-z ]+\) (mirall|csyncoC)\/.*$/',
- '/^Mozilla\/5\.0 \(Android\) ownCloud\-android.*$/',
- '/^Mozilla\/5\.0 \(iOS\) (ownCloud|Nextcloud)\-iOS.*$/',
- ])
->willReturn(false);
$this->session
->expects($this->any())
@@ -405,11 +395,6 @@ class AuthTest extends TestCase {
$this->request
->expects($this->any())
->method('isUserAgent')
- ->with([
- '/^Mozilla\/5\.0 \([A-Za-z ]+\) (mirall|csyncoC)\/.*$/',
- '/^Mozilla\/5\.0 \(Android\) (ownCloud|Nextcloud)\-android.*$/',
- '/^Mozilla\/5\.0 \(iOS\) (ownCloud|Nextcloud)\-iOS.*$/',
- ])
->willReturn(false);
$this->session
->expects($this->any())
@@ -451,11 +436,6 @@ class AuthTest extends TestCase {
$this->request
->expects($this->any())
->method('isUserAgent')
- ->with([
- '/^Mozilla\/5\.0 \([A-Za-z ]+\) (mirall|csyncoC)\/.*$/',
- '/^Mozilla\/5\.0 \(Android\) (ownCloud|Nextcloud)\-android.*$/',
- '/^Mozilla\/5\.0 \(iOS\) (ownCloud|Nextcloud)\-iOS.*$/',
- ])
->willReturn(true);
$this->session
->expects($this->any())
diff --git a/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php
index e0a274321f0..616e9796ab4 100644
--- a/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php
@@ -1,4 +1,6 @@
<?php
+
+declare(strict_types=1);
/**
* @copyright Copyright (c) 2016, ownCloud, Inc.
*
@@ -28,7 +30,9 @@ namespace OCA\DAV\Tests\unit\Connector\Sabre;
use OCA\DAV\Connector\Sabre\BlockLegacyClientPlugin;
use OCP\IConfig;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
+use Sabre\HTTP\RequestInterface;
/**
* Class BlockLegacyClientPluginTest
@@ -36,7 +40,7 @@ use Test\TestCase;
* @package OCA\DAV\Tests\unit\Connector\Sabre
*/
class BlockLegacyClientPluginTest extends TestCase {
- /** @var IConfig | \PHPUnit\Framework\MockObject\MockObject */
+ /** @var IConfig|MockObject */
private $config;
/** @var BlockLegacyClientPlugin */
private $blockLegacyClientVersionPlugin;
@@ -44,34 +48,25 @@ class BlockLegacyClientPluginTest extends TestCase {
protected function setUp(): void {
parent::setUp();
- $this->config = $this->getMockBuilder(IConfig::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->config = $this->createMock(IConfig::class);
$this->blockLegacyClientVersionPlugin = new BlockLegacyClientPlugin($this->config);
}
- /**
- * @return array
- */
- public function oldDesktopClientProvider() {
+ public function oldDesktopClientProvider(): array {
return [
- ['Mozilla/5.0 (1.5.0) mirall/1.5.0'],
- ['mirall/1.5.0'],
- ['mirall/1.5.4'],
- ['mirall/1.6.0'],
+ ['Mozilla/5.0 (Windows) mirall/1.5.0'],
['Mozilla/5.0 (Bogus Text) mirall/1.6.9'],
];
}
/**
* @dataProvider oldDesktopClientProvider
- * @param string $userAgent
*/
- public function testBeforeHandlerException($userAgent): void {
+ public function testBeforeHandlerException(string $userAgent): void {
$this->expectException(\Sabre\DAV\Exception\Forbidden::class);
$this->expectExceptionMessage('Unsupported client version.');
- /** @var \Sabre\HTTP\RequestInterface | \PHPUnit\Framework\MockObject\MockObject $request */
+ /** @var RequestInterface|MockObject $request */
$request = $this->createMock('\Sabre\HTTP\RequestInterface');
$request
->expects($this->once())
@@ -88,26 +83,20 @@ class BlockLegacyClientPluginTest extends TestCase {
$this->blockLegacyClientVersionPlugin->beforeHandler($request);
}
- /**
- * @return array
- */
- public function newAndAlternateDesktopClientProvider() {
+ public function newAndAlternateDesktopClientProvider(): array {
return [
- ['Mozilla/5.0 (1.7.0) mirall/1.7.0'],
- ['mirall/1.8.3'],
- ['mirall/1.7.2'],
- ['mirall/1.7.0'],
+ ['Mozilla/5.0 (Windows) mirall/1.7.0'],
['Mozilla/5.0 (Bogus Text) mirall/1.9.3'],
+ ['Mozilla/5.0 (Not Our Client But Old Version) LegacySync/1.1.0'],
];
}
/**
* @dataProvider newAndAlternateDesktopClientProvider
- * @param string $userAgent
*/
- public function testBeforeHandlerSuccess($userAgent): void {
- /** @var \Sabre\HTTP\RequestInterface | \PHPUnit\Framework\MockObject\MockObject $request */
- $request = $this->createMock('\Sabre\HTTP\RequestInterface');
+ public function testBeforeHandlerSuccess(string $userAgent): void {
+ /** @var RequestInterface|MockObject $request */
+ $request = $this->createMock(RequestInterface::class);
$request
->expects($this->once())
->method('getHeader')
@@ -124,8 +113,8 @@ class BlockLegacyClientPluginTest extends TestCase {
}
public function testBeforeHandlerNoUserAgent(): void {
- /** @var \Sabre\HTTP\RequestInterface | \PHPUnit\Framework\MockObject\MockObject $request */
- $request = $this->createMock('\Sabre\HTTP\RequestInterface');
+ /** @var RequestInterface|MockObject $request */
+ $request = $this->createMock(RequestInterface::class);
$request
->expects($this->once())
->method('getHeader')