1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SimpleSAML\Module\Monitor\Test; |
4
|
|
|
|
5
|
|
|
use SimpleSAML\Module\Monitor\TestCase; |
6
|
|
|
use SimpleSAML\Module\Monitor\TestData; |
7
|
|
|
use SimpleSAML\Module\Monitor\State; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Tests for TestCase\Metadata\Expiration |
11
|
|
|
*/ |
12
|
|
|
class TestMetadataExpirationTest extends \PHPUnit\Framework\TestCase |
13
|
|
|
{ |
14
|
|
|
public function testMetadataExpired(): void |
15
|
|
|
{ |
16
|
|
|
$testData = new TestData([ |
17
|
|
|
'entityId' => 'https://example.org', |
18
|
|
|
'entityMetadata' => ['expire' => time() - 1000], |
19
|
|
|
]); |
20
|
|
|
$expirationTest = new TestCase\Metadata\Expiration($testData); |
21
|
|
|
$testResult = $expirationTest->getTestResult(); |
22
|
|
|
|
23
|
|
|
$this->assertEquals(State::ERROR, $testResult->getState()); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function testMetadataValid(): void |
27
|
|
|
{ |
28
|
|
|
$testData = new TestData([ |
29
|
|
|
'entityId' => 'https://example.org', |
30
|
|
|
'entityMetadata' => ['expire' => time() + 1000], |
31
|
|
|
]); |
32
|
|
|
$expirationTest = new TestCase\Metadata\Expiration($testData); |
33
|
|
|
$testResult = $expirationTest->getTestResult(); |
34
|
|
|
|
35
|
|
|
$this->assertEquals(State::OK, $testResult->getState()); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function testMetadataNeverExpires(): void |
39
|
|
|
{ |
40
|
|
|
$testData = new TestData([ |
41
|
|
|
'entityId' => 'https://example.org', |
42
|
|
|
'entityMetadata' => [], |
43
|
|
|
]); |
44
|
|
|
$expirationTest = new TestCase\Metadata\Expiration($testData); |
45
|
|
|
$testResult = $expirationTest->getTestResult(); |
46
|
|
|
|
47
|
|
|
$this->assertEquals(State::OK, $testResult->getState()); |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|