1<?php 2 3/** 4 * General tests for the authpdo plugin 5 * 6 * @group plugin_authpdo 7 * @group plugins 8 */ 9class sqlite_plugin_authpdo_test extends DokuWikiTest { 10 11 protected $dbfile; 12 13 public function setUp() { 14 parent::setUp(); 15 $this->dbfile = tempnam('/tmp/', 'pluginpdo_test_'); 16 copy(__DIR__ . '/test.sqlite3', $this->dbfile); 17 18 global $conf; 19 20 $conf['plugin']['authpdo']['debug'] = 1; 21 $conf['plugin']['authpdo']['dsn'] = 'sqlite:' . $this->dbfile; 22 $conf['plugin']['authpdo']['user'] = ''; 23 $conf['plugin']['authpdo']['pass'] = ''; 24 25 26 $conf['plugin']['authpdo']['select-user'] = 'SELECT id as uid, login as user, name, pass as clear, mail FROM user WHERE login = :user'; 27 } 28 29 public function tearDown() { 30 parent::tearDown(); 31 unlink($this->dbfile); 32 } 33 34 public function test_userinfo() { 35 global $conf; 36 $auth = new auth_plugin_authpdo(); 37 38 // clear text pasword (with default config above 39 $this->assertFalse($auth->checkPass('nobody', 'nope')); 40 $this->assertFalse($auth->checkPass('admin', 'nope')); 41 $this->assertTrue($auth->checkPass('admin', 'password')); 42 43 // now with a hashed password 44 $conf['plugin']['authpdo']['select-user'] = 'SELECT id as uid, login as user, name, pass as hash, mail FROM user WHERE login = :user'; 45 $this->assertFalse($auth->checkPass('admin', 'password')); 46 $this->assertFalse($auth->checkPass('user', md5('password'))); 47 48 } 49} 50