@@ -25,8 +25,82 @@ protected function setUp()
25
25
\SimpleSAML_Configuration::loadFromArray (array (), '[ARRAY] ' , 'simplesaml ' );
26
26
}
27
27
28
- public function testAny ()
28
+ /**
29
+ * Test the example from docs
30
+ */
31
+ public function testExample ()
32
+ {
33
+ $ config = array (
34
+ 'attribute ' => 'eduPersonPrincipalName ' ,
35
+ 'limit ' => array ('eduPersonEntitlement ' , 'eduPersonAffiliation ' ),
36
+ 'replace ' => false ,
37
+ 'database ' => array (
38
+ 'username ' => 'phpunit ' ,
39
+ 'password ' => 'phpunit ' ,
40
+ ),
41
+ );
42
+ $ request = array (
43
+ 'Attributes ' => array (
44
+ 'eduPersonPrincipalName ' => array ('user@example.org ' ),
45
+ 'eduPersonAffiliation ' => array ('member ' ),
46
+ 'displayName ' => array ('Example User ' ),
47
+ ),
48
+ 'Destination ' => array (
49
+ 'entityid ' => 'https://idp.example.org/idp/shibboleth ' ,
50
+ ),
51
+ );
52
+ $ result = self ::processFilter ($ config , $ request );
53
+ $ attributes = $ result ['Attributes ' ];
54
+ $ expectedData = array (
55
+ 'eduPersonPrincipalName ' => array ('user@example.org ' ),
56
+ 'displayName ' => array ('Example User ' ),
57
+ 'eduPersonEntitlement ' => array (
58
+ 'urn:mace:exampleIdP.org:demoservice:demo-admin ' ,
59
+ 'urn:mace:grnet.gr:eduroam:admin ' ,
60
+ ),
61
+ 'eduPersonAffiliation ' => array (
62
+ 'member ' ,
63
+ 'faculty ' ,
64
+ ),
65
+ );
66
+ $ this ->assertEquals ($ expectedData , $ attributes , "Expected data was not correct " );
67
+ }
68
+
69
+ /**
70
+ * Test attribute replacement
71
+ */
72
+ public function testReplace ()
29
73
{
30
- $ this ->assertTrue (true , 'Just for travis.yml test ' );
74
+ $ config = array (
75
+ 'attribute ' => 'eduPersonPrincipalName ' ,
76
+ 'limit ' => array ('mail ' , 'eduPersonAffiliation ' ),
77
+ 'replace ' => true ,
78
+ 'database ' => array (
79
+ 'username ' => 'phpunit ' ,
80
+ 'password ' => 'phpunit ' ,
81
+ ),
82
+ );
83
+ $ request = array (
84
+ 'Attributes ' => array (
85
+ 'eduPersonPrincipalName ' => array ('user@example.org ' ),
86
+ 'eduPersonAffiliation ' => array ('member ' ),
87
+ 'displayName ' => array ('Example User ' ),
88
+ ),
89
+ 'Destination ' => array (
90
+ 'entityid ' => 'https://idp.example.org/idp/shibboleth ' ,
91
+ ),
92
+ );
93
+ $ result = self ::processFilter ($ config , $ request );
94
+ $ attributes = $ result ['Attributes ' ];
95
+ $ expectedData = array (
96
+ 'eduPersonPrincipalName ' => array ('user@example.org ' ),
97
+ 'displayName ' => array ('Example User ' ),
98
+ 'eduPersonAffiliation ' => array (
99
+ 'faculty ' ,
100
+ ),
101
+ 'mail ' => array ('user@example.org ' ),
102
+ );
103
+ $ this ->assertEquals ($ expectedData , $ attributes , "Expected data was not correct " );
31
104
}
105
+
32
106
}
0 commit comments