* Copyright 2001-2012 Strangecode, LLC * * This file is part of The Strangecode Codebase. * * The Strangecode Codebase is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or (at your option) * any later version. * * The Strangecode Codebase is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * The Strangecode Codebase. If not, see . */ /** * PHPUnit test case for codebase/lib/AuthFile.inc.php * * The method skeletons below need to be filled in with * real data so that the tests will run correctly. Replace * all EXPECTED_VAL and PARAM strings with real data. * * Created with PHPUnit_Skeleton on 2005-08-09 */ // class AuthFileTest extends PHPUnit_Framework_TestCase { var $AuthFile; static $shared_session; function setUp() { require dirname(__FILE__) . '/_config.inc.php'; require_once '../lib/Auth_File.inc.php'; $this->AuthFile = new Auth_File('test_auth'); $this->AuthFile->setParam(array('htpasswd_file' => dirname(__FILE__) . '/_test_htpasswd')); $_SESSION = AuthFileTest::$shared_session; } function tearDown() { unset($this->AuthFile); AuthFileTest::$shared_session = $_SESSION; } function test_authenticate() { $true = $this->AuthFile->authenticate('testuser', 'testpass'); $this->assertTrue($true, 'testuser not authorized with good password.'); $false = $this->AuthFile->authenticate('testuser', 'wrongpass'); $this->assertFalse($false, 'testuser not blocked with bad password.'); } function test_login() { $result = $this->AuthFile->login('testuser', 'testpass'); $this->assertTrue($result, 'testuser login failed.'); $this->assertTrue($_SESSION['_auth_file']['test_auth']['authenticated'], 'testuser authentication not found in session.'); } function test_clear() { $result = $this->AuthFile->login('testuser', 'testpass'); $this->AuthFile->clear(); $this->assertFalse($_SESSION['_auth_file']['test_auth']['authenticated'], 'testuser authentication not false in session.'); } function test_isloggedin() { $this->AuthFile->login('testuser', 'testpass'); $true = $this->AuthFile->isloggedin(); $this->assertTrue($true, 'testuser not logged in but should be.'); $this->AuthFile->clear(); $false = $this->AuthFile->isloggedin(); $this->assertFalse($false, 'testuser is logged in but shouldn\'t be.'); } // function test_isadmin() // { // $this->AuthFile->login('testuser', 'testpass'); // $true = $this->AuthFile->isadmin(); // $this->assertTrue($true); // } // // function test_requireadminlogin() // { // $result = $this->AuthFile->requireadminlogin(PARAM); // $expected = EXPECTED_VAL; // $this->assertEquals($expected, $result); // } // // function test__encrypt() // { // $result = $this->AuthFile->_encrypt(PARAM); // $expected = EXPECTED_VAL; // $this->assertEquals($expected, $result); // } // // function test__salt() // { // $result = $this->AuthFile->_salt(PARAM); // $expected = EXPECTED_VAL; // $this->assertEquals($expected, $result); // } }