Skip to content
Snippets Groups Projects
Commit dd8e62d4 authored by Patrick Radtke's avatar Patrick Radtke
Browse files

655 allow core:php to manipulate all of the state

parent e4d7c082
No related branches found
No related tags found
No related merge requests found
......@@ -49,7 +49,7 @@ class PHP extends \SimpleSAML\Auth\ProcessingFilter
assert(is_array($request));
assert(array_key_exists('Attributes', $request));
$function = function(/** @scrutinizer ignore-unused */ &$attributes) { eval($this->code); };
$function($request['Attributes']);
$function = function(/** @scrutinizer ignore-unused */ &$attributes, &$state) { eval($this->code); };
$function($request['Attributes'], $request);
}
}
......@@ -111,4 +111,42 @@ class Test_Core_Auth_Process_PHP extends TestCase
);
$this->processFilter($config, $request);
}
/**
* Check that the entire state can be adjusted.
*/
public function testStateCanBeModified()
{
$config = array(
'code' => '
$attributes["orig2"] = array("value0");
$state["newKey"] = ["newValue"];
$state["Destination"]["attributes"][] = "givenName";
',
);
$request = array(
'Attributes' => array(
'orig1' => array('value1', 'value2'),
'orig2' => array('value3'),
'orig3' => array('value4')
),
'Destination' => [
'attributes' => ['eduPersonPrincipalName']
],
);
$expected = array(
'Attributes' => array(
'orig1' => array('value1', 'value2'),
'orig2' => array('value0'),
'orig3' => array('value4')
),
'Destination' => [
'attributes' => ['eduPersonPrincipalName', 'givenName']
],
'newKey' => ['newValue']
);
$this->assertEquals($expected, $this->processFilter($config, $request));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment