From c9dfb1429d7bf83571b9cde7cea6b37ed73f9ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Pe=CC=81rez=20Crespo?= <jaime.perez@uninett.no> Date: Wed, 17 Oct 2018 14:58:07 +0200 Subject: [PATCH] Make SimpleSAML\Session and SimpleSAML\Store implement the ClearableState interface. This way we can clear their state as well between tests, not only the configuration. This allows for richer functional testing. --- lib/SimpleSAML/Session.php | 12 +++++++++++- lib/SimpleSAML/Store.php | 11 ++++++++++- tests/Utils/StateClearer.php | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php index b21a6e710..feea0fbd3 100644 --- a/lib/SimpleSAML/Session.php +++ b/lib/SimpleSAML/Session.php @@ -22,7 +22,7 @@ use SimpleSAML\Error; * @package SimpleSAMLphp */ -class Session implements \Serializable +class Session implements \Serializable, Utils\ClearableState { /** * This is a timeout value for setData, which indicates that the data @@ -1134,4 +1134,14 @@ class Session implements \Serializable } return $authorities; } + + + /** + * Clear any configuration information cached + */ + public static function clearInternalState() + { + self::$instance = null; + self::$sessions = null; + } } diff --git a/lib/SimpleSAML/Store.php b/lib/SimpleSAML/Store.php index d5be90656..7f227fca2 100644 --- a/lib/SimpleSAML/Store.php +++ b/lib/SimpleSAML/Store.php @@ -9,7 +9,7 @@ use SimpleSAML\Error\CriticalConfigurationError; * * @package SimpleSAMLphp */ -abstract class Store +abstract class Store implements Utils\ClearableState { /** * Our singleton instance. @@ -100,4 +100,13 @@ abstract class Store * @param string $key The key. */ abstract public function delete($type, $key); + + + /** + * Clear any SSP specific state, such as SSP environmental variables or cached internals. + */ + public static function clearInternalState() + { + self::$instance = null; + } } diff --git a/tests/Utils/StateClearer.php b/tests/Utils/StateClearer.php index db32db8e7..89dafe4af 100644 --- a/tests/Utils/StateClearer.php +++ b/tests/Utils/StateClearer.php @@ -18,7 +18,7 @@ class StateClearer * Class that implement \SimpleSAML\Utils\ClearableState and should have clearInternalState called between tests * @var array */ - private $clearableState = array('SimpleSAML\Configuration'); + private $clearableState = array('SimpleSAML\Configuration', 'SimpleSAML\Store', 'SimpleSAML\Session'); /** * Environmental variables to unset -- GitLab