From e0dd04a6493f1b7f7133f75c08f9ea55ee8bd50a Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 14 Oct 2011 16:39:36 +0200 Subject: Added bcrypt support for password hashes This method require PHP 5.3+ it will fail otherwise! --- _test/cases/inc/auth_password.test.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to '_test') diff --git a/_test/cases/inc/auth_password.test.php b/_test/cases/inc/auth_password.test.php index 928552a14..6fe564e73 100644 --- a/_test/cases/inc/auth_password.test.php +++ b/_test/cases/inc/auth_password.test.php @@ -48,6 +48,11 @@ class auth_password_test extends UnitTestCase { } } + function test_bcrypt_self(){ + $hash = auth_cryptPassword('foobcrypt','bcrypt'); + $this->assertTrue(auth_verifyPassword('foobcrypt',$hash)); + } + function test_verifyPassword_nohash(){ $this->assertTrue(auth_verifyPassword('foo','$1$$n1rTiFE0nRifwV/43bVon/')); } -- cgit v1.2.3 From 457ad80ad7c53870fc033997bfbf36e3904f9c4e Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Wed, 23 Nov 2011 20:25:58 +0100 Subject: introduced remote api class --- _test/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '_test') diff --git a/_test/index.php b/_test/index.php index f59c44cf4..64ece4762 100644 --- a/_test/index.php +++ b/_test/index.php @@ -11,7 +11,7 @@ if(@file_exists(DOKU_CONF.'local.php')){ require_once(DOKU_CONF.'local.php'); } $conf['lang'] = 'en'; define('TEST_ROOT', dirname(__FILE__)); define('TMPL_FILESCHEME_PATH', TEST_ROOT . '/filescheme/'); -error_reporting(E_ALL); +error_reporting(E_ALL & ~E_DEPRECATED); set_time_limit(600); ini_set('memory_limit','128M'); -- cgit v1.2.3 From c8ca60df97ff2b24091c7c0d0db72c680200ea1b Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 27 Nov 2011 11:08:44 +0100 Subject: added test case for lsmd5 passhashing --- _test/cases/inc/auth_password.test.php | 1 + 1 file changed, 1 insertion(+) (limited to '_test') diff --git a/_test/cases/inc/auth_password.test.php b/_test/cases/inc/auth_password.test.php index 928552a14..6c643a7ed 100644 --- a/_test/cases/inc/auth_password.test.php +++ b/_test/cases/inc/auth_password.test.php @@ -12,6 +12,7 @@ class auth_password_test extends UnitTestCase { 'md5' => '8fa22d62408e5351553acdd91c6b7003', 'sha1' => 'b456d3b0efd105d613744ffd549514ecafcfc7e1', 'ssha' => '{SSHA}QMHG+uC7bHNYKkmoLbNsNI38/dJhYmNk', + 'lsmd5' => '{SMD5}HGbkPrkWgy9KgcRGWlrsUWFiY2RlZmdo', 'crypt' => 'ablvoGr1hvZ5k', 'mysql' => '4a1fa3780bd6fd55', 'my411' => '*e5929347e25f82e19e4ebe92f1dc6b6e7c2dbd29', -- cgit v1.2.3 From f61380cb67f8216ae4c75922511ff5a07fd21ca0 Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Mon, 28 Nov 2011 19:06:16 +0100 Subject: introduced first remote test cases --- _test/cases/inc/remote.test.php | 77 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 _test/cases/inc/remote.test.php (limited to '_test') diff --git a/_test/cases/inc/remote.test.php b/_test/cases/inc/remote.test.php new file mode 100644 index 000000000..aa7a8cd1b --- /dev/null +++ b/_test/cases/inc/remote.test.php @@ -0,0 +1,77 @@ + array( + 'args' => array(), + 'return' => 'void' + ), + 'method2' => array( + 'args' => array('string', 'int', 'bool'), + 'return' => array('string'), + ) + ); + } +} + + +class remote_test extends UnitTestCase { + + var $originalConf; + + var $remote; + + function setUp() { + global $plugin_controller; + global $conf; + parent::setUp(); + $pluginManager = new MockDoku_Plugin_Controller(); + $pluginManager->setReturnValue('getList', array('testplugin')); + $pluginManager->setReturnValue('load', new remote_plugin_testplugin()); + $plugin_controller = $pluginManager; + + $this->originalConf = $conf; + + $this->remote = new RemoteAPI(); + } + + function tearDown() { + global $conf; + $conf = $this->originalConf; + } + + function test_pluginMethods() { + $methods = $this->remote->getPluginMethods(); + $this->assertEqual(array_keys($methods), array('plugin.testplugin.method1', 'plugin.testplugin.method2')); + } + + function test_hasAccessSuccess() { + global $conf; + $conf['remote'] = 1; + $this->assertTrue($this->remote->hasAccess()); + } + + function test_hasAccessFail() { + global $conf; + $conf['remote'] = 0; + $this->assertFalse($this->remote->hasAccess()); + } + + function test_forceAccessSuccess() { + global $conf; + $conf['remote'] = 1; + $this->remote->forceAccess(); // no exception should occur + } + + function test_forceAccessFail() { + global $conf; + $conf['remote'] = 0; + $this->expectException('RemoteException'); + $this->remote->forceAccess(); + } +} -- cgit v1.2.3 From 4815d222f25c9a31949297223c98cfca7151ae8d Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Thu, 8 Dec 2011 19:57:18 +0100 Subject: RemoteAPI can now handle remote calls. --- _test/cases/inc/remote.test.php | 102 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) (limited to '_test') diff --git a/_test/cases/inc/remote.test.php b/_test/cases/inc/remote.test.php index aa7a8cd1b..b33d8039f 100644 --- a/_test/cases/inc/remote.test.php +++ b/_test/cases/inc/remote.test.php @@ -1,9 +1,74 @@ array( + 'args' => array(), + 'return' => 'string', + 'doc' => 'Test method', + 'name' => 'stringTestMethod', + ), 'wiki.intTestMethod' => array( + 'args' => array(), + 'return' => 'int', + 'doc' => 'Test method', + 'name' => 'intTestMethod', + ), 'wiki.floatTestMethod' => array( + 'args' => array(), + 'return' => 'float', + 'doc' => 'Test method', + 'name' => 'floatTestMethod', + ), 'wiki.dateTestMethod' => array( + 'args' => array(), + 'return' => 'date', + 'doc' => 'Test method', + 'name' => 'dateTestMethod', + ), 'wiki.fileTestMethod' => array( + 'args' => array(), + 'return' => 'file', + 'doc' => 'Test method', + 'name' => 'fileTestMethod', + ), 'wiki.voidTestMethod' => array( + 'args' => array(), + 'return' => 'void', + 'doc' => 'Test method', + 'name' => 'voidTestMethod', + ), 'wiki.oneStringArgMethod' => array( + 'args' => array('string'), + 'return' => 'string', + 'doc' => 'Test method', + 'name' => 'oneStringArgMethod', + ), 'wiki.twoArgMethod' => array( + 'args' => array('string', 'int'), + 'return' => 'array', + 'doc' => 'Test method', + 'name' => 'twoArgMethod', + ), 'wiki.twoArgWithDefaultArg' => array( + 'args' => array('string', 'string'), + 'return' => 'string', + 'doc' => 'Test method', + 'name' => 'twoArgWithDefaultArg', + ), + ); + } + function stringTestMethod() { return 'success'; } + function intTestMethod() { return 42; } + function floatTestMethod() { return 3.14159265; } + function dateTestMethod() { return 2623452346; } + function fileTestMethod() { return 'file content'; } + function voidTestMethod() { return null; } + function oneStringArgMethod($arg) {return $arg; } + function twoArgMethod($string, $int) { return array($string, $int); } + function twoArgWithDefaultArg($string1, $string2 = 'default') { return array($string1, $string2); } + +} + class remote_plugin_testplugin extends DokuWiki_Remote_Plugin { function _getMethods() { return array( @@ -74,4 +139,41 @@ class remote_test extends UnitTestCase { $this->expectException('RemoteException'); $this->remote->forceAccess(); } + + function test_generalCoreFunctionWithoutArguments() { + global $conf; + $conf['remote'] = 1; + $remoteApi = new RemoteApi(); + $remoteApi->getCoreMethods(new RemoteAPICoreTest()); + + $this->assertEqual($remoteApi->call('wiki.stringTestMethod'), 'success'); + $this->assertEqual($remoteApi->call('wiki.intTestMethod'), 42); + $this->assertEqual($remoteApi->call('wiki.floatTestMethod'), 3.14159265); + $this->assertEqual($remoteApi->call('wiki.dateTestMethod'), 2623452346); + $this->assertEqual($remoteApi->call('wiki.fileTestMethod'), 'file content'); + $this->assertEqual($remoteApi->call('wiki.voidTestMethod'), null); + } + + function test_generalCoreFunctionOnArgumentMismatch() { + global $conf; + $conf['remote'] = 1; + $remoteApi = new RemoteApi(); + $remoteApi->getCoreMethods(new RemoteAPICoreTest()); + + $this->expectException('RemoteException'); + $remoteApi->call('wiki.voidTestMethod', array('something')); + } + + function test_generalCoreFunctionWithArguments() { + global $conf; + $conf['remote'] = 1; + + $remoteApi = new RemoteApi(); + $remoteApi->getCoreMethods(new RemoteAPICoreTest()); + + $this->assertEqual($remoteApi->call('wiki.oneStringArgMethod', array('string')), 'string'); + $this->assertEqual($remoteApi->call('wiki.twoArgMethod', array('string', 1)), array('string' , 1)); + $this->assertEqual($remoteApi->call('wiki.twoArgWithDefaultArg', array('string')), array('string', 'default')); + $this->assertEqual($remoteApi->call('wiki.twoArgWithDefaultArg', array('string', 'another')), array('string', 'another')); + } } -- cgit v1.2.3 From 647919c9a61d928502b0b45063cc60702d0d310e Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Thu, 8 Dec 2011 20:33:30 +0100 Subject: added remote plugin calls. --- _test/cases/inc/remote.test.php | 43 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) (limited to '_test') diff --git a/_test/cases/inc/remote.test.php b/_test/cases/inc/remote.test.php index b33d8039f..f0e7b3d27 100644 --- a/_test/cases/inc/remote.test.php +++ b/_test/cases/inc/remote.test.php @@ -75,13 +75,24 @@ class remote_plugin_testplugin extends DokuWiki_Remote_Plugin { 'method1' => array( 'args' => array(), 'return' => 'void' - ), - 'method2' => array( + ), 'methodString' => array( + 'args' => array(), + 'return' => 'string' + ), 'method2' => array( + 'args' => array('string', 'int'), + 'return' => 'array', + 'name' => 'method2', + ), 'method2ext' => array( 'args' => array('string', 'int', 'bool'), - 'return' => array('string'), + 'return' => 'array', + 'name' => 'method2', ) ); } + + function method1() { return null; } + function methodString() { return 'success'; } + function method2($str, $int, $bool = false) { return array($str, $int, $bool); } } @@ -112,7 +123,11 @@ class remote_test extends UnitTestCase { function test_pluginMethods() { $methods = $this->remote->getPluginMethods(); - $this->assertEqual(array_keys($methods), array('plugin.testplugin.method1', 'plugin.testplugin.method2')); + $actual = array_keys($methods); + sort($actual); + $expect = array('plugin.testplugin.method1', 'plugin.testplugin.method2', 'plugin.testplugin.methodString', 'plugin.testplugin.method2ext'); + sort($expect); + $this->assertEqual($expect,$actual); } function test_hasAccessSuccess() { @@ -176,4 +191,24 @@ class remote_test extends UnitTestCase { $this->assertEqual($remoteApi->call('wiki.twoArgWithDefaultArg', array('string')), array('string', 'default')); $this->assertEqual($remoteApi->call('wiki.twoArgWithDefaultArg', array('string', 'another')), array('string', 'another')); } + + function test_pluginCallMethods() { + global $conf; + $conf['remote'] = 1; + + $remoteApi = new RemoteApi(); + $this->assertEqual($remoteApi->call('plugin.testplugin.method1'), null); + $this->assertEqual($remoteApi->call('plugin.testplugin.method2', array('string', 7)), array('string', 7, false)); + $this->assertEqual($remoteApi->call('plugin.testplugin.method2ext', array('string', 7, true)), array('string', 7, true)); + $this->assertEqual($remoteApi->call('plugin.testplugin.methodString'), 'success'); + } + + function test_notExistingCall() { + global $conf; + $conf['remote'] = 1; + + $remoteApi = new RemoteApi(); + $this->expectException('RemoteException'); + $remoteApi->call('dose not exist'); + } } -- cgit v1.2.3 From 795114e73f18f06c2b32b433e150cad81da6581f Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Sat, 10 Dec 2011 14:05:33 +0100 Subject: changed return types --- _test/cases/inc/remote.test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to '_test') diff --git a/_test/cases/inc/remote.test.php b/_test/cases/inc/remote.test.php index f0e7b3d27..23186344b 100644 --- a/_test/cases/inc/remote.test.php +++ b/_test/cases/inc/remote.test.php @@ -60,8 +60,8 @@ class RemoteAPICoreTest { function stringTestMethod() { return 'success'; } function intTestMethod() { return 42; } function floatTestMethod() { return 3.14159265; } - function dateTestMethod() { return 2623452346; } - function fileTestMethod() { return 'file content'; } + function dateTestMethod() { return new RemoteDate(2623452346); } + function fileTestMethod() { return new RemoteFile('file content'); } function voidTestMethod() { return null; } function oneStringArgMethod($arg) {return $arg; } function twoArgMethod($string, $int) { return array($string, $int); } @@ -164,8 +164,8 @@ class remote_test extends UnitTestCase { $this->assertEqual($remoteApi->call('wiki.stringTestMethod'), 'success'); $this->assertEqual($remoteApi->call('wiki.intTestMethod'), 42); $this->assertEqual($remoteApi->call('wiki.floatTestMethod'), 3.14159265); - $this->assertEqual($remoteApi->call('wiki.dateTestMethod'), 2623452346); - $this->assertEqual($remoteApi->call('wiki.fileTestMethod'), 'file content'); + $this->assertEqual($remoteApi->call('wiki.dateTestMethod'), new RemoteDate(2623452346)); + $this->assertEqual($remoteApi->call('wiki.fileTestMethod'), new RemoteFile('file content')); $this->assertEqual($remoteApi->call('wiki.voidTestMethod'), null); } -- cgit v1.2.3 From a317247b19c498f4292480110cf0e0a1ce9780e8 Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Sun, 8 Jan 2012 14:54:53 +0100 Subject: updated remote hasAccess function --- _test/cases/inc/remote.test.php | 46 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) (limited to '_test') diff --git a/_test/cases/inc/remote.test.php b/_test/cases/inc/remote.test.php index 23186344b..b6a683f45 100644 --- a/_test/cases/inc/remote.test.php +++ b/_test/cases/inc/remote.test.php @@ -99,12 +99,15 @@ class remote_plugin_testplugin extends DokuWiki_Remote_Plugin { class remote_test extends UnitTestCase { var $originalConf; + var $userinfo; var $remote; function setUp() { global $plugin_controller; global $conf; + global $USERINFO; + parent::setUp(); $pluginManager = new MockDoku_Plugin_Controller(); $pluginManager->setReturnValue('getList', array('testplugin')); @@ -112,13 +115,19 @@ class remote_test extends UnitTestCase { $plugin_controller = $pluginManager; $this->originalConf = $conf; + $conf['remote'] = 1; + $conf['useacl'] = 0; + $this->userinfo = $USERINFO; $this->remote = new RemoteAPI(); } function tearDown() { global $conf; + global $USERINFO; $conf = $this->originalConf; + $USERINFO = $this->userinfo; + } function test_pluginMethods() { @@ -131,8 +140,6 @@ class remote_test extends UnitTestCase { } function test_hasAccessSuccess() { - global $conf; - $conf['remote'] = 1; $this->assertTrue($this->remote->hasAccess()); } @@ -142,6 +149,41 @@ class remote_test extends UnitTestCase { $this->assertFalse($this->remote->hasAccess()); } + function test_hasAccessFailAcl() { + global $conf; + $conf['useacl'] = 1; + $this->assertFalse($this->remote->hasAccess()); + } + + function test_hasAccessSuccessAclEmptyRemoteUser() { + global $conf; + $conf['useacl'] = 1; + $conf['remoteuser'] = ''; + + $this->assertTrue($this->remote->hasAccess()); + } + + function test_hasAccessSuccessAcl() { + global $conf; + global $USERINFO; + $conf['useacl'] = 1; + $conf['remoteuser'] = '@grp,@grp2'; + $USERINFO['grps'] = array('grp'); + + $this->assertTrue($this->remote->hasAccess()); + } + + function test_hasAccessFailAcl2() { + global $conf; + global $USERINFO; + $conf['useacl'] = 1; + $conf['remoteuser'] = '@grp'; + $USERINFO['grps'] = array('grp1'); + + $this->assertFalse($this->remote->hasAccess()); + } + + function test_forceAccessSuccess() { global $conf; $conf['remote'] = 1; -- cgit v1.2.3 From 4beb39ea51a46409ab3abd4a1b880bf5d3d5dc4a Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Sun, 8 Jan 2012 15:31:46 +0100 Subject: enforce acl on remote method call --- _test/cases/inc/remote.test.php | 52 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) (limited to '_test') diff --git a/_test/cases/inc/remote.test.php b/_test/cases/inc/remote.test.php index b6a683f45..07ca9d0e8 100644 --- a/_test/cases/inc/remote.test.php +++ b/_test/cases/inc/remote.test.php @@ -54,7 +54,13 @@ class RemoteAPICoreTest { 'return' => 'string', 'doc' => 'Test method', 'name' => 'twoArgWithDefaultArg', - ), + ), 'wiki.publicCall' => array( + 'args' => array(), + 'return' => 'boolean', + 'doc' => 'testing for public access', + 'name' => 'publicCall', + 'public' => 1 + ) ); } function stringTestMethod() { return 'success'; } @@ -66,6 +72,7 @@ class RemoteAPICoreTest { function oneStringArgMethod($arg) {return $arg; } function twoArgMethod($string, $int) { return array($string, $int); } function twoArgWithDefaultArg($string1, $string2 = 'default') { return array($string1, $string2); } + function publicCall() {return true;} } @@ -86,6 +93,12 @@ class remote_plugin_testplugin extends DokuWiki_Remote_Plugin { 'args' => array('string', 'int', 'bool'), 'return' => 'array', 'name' => 'method2', + ), 'publicCall' => array( + 'args' => array(), + 'return' => 'boolean', + 'doc' => 'testing for public access', + 'name' => 'publicCall', + 'public' => 1 ) ); } @@ -93,6 +106,8 @@ class remote_plugin_testplugin extends DokuWiki_Remote_Plugin { function method1() { return null; } function methodString() { return 'success'; } function method2($str, $int, $bool = false) { return array($str, $int, $bool); } + function publicCall() {return true;} + } @@ -134,7 +149,7 @@ class remote_test extends UnitTestCase { $methods = $this->remote->getPluginMethods(); $actual = array_keys($methods); sort($actual); - $expect = array('plugin.testplugin.method1', 'plugin.testplugin.method2', 'plugin.testplugin.methodString', 'plugin.testplugin.method2ext'); + $expect = array('plugin.testplugin.method1', 'plugin.testplugin.method2', 'plugin.testplugin.methodString', 'plugin.testplugin.method2ext', 'plugin.testplugin.publicCall'); sort($expect); $this->assertEqual($expect,$actual); } @@ -253,4 +268,37 @@ class remote_test extends UnitTestCase { $this->expectException('RemoteException'); $remoteApi->call('dose not exist'); } + + function test_publicCallCore() { + global $conf; + $conf['useacl'] = 1; + $remoteApi = new RemoteApi(); + $remoteApi->getCoreMethods(new RemoteAPICoreTest()); + $this->assertTrue($remoteApi->call('wiki.publicCall')); + } + + function test_publicCallPlugin() { + global $conf; + $conf['useacl'] = 1; + $remoteApi = new RemoteApi(); + $this->assertTrue($remoteApi->call('plugin.testplugin.publicCall')); + } + + function test_publicCallCoreDeny() { + global $conf; + $conf['useacl'] = 1; + $remoteApi = new RemoteApi(); + $remoteApi->getCoreMethods(new RemoteAPICoreTest()); + $this->expectException('RemoteAccessDenied'); + $remoteApi->call('wiki.stringTestMethod'); + } + + function test_publicCallPluginDeny() { + global $conf; + $conf['useacl'] = 1; + $remoteApi = new RemoteApi(); + $this->expectException('RemoteAccessDenied'); + $remoteApi->call('plugin.testplugin.methodString'); + } + } -- cgit v1.2.3 From 6e8160489a60f00eb756682b574be72693c7878b Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Sun, 8 Jan 2012 19:29:39 +0100 Subject: adjusted test cases --- _test/cases/inc/remote.test.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to '_test') diff --git a/_test/cases/inc/remote.test.php b/_test/cases/inc/remote.test.php index 07ca9d0e8..c4f0cd2c2 100644 --- a/_test/cases/inc/remote.test.php +++ b/_test/cases/inc/remote.test.php @@ -66,8 +66,8 @@ class RemoteAPICoreTest { function stringTestMethod() { return 'success'; } function intTestMethod() { return 42; } function floatTestMethod() { return 3.14159265; } - function dateTestMethod() { return new RemoteDate(2623452346); } - function fileTestMethod() { return new RemoteFile('file content'); } + function dateTestMethod() { return 2623452346; } + function fileTestMethod() { return 'file content'; } function voidTestMethod() { return null; } function oneStringArgMethod($arg) {return $arg; } function twoArgMethod($string, $int) { return array($string, $int); } @@ -131,6 +131,7 @@ class remote_test extends UnitTestCase { $this->originalConf = $conf; $conf['remote'] = 1; + $conf['remoteuser'] = '!!not set!!'; $conf['useacl'] = 0; $this->userinfo = $USERINFO; @@ -221,8 +222,8 @@ class remote_test extends UnitTestCase { $this->assertEqual($remoteApi->call('wiki.stringTestMethod'), 'success'); $this->assertEqual($remoteApi->call('wiki.intTestMethod'), 42); $this->assertEqual($remoteApi->call('wiki.floatTestMethod'), 3.14159265); - $this->assertEqual($remoteApi->call('wiki.dateTestMethod'), new RemoteDate(2623452346)); - $this->assertEqual($remoteApi->call('wiki.fileTestMethod'), new RemoteFile('file content')); + $this->assertEqual($remoteApi->call('wiki.dateTestMethod'), 2623452346); + $this->assertEqual($remoteApi->call('wiki.fileTestMethod'), 'file content'); $this->assertEqual($remoteApi->call('wiki.voidTestMethod'), null); } -- cgit v1.2.3 From e61127e4af913a252fbe5c8f427501268501895c Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Sun, 8 Jan 2012 19:31:10 +0100 Subject: refactored RemoteAccessDenied to RemoteAccessDeniedException --- _test/cases/inc/remote.test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to '_test') diff --git a/_test/cases/inc/remote.test.php b/_test/cases/inc/remote.test.php index c4f0cd2c2..f5da3c06d 100644 --- a/_test/cases/inc/remote.test.php +++ b/_test/cases/inc/remote.test.php @@ -290,7 +290,7 @@ class remote_test extends UnitTestCase { $conf['useacl'] = 1; $remoteApi = new RemoteApi(); $remoteApi->getCoreMethods(new RemoteAPICoreTest()); - $this->expectException('RemoteAccessDenied'); + $this->expectException('RemoteAccessDeniedException'); $remoteApi->call('wiki.stringTestMethod'); } @@ -298,7 +298,7 @@ class remote_test extends UnitTestCase { global $conf; $conf['useacl'] = 1; $remoteApi = new RemoteApi(); - $this->expectException('RemoteAccessDenied'); + $this->expectException('RemoteAccessDeniedException'); $remoteApi->call('plugin.testplugin.methodString'); } -- cgit v1.2.3 From 995dc0ce9ce4e23e9f15e7088aa1219ab72835cb Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Sun, 22 Jan 2012 11:58:01 +0100 Subject: fixed testcase --- _test/cases/inc/remote.test.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to '_test') diff --git a/_test/cases/inc/remote.test.php b/_test/cases/inc/remote.test.php index f5da3c06d..186f8e65a 100644 --- a/_test/cases/inc/remote.test.php +++ b/_test/cases/inc/remote.test.php @@ -2,9 +2,14 @@ require_once DOKU_INC . 'inc/init.php'; require_once DOKU_INC . 'inc/RemoteAPICore.php'; +require_once DOKU_INC . 'inc/auth/basic.class.php'; Mock::generate('Doku_Plugin_Controller'); +class MockAuth extends auth_basic { + function isCaseSensitive() { return true; } +} + class RemoteAPICoreTest { function __getRemoteInfo() { @@ -122,6 +127,7 @@ class remote_test extends UnitTestCase { global $plugin_controller; global $conf; global $USERINFO; + global $auth; parent::setUp(); $pluginManager = new MockDoku_Plugin_Controller(); @@ -136,6 +142,8 @@ class remote_test extends UnitTestCase { $this->userinfo = $USERINFO; $this->remote = new RemoteAPI(); + + $auth = new MockAuth(); } function tearDown() { @@ -185,7 +193,6 @@ class remote_test extends UnitTestCase { $conf['useacl'] = 1; $conf['remoteuser'] = '@grp,@grp2'; $USERINFO['grps'] = array('grp'); - $this->assertTrue($this->remote->hasAccess()); } -- cgit v1.2.3 From 0b9869484e3052d68e5939bf626fbd3a840d3062 Mon Sep 17 00:00:00 2001 From: lupo49 Date: Sat, 10 Mar 2012 20:16:28 +0100 Subject: Unit Test: Adding test to check windows share link with hyphen character --- _test/cases/inc/parser/parser_links.test.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to '_test') diff --git a/_test/cases/inc/parser/parser_links.test.php b/_test/cases/inc/parser/parser_links.test.php index 53871e110..d0fb19570 100644 --- a/_test/cases/inc/parser/parser_links.test.php +++ b/_test/cases/inc/parser/parser_links.test.php @@ -400,6 +400,21 @@ class TestOfDoku_Parser_Links extends TestOfDoku_Parser { ); $this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls); } + + function testWindowsShareLinkHyphen() { + $this->P->addMode('windowssharelink',new Doku_Parser_Mode_WindowsShareLink()); + $this->P->parse('Foo \\\server\share-hyphen Bar'); + $calls = array ( + array('document_start',array()), + array('p_open',array()), + array('cdata',array("\n".'Foo ')), + array('windowssharelink',array('\\\server\share-hyphen',NULL)), + array('cdata',array(' Bar')), + array('p_close',array()), + array('document_end',array()), + ); + $this->assertEqual(array_map('stripByteIndex',$this->H->calls),$calls); + } function testWindowsShareLinkInternal() { $this->P->addMode('internallink',new Doku_Parser_Mode_InternalLink()); -- cgit v1.2.3 From 9e760ee516dd6e50390490f6d5585b854b895808 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 13 Mar 2012 17:32:53 +0100 Subject: added (failing) test for cleanText() The cleanText function is supposed to convert DOS to Unix lineendings but it seems that it doesn't always do that correctly as this thread suggests: http://forum.dokuwiki.org/thread/8141 I added a unit test that currently fails but haven't found the real cause yet. Further testing (and a fix) is needed. --- _test/cases/inc/common_cleanText.test.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 _test/cases/inc/common_cleanText.test.php (limited to '_test') diff --git a/_test/cases/inc/common_cleanText.test.php b/_test/cases/inc/common_cleanText.test.php new file mode 100644 index 000000000..571e41fa5 --- /dev/null +++ b/_test/cases/inc/common_cleanText.test.php @@ -0,0 +1,31 @@ +assertEqual($unix,cleanText($unix)); + } + + function test_win(){ + $unix = 'one + two + + three'; + $win = 'one + two + + three'; + $this->assertNotEqual($unix,$win); + $this->assertEqual($unix,cleanText($win)); + } +} + +//Setup VIM: ex: et ts=4 : -- cgit v1.2.3 From 6212730ca98f1a8c054d742fa68f988e77be4caf Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 13 Mar 2012 19:08:15 +0100 Subject: the previous test case had an error There were whitespaces on the empty DOS line. This fixes the test but does not explain the broken behaviour in the wiki itself. --- _test/cases/inc/common_cleanText.test.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to '_test') diff --git a/_test/cases/inc/common_cleanText.test.php b/_test/cases/inc/common_cleanText.test.php index 571e41fa5..936ed1d76 100644 --- a/_test/cases/inc/common_cleanText.test.php +++ b/_test/cases/inc/common_cleanText.test.php @@ -19,10 +19,13 @@ class common_clientIP_test extends UnitTestCase { two three'; - $win = 'one + $win = 'one two - + three'; + + $this->assertEqual(bin2hex($unix),'6f6e650a2020202020202020202020202020202074776f0a0a202020202020202020202020202020207468726565'); + $this->assertEqual(bin2hex($win),'6f6e650d0a2020202020202020202020202020202074776f0d0a0d0a202020202020202020202020202020207468726565'); $this->assertNotEqual($unix,$win); $this->assertEqual($unix,cleanText($win)); } -- cgit v1.2.3 From d4dca43453a7a9e798c208cbb89ee09616381dde Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 16 Mar 2012 11:11:15 +0100 Subject: fixed error in bcrypt password method --- _test/cases/inc/auth_password.test.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to '_test') diff --git a/_test/cases/inc/auth_password.test.php b/_test/cases/inc/auth_password.test.php index 394f0b2f5..d4a4d2bdb 100644 --- a/_test/cases/inc/auth_password.test.php +++ b/_test/cases/inc/auth_password.test.php @@ -54,6 +54,10 @@ class auth_password_test extends UnitTestCase { $this->assertTrue(auth_verifyPassword('foobcrypt',$hash)); } + function test_verifyPassword_fixedbcrypt(){ + $this->assertTrue(auth_verifyPassword('foobcrypt','$2a$12$uTWercxbq4sjp2xAzv3we.ZOxk51m5V/Bv5bp2H27oVFJl5neFQoC')); + } + function test_verifyPassword_nohash(){ $this->assertTrue(auth_verifyPassword('foo','$1$$n1rTiFE0nRifwV/43bVon/')); } -- cgit v1.2.3 From 7c35ac36c1dea2d6f26d8184dcbf1fe5afae59ac Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Wed, 21 Mar 2012 13:15:18 +0100 Subject: added RPC_CALL_ADD event. This event enables plugins to register custom method names. --- _test/cases/inc/remote.test.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to '_test') diff --git a/_test/cases/inc/remote.test.php b/_test/cases/inc/remote.test.php index 186f8e65a..f03d13ce1 100644 --- a/_test/cases/inc/remote.test.php +++ b/_test/cases/inc/remote.test.php @@ -309,4 +309,16 @@ class remote_test extends UnitTestCase { $remoteApi->call('plugin.testplugin.methodString'); } + function test_pluginCallCustomPath() { + global $EVENT_HANDLER; + $EVENT_HANDLER->register_hook('RPC_CALL_ADD', 'BEFORE', &$this, 'pluginCallCustomPathRegister'); + + $remoteApi = new RemoteAPI(); + $result = $remoteApi->call('custom.path'); + $this->assertEqual($result, 'success'); + } + + function pluginCallCustomPathRegister(&$event, $param) { + $event->data['custom.path'] = array('testplugin', 'methodString'); + } } -- cgit v1.2.3