-
Notifications
You must be signed in to change notification settings - Fork 100
/
KnownAssertionIssuerActionTest.php
84 lines (64 loc) · 2.81 KB
/
KnownAssertionIssuerActionTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
namespace LightSaml\Tests\Action\Assertion\Inbound;
use LightSaml\Action\Assertion\Inbound\KnownAssertionIssuerAction;
use LightSaml\Model\Assertion\Assertion;
use LightSaml\Model\Assertion\Issuer;
use LightSaml\Tests\BaseTestCase;
class KnownAssertionIssuerActionTest extends BaseTestCase
{
public function test_constructs_with_logger_and_entity_descriptor_store()
{
new KnownAssertionIssuerAction($this->getLoggerMock(), $this->getEntityDescriptorStoreMock());
$this->assertTrue(true);
}
public function test_throws_context_exception_when_assertion_has_no_issuer()
{
$action = new KnownAssertionIssuerAction(
$loggerMock = $this->getLoggerMock(),
$entityDescriptorStoreMock = $this->getEntityDescriptorStoreMock()
);
$context = $this->getAssertionContext($assertion = new Assertion());
$loggerMock->expects($this->once())
->method('error')
->with('Assertion element must have an issuer element');
$this->expectException(\LightSaml\Error\LightSamlContextException::class);
$this->expectExceptionMessage("Assertion element must have an issuer element");
$action->execute($context);
}
public function test_throws_context_exception_on_unknown_issuer()
{
$action = new KnownAssertionIssuerAction(
$loggerMock = $this->getLoggerMock(),
$entityDescriptorStoreMock = $this->getEntityDescriptorStoreMock()
);
$context = $this->getAssertionContext($assertion = new Assertion());
$assertion->setIssuer(new Issuer($issuer = 'http://issuer.com'));
$entityDescriptorStoreMock->expects($this->once())
->method('has')
->with($issuer)
->willReturn(false);
$loggerMock->expects($this->once())
->method('error')
->with("Unknown issuer 'http://issuer.com'");
$this->expectExceptionMessage("Unknown issuer 'http://issuer.com'");
$this->expectException(\LightSaml\Error\LightSamlContextException::class);
$action->execute($context);
}
public function test_logs_known_issuer()
{
$action = new KnownAssertionIssuerAction(
$loggerMock = $this->getLoggerMock(),
$entityDescriptorStoreMock = $this->getEntityDescriptorStoreMock()
);
$context = $this->getAssertionContext($assertion = new Assertion());
$assertion->setIssuer(new Issuer($issuer = 'http://issuer.com'));
$entityDescriptorStoreMock->expects($this->once())
->method('has')
->with($issuer)
->willReturn(true);
$loggerMock->expects($this->once())
->method('debug')
->with('Known assertion issuer: "http://issuer.com"');
$action->execute($context);
}
}