diff options
author | Gerrit Uitslag <klapinklapin@gmail.com> | 2014-09-28 13:46:04 +0200 |
---|---|---|
committer | Gerrit Uitslag <klapinklapin@gmail.com> | 2014-09-28 13:46:04 +0200 |
commit | b79379f2e598abaa2febb299cdfcebe0a95d034c (patch) | |
tree | 7098c3a758f606394f4b38d679b5198f8973cffe /lib/plugins/authplain/_test | |
parent | 73411587cb6d2c54aefebe90c87799c4aa1d31ec (diff) | |
parent | da9572711f54d13ce3c5506971154b0bc359723f (diff) | |
download | rpg-b79379f2e598abaa2febb299cdfcebe0a95d034c.tar.gz rpg-b79379f2e598abaa2febb299cdfcebe0a95d034c.tar.bz2 |
Merge remote-tracking branch 'origin/master' into overridablelangstrings
Conflicts:
inc/plugin.php
Diffstat (limited to 'lib/plugins/authplain/_test')
-rw-r--r-- | lib/plugins/authplain/_test/escaping.test.php | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/lib/plugins/authplain/_test/escaping.test.php b/lib/plugins/authplain/_test/escaping.test.php new file mode 100644 index 000000000..cd5294157 --- /dev/null +++ b/lib/plugins/authplain/_test/escaping.test.php @@ -0,0 +1,82 @@ +<?php + +/** + * These tests are designed to test the capacity of pluginauth to handle + * correct escaping of colon field delimiters and backslashes in user content. + * + * (Note that these tests set some Real Names, etc. that are may not be + * valid in the broader dokuwiki context, but the tests ensure that + * authplain won't get unexpectedly surprised.) + * + * @group plugin_authplain + * @group plugins + */ +class helper_plugin_authplain_escaping_test extends DokuWikiTest { + + protected $pluginsEnabled = array('authplain'); + protected $auth; + + protected function reloadUsers() { + /* auth caches data loaded from file, but recreated object forces reload */ + $this->auth = new auth_plugin_authplain(); + } + + function setUp() { + global $config_cascade; + parent::setUp(); + $name = $config_cascade['plainauth.users']['default']; + copy($name, $name.".orig"); + $this->reloadUsers(); + } + + function tearDown() { + global $config_cascade; + parent::tearDown(); + $name = $config_cascade['plainauth.users']['default']; + copy($name.".orig", $name); + } + + public function testMediawikiPasswordHash() { + global $conf; + $conf['passcrypt'] = 'mediawiki'; + $this->auth->createUser("mwuser", "12345", "Mediawiki User", "me@example.com"); + $this->reloadUsers(); + $this->assertTrue($this->auth->checkPass("mwuser", "12345")); + $mwuser = $this->auth->getUserData("mwuser"); + $this->assertStringStartsWith(":B:",$mwuser['pass']); + $this->assertEquals("Mediawiki User",$mwuser['name']); + } + + public function testNameWithColons() { + $name = ":Colon: User:"; + $this->auth->createUser("colonuser", "password", $name, "me@example.com"); + $this->reloadUsers(); + $user = $this->auth->getUserData("colonuser"); + $this->assertEquals($name,$user['name']); + } + + public function testNameWithBackslashes() { + $name = "\\Slash\\ User\\"; + $this->auth->createUser("slashuser", "password", $name, "me@example.com"); + $this->reloadUsers(); + $user = $this->auth->getUserData("slashuser"); + $this->assertEquals($name,$user['name']); + } + + public function testModifyUser() { + global $conf; + $conf['passcrypt'] = 'mediawiki'; + $user = $this->auth->getUserData("testuser"); + $user['name'] = "\\New:Crazy:Name\\"; + $user['pass'] = "awesome new password"; + $this->auth->modifyUser("testuser", $user); + $this->reloadUsers(); + + $saved = $this->auth->getUserData("testuser"); + $this->assertEquals($saved['name'], $user['name']); + $this->assertTrue($this->auth->checkPass("testuser", $user['pass'])); + } + +} + +?>
\ No newline at end of file |