aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib/plugins/authpdo/_test/sqlite.test.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2016-01-29 21:25:50 +0100
committerAndreas Gohr <andi@splitbrain.org>2016-01-29 21:25:50 +0100
commitf64dbc90055403db700941e4691ea451bb971cef (patch)
tree0d2e3a89290c2c658cf3cf1cc69767d0011a6027 /lib/plugins/authpdo/_test/sqlite.test.php
parentef89d2cdf605240572d5c20ce836571c2ba87742 (diff)
downloaddokuwiki-f64dbc90055403db700941e4691ea451bb971cef.tar.gz
dokuwiki-f64dbc90055403db700941e4691ea451bb971cef.zip
began work on PDO auth plugin
Diffstat (limited to 'lib/plugins/authpdo/_test/sqlite.test.php')
-rw-r--r--lib/plugins/authpdo/_test/sqlite.test.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/plugins/authpdo/_test/sqlite.test.php b/lib/plugins/authpdo/_test/sqlite.test.php
new file mode 100644
index 000000000..b60072d94
--- /dev/null
+++ b/lib/plugins/authpdo/_test/sqlite.test.php
@@ -0,0 +1,49 @@
+<?php
+
+/**
+ * General tests for the authpdo plugin
+ *
+ * @group plugin_authpdo
+ * @group plugins
+ */
+class sqlite_plugin_authpdo_test extends DokuWikiTest {
+
+ protected $dbfile;
+
+ public function setUp() {
+ parent::setUp();
+ $this->dbfile = tempnam('/tmp/', 'pluginpdo_test_');
+ copy(__DIR__ . '/test.sqlite3', $this->dbfile);
+
+ global $conf;
+
+ $conf['plugin']['authpdo']['debug'] = 1;
+ $conf['plugin']['authpdo']['dsn'] = 'sqlite:' . $this->dbfile;
+ $conf['plugin']['authpdo']['user'] = '';
+ $conf['plugin']['authpdo']['pass'] = '';
+
+
+ $conf['plugin']['authpdo']['select-user'] = 'SELECT id as uid, login as user, name, pass as clear, mail FROM user WHERE login = :user';
+ }
+
+ public function tearDown() {
+ parent::tearDown();
+ unlink($this->dbfile);
+ }
+
+ public function test_userinfo() {
+ global $conf;
+ $auth = new auth_plugin_authpdo();
+
+ // clear text pasword (with default config above
+ $this->assertFalse($auth->checkPass('nobody', 'nope'));
+ $this->assertFalse($auth->checkPass('admin', 'nope'));
+ $this->assertTrue($auth->checkPass('admin', 'password'));
+
+ // now with a hashed password
+ $conf['plugin']['authpdo']['select-user'] = 'SELECT id as uid, login as user, name, pass as hash, mail FROM user WHERE login = :user';
+ $this->assertFalse($auth->checkPass('admin', 'password'));
+ $this->assertFalse($auth->checkPass('user', md5('password')));
+
+ }
+}