19declare(strict_types=1);
23use PHPUnit\Framework\TestCase;
29 private int $now = 1_000_000;
33 protected function setUp(): void
40 $settings = $this->createStub(\ilSetting::class);
41 $settings->method(
'get')->willReturnCallback(
42 fn(
string $key, ?
string $default =
null): ?
string => $this->stored[$key] ?? $default
44 $settings->method(
'set')->willReturnCallback(
function (
string $key,
string $value):
void {
45 $this->stored[$key] = $value;
47 $settings->method(
'delete')->willReturnCallback(
function (
string $key):
void {
48 unset($this->stored[$key]);
57 throw new \RuntimeException(
'discovery not reachable');
69 $this->assertSame(
'bmV3', $keys->current->modulus);
70 $this->assertSame(
'bmV3', $this->stored[
'wopi_proof_modulus']);
77 $this->assertNotNull($refresh());
79 $this->assertNull($refresh());
81 $this->assertNotNull($refresh());
82 $this->assertSame(2, $this->fetches);
87 $this->stored[
'wopi_proof_modulus'] =
'b2xk';
88 $this->stored[
'wopi_proof_exponent'] =
'AQAB';
90 $this->assertNull(($this->
refresh(
true))());
91 $this->assertSame(
'b2xk', $this->stored[
'wopi_proof_modulus']);
96 $this->stored[
'wopi_proof_modulus'] =
'b2xk';
97 $this->stored[
'wopi_proof_exponent'] =
'AQAB';
98 $this->discovered =
null;
100 $this->assertNull(($this->
refresh())());
101 $this->assertSame(
'b2xk', $this->stored[
'wopi_proof_modulus']);
testFailedFetchKeepsTheStoredKeys()
testDiscoveryWithoutKeysKeepsTheStoredKeys()
refresh(bool $failing=false)
testFetchedKeysAreStoredAndReturned()
testFetchesAtMostOnceWithinTheInterval()
Fetches the proof keys from the discovery again when a request could not be verified with the stored ...
A public RSA key of a WOPI client, as published in its discovery with base64 encoded modulus and expo...
The current and the previous proof key of a WOPI client.