test(OCM): Throw IdentityNotFoundException

Signed-off-by: Micke Nordin <kano@sunet.se>
pull/62543/head
Micke Nordin 2 weeks ago
parent 41cc0a4ed6
commit 3dcf085f64
No known key found for this signature in database
GPG Key ID: 4A10941FAD116B7E
  1. 5
      tests/lib/OCM/OCMSignatoryManagerRotationTest.php

@ -19,6 +19,7 @@ use OCP\IAppConfig;
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IURLGenerator;
use OCP\Security\Signature\Exceptions\IdentityNotFoundException;
use OCP\Security\Signature\ISignatureManager;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
@ -46,6 +47,8 @@ class OCMSignatoryManagerRotationTest extends TestCase {
$this->wireIdentityProofManager();
$signatureManager = $this->createMock(ISignatureManager::class);
$signatureManager->method('generateKeyIdFromConfig')
->willThrowException(new IdentityNotFoundException('no configured identity'));
$urlGenerator = $this->createMock(IURLGenerator::class);
$urlGenerator->method('getAbsoluteURL')
->willReturnCallback(static fn (string $path): string => 'https://alice.example' . $path);
@ -188,6 +191,8 @@ class OCMSignatoryManagerRotationTest extends TestCase {
// identity at all; provisioning the first key should fail loudly so
// the admin gets a clear message instead of a corrupt half-state.
$signatureManager = $this->createMock(ISignatureManager::class);
$signatureManager->method('generateKeyIdFromConfig')
->willThrowException(new IdentityNotFoundException('no configured identity'));
$urlGenerator = $this->createMock(IURLGenerator::class);
// getAbsoluteURL() yields no host, so the kid's identity cannot be
// resolved; provisioning must fail loudly rather than corrupt state.

Loading…
Cancel
Save