@@ -59,6 +59,34 @@ public function testBasic(): void
5959 }
6060
6161
62+ /**
63+ * The most basic test of no match.
64+ *
65+ * @throws \SimpleSAML\Error\Exception
66+ */
67+ public function testBasicNoMatch (): void
68+ {
69+ $ config = [
70+ 'sourceattribute ' => 'memberOf ' ,
71+ 'targetattribute ' => 'eduPersonAffiliation ' ,
72+ 'values ' => [
73+ 'member ' => [
74+ 'nomatch ' ,
75+ ],
76+ ],
77+ ];
78+ $ request = [
79+ 'Attributes ' => [
80+ 'memberOf ' => ['theGroup ' ],
81+ ],
82+ ];
83+ $ result = self ::processFilter ($ config , $ request );
84+ $ attributes = $ result ['Attributes ' ];
85+ $ this ->assertArrayNotHasKey ('memberOf ' , $ attributes );
86+ $ this ->assertArrayNotHasKey ('eduPersonAffiliation ' , $ attributes );
87+ }
88+
89+
6290 /**
6391 * Test basic functionality, remove duplicates
6492 *
@@ -225,4 +253,63 @@ public function testMissingTargetAttribute(): void
225253 ];
226254 self ::processFilter ($ config , $ request );
227255 }
256+
257+
258+ /**
259+ * Basic regular expression functionality test.
260+ *
261+ * @throws \SimpleSAML\Error\Exception
262+ */
263+ public function testBasicRegex (): void
264+ {
265+ $ config = [
266+ 'sourceattribute ' => 'memberOf ' ,
267+ 'targetattribute ' => 'eduPersonAffiliation ' ,
268+ '%regex ' ,
269+ 'values ' => [
270+ 'member ' => [
271+ '/^the/ ' ,
272+ ],
273+ ],
274+ ];
275+ $ request = [
276+ 'Attributes ' => [
277+ 'memberOf ' => ['theGroup ' ],
278+ ],
279+ ];
280+ $ result = self ::processFilter ($ config , $ request );
281+ $ attributes = $ result ['Attributes ' ];
282+ $ this ->assertArrayNotHasKey ('memberOf ' , $ attributes );
283+ $ this ->assertArrayHasKey ('eduPersonAffiliation ' , $ attributes );
284+ $ this ->assertEquals ($ attributes ['eduPersonAffiliation ' ], ['member ' ]);
285+ }
286+
287+
288+ /**
289+ * Basic regular expression functionality test of a "no match".
290+ *
291+ * @throws \SimpleSAML\Error\Exception
292+ */
293+ public function testBasicRegexNoMatch (): void
294+ {
295+ $ config = [
296+ 'sourceattribute ' => 'memberOf ' ,
297+ 'targetattribute ' => 'eduPersonAffiliation ' ,
298+ '%regex ' ,
299+ 'values ' => [
300+ 'member ' => [
301+ '/^nomatch$/ ' ,
302+ ],
303+ ],
304+ ];
305+ $ request = [
306+ 'Attributes ' => [
307+ 'memberOf ' => ['theGroup ' ],
308+ ],
309+ ];
310+ $ result = self ::processFilter ($ config , $ request );
311+ $ attributes = $ result ['Attributes ' ];
312+ $ this ->assertArrayNotHasKey ('memberOf ' , $ attributes );
313+ $ this ->assertArrayNotHasKey ('eduPersonAffiliation ' , $ attributes );
314+ }
228315}
0 commit comments