diff options
Diffstat (limited to 'lib/plugins/authplain/_test')
-rw-r--r-- | lib/plugins/authplain/_test/escaping.test.php | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/lib/plugins/authplain/_test/escaping.test.php b/lib/plugins/authplain/_test/escaping.test.php index 5cf631508..9df96389a 100644 --- a/lib/plugins/authplain/_test/escaping.test.php +++ b/lib/plugins/authplain/_test/escaping.test.php @@ -13,13 +13,13 @@ */ class helper_plugin_authplain_escaping_test extends DokuWikiTest { - protected $pluginsEnabled = array('authplain'); - /** @var auth_plugin_authplain */ + protected $pluginsEnabled = array('authplainharness'); + /** @var auth_plugin_authplain|auth_plugin_authplainharness */ protected $auth; protected function reloadUsers() { /* auth caches data loaded from file, but recreated object forces reload */ - $this->auth = new auth_plugin_authplain(); + $this->auth = new auth_plugin_authplainharness(); } function setUp() { @@ -77,7 +77,44 @@ class helper_plugin_authplain_escaping_test extends DokuWikiTest { $this->assertEquals($saved['name'], $user['name']); $this->assertTrue($this->auth->checkPass("testuser", $user['pass'])); } + + // really only required for developers to ensure this plugin will + // work with systems running on PCRE 6.6 and lower. + public function testLineSplit(){ + $this->auth->setPregsplit_safe(false); + + $names = array( + 'plain', + 'ut-fठ8', + 'colon:', + 'backslash\\', + 'alltogether\\ठ:' + ); + $userpass = 'user:password_hash:'; + $other_user_data = ':email@address:group1,group2'; + + foreach ($names as $testname) { + $escaped = str_replace(array('\\',':'),array('\\\\','\\:'),$testname); // escape : & \ + $test_line = $userpass.$escaped.$other_user_data; + $result = $this->auth->splitUserData($test_line); + + $this->assertEquals($escaped, $result[2]); + } + } } -?>
\ No newline at end of file +class auth_plugin_authplainharness extends auth_plugin_authplain { + + public function setPregsplit_safe($bool) { + $this->_pregsplit_safe = $bool; + } + + public function getPregsplit_safe(){ + return $this->_pregsplit_safe; + } + + public function splitUserData($line){ + return $this->_splitUserData($line); + } +} |