1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LightSaml\Tests\Resolver\Endpoint; |
4
|
|
|
|
5
|
|
|
use LightSaml\Criteria\CriteriaSet; |
6
|
|
|
use LightSaml\Model\Metadata\EndpointReference; |
7
|
|
|
use LightSaml\Model\Metadata\EntityDescriptor; |
8
|
|
|
use LightSaml\Model\Metadata\SingleSignOnService; |
9
|
|
|
use LightSaml\Model\Metadata\SpSsoDescriptor; |
10
|
|
|
use LightSaml\Resolver\Endpoint\BindingEndpointResolver; |
11
|
|
|
use LightSaml\Resolver\Endpoint\Criteria\BindingCriteria; |
12
|
|
|
use LightSaml\SamlConstants; |
13
|
|
|
use LightSaml\Tests\BaseTestCase; |
14
|
|
|
|
15
|
|
|
class BindingEndpointResolverTest extends BaseTestCase |
16
|
|
|
{ |
17
|
|
|
public function test__does_not_modify_when_criteria_not_present() |
18
|
|
|
{ |
19
|
|
|
$candidates = [ |
20
|
|
|
$firstEndpoint = $this->getMockBuilder(EndpointReference::class)->disableOriginalConstructor()->getMock(), |
21
|
|
|
$secondEndpoint = $this->getMockBuilder(EndpointReference::class)->disableOriginalConstructor()->getMock(), |
22
|
|
|
]; |
23
|
|
|
|
24
|
|
|
$resolver = new BindingEndpointResolver(); |
25
|
|
|
|
26
|
|
|
$result = $resolver->resolve(new CriteriaSet([]), $candidates); |
|
|
|
|
27
|
|
|
|
28
|
|
|
$this->assertCount(2, $result); |
|
|
|
|
29
|
|
|
$this->assertSame($firstEndpoint, $result[0]); |
30
|
|
|
$this->assertSame($secondEndpoint, $result[1]); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function test__filters_by_given_bindings() |
34
|
|
|
{ |
35
|
|
|
$criteriaSet = new CriteriaSet([new BindingCriteria([ |
36
|
|
|
SamlConstants::BINDING_SAML2_HTTP_POST, |
37
|
|
|
SamlConstants::BINDING_SAML2_HTTP_REDIRECT |
38
|
|
|
])]); |
39
|
|
|
|
40
|
|
|
$candidates = [ |
41
|
|
|
$firstEndpoint = new EndpointReference( |
42
|
|
|
new EntityDescriptor(), |
43
|
|
|
new SpSsoDescriptor(), |
44
|
|
|
(new SingleSignOnService())->setBinding(SamlConstants::BINDING_SAML2_SOAP) |
45
|
|
|
), |
46
|
|
|
$secondEndpoint = new EndpointReference( |
47
|
|
|
new EntityDescriptor(), |
48
|
|
|
new SpSsoDescriptor(), |
49
|
|
|
(new SingleSignOnService())->setBinding(SamlConstants::BINDING_SAML2_HTTP_REDIRECT) |
50
|
|
|
), |
51
|
|
|
$thirdEndpoint = new EndpointReference( |
52
|
|
|
new EntityDescriptor(), |
53
|
|
|
new SpSsoDescriptor(), |
54
|
|
|
(new SingleSignOnService())->setBinding(SamlConstants::BINDING_SAML2_HTTP_POST) |
55
|
|
|
), |
56
|
|
|
$fourthEndpoint = new EndpointReference( |
57
|
|
|
new EntityDescriptor(), |
58
|
|
|
new SpSsoDescriptor(), |
59
|
|
|
(new SingleSignOnService())->setBinding(SamlConstants::BINDING_SAML2_HTTP_ARTIFACT) |
60
|
|
|
), |
61
|
|
|
]; |
62
|
|
|
|
63
|
|
|
$resolver = new BindingEndpointResolver(); |
64
|
|
|
|
65
|
|
|
$result = $resolver->resolve($criteriaSet, $candidates); |
66
|
|
|
|
67
|
|
|
$this->assertCount(2, $result); |
|
|
|
|
68
|
|
|
$this->assertSame($thirdEndpoint, $result[0]); |
69
|
|
|
$this->assertSame($secondEndpoint, $result[1]); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: