From 9716b0d7350aa28481a5a9642b74da847c0fa211 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Wed, 17 Jul 2024 02:03:18 +0200 Subject: refactor: Migrate some legacy and core functions to `IFilenameValidator` Signed-off-by: Ferdinand Thiessen --- tests/lib/Security/CertificateManagerTest.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/lib/Security/CertificateManagerTest.php b/tests/lib/Security/CertificateManagerTest.php index fc5ae1f03f2..e123ebeda25 100644 --- a/tests/lib/Security/CertificateManagerTest.php +++ b/tests/lib/Security/CertificateManagerTest.php @@ -12,8 +12,10 @@ namespace Test\Security; use OC\Files\View; use OC\Security\CertificateManager; +use OCP\Files\InvalidPathException; use OCP\IConfig; use OCP\Security\ISecureRandom; +use PHPUnit\Framework\MockObject\MockObject; use Psr\Log\LoggerInterface; /** @@ -25,12 +27,9 @@ class CertificateManagerTest extends \Test\TestCase { use \Test\Traits\UserTrait; use \Test\Traits\MountProviderTrait; - /** @var CertificateManager */ - private $certificateManager; - /** @var String */ - private $username; - /** @var ISecureRandom */ - private $random; + private CertificateManager $certificateManager; + private string $username; + private ISecureRandom&MockObject $random; protected function setUp(): void { parent::setUp(); @@ -117,9 +116,7 @@ class CertificateManagerTest extends \Test\TestCase { * @param string $filename */ public function testAddDangerousFile($filename) { - $this->expectException(\Exception::class); - $this->expectExceptionMessage('Filename is not valid'); - + $this->expectException(InvalidPathException::class); $this->certificateManager->addCertificate(file_get_contents(__DIR__ . '/../../data/certificates/expiredCertificate.crt'), $filename); } -- cgit v1.2.3