protected function _RequireAuthentication() { $user = new User(); $user->email = '*****@*****.**'; $user->Insert(); Bugdar::$auth = new AuthenticationTest($user); }
public function testBadPassword() { Bugdar::$auth = new AuthenticationTest(NULL); $data = new phalanx\base\PropertyBag(array('do' => 'fire', 'email' => self::EMAIL, 'password' => 'foo')); $event = new UserLoginEvent($data); $self =& $this; EventPump::Pump()->PostEvent($event); $this->assertFalse($event->was_successful()); }
public function testInvalidEmail() { Bugdar::$auth = new AuthenticationTest(NULL); $data = new phalanx\base\PropertyBag(array('do' => 'submit', 'email' => 'robert', 'alias' => 'Robert', 'password' => 'abc123')); $event = new UserRegisterEvent($data); EventPump::Pump()->PostEvent($event); $last_event = EventPump::Pump()->GetEventChain()->Top(); $this->assertType('StandardErrorEvent', $last_event); }
public static function BootstrapAuthentication($config) { // Load the authentication system. $auth_module = BUGDAR_ROOT . '/includes/auth/auth_' . $config->{'auth.module'} . '.php'; if (!file_exists($auth_module) || !is_readable($auth_module)) { throw new CoreException('Could not load authentication module ' . $config->{'auth.module'}); } require $auth_module; $name = phalanx\base\UnderscoreToCamelCase($config->{'auth.module'}); $class_name = 'Authentication' . $name; if (!class_exists($class_name)) { throw new CoreException('Could not find class ' . $class_name); } self::$auth = new $class_name($config->auth); }
public function Fire() { $valid_settings = array('webroot', 'tracker_name'); // Load the current settings. $this->settings = Bugdar::$settings; if ($this->input->_method == 'POST') { // Create the prepared statement that we reuse for each setting. $query = Bugdar::$db->Prepare("\n INSERT INTO " . TABLE_PREFIX . "settings\n (setting, value)\n VALUES\n (:setting, :value)\n ON DUPLICATE KEY UPDATE value = :value\n "); // Update all the settings atomically. Bugdar::$db->BeginTransaction(); foreach ($valid_settings as $setting) { if (!isset($this->input->settings[$setting])) { continue; } $value = $this->input->settings[$setting]; $query->Execute(array('setting' => $setting, 'value' => $value)); $this->settings[$setting] = $value; } Bugdar::$settings = $this->settings; Bugdar::$db->Commit(); } }
// // You should have received a copy of the GNU General Public License along with // this program. If not, see <http://www.gnu.org/licenses/>. error_reporting(E_ALL & ~E_NOTICE); // Define path constants. define('BUGDAR_ROOT', dirname(dirname(__FILE__))); define('PHALANX_ROOT', BUGDAR_ROOT . '/phalanx'); define('TEST_ROOT', dirname(__FILE__)); // Load some standard Bugdar files. require_once BUGDAR_ROOT . '/includes/core.php'; require_once BUGDAR_ROOT . '/includes/auth/auth.php'; require_once BUGDAR_ROOT . '/includes/localizer.php'; require_once BUGDAR_ROOT . '/includes/view_helpers.php'; // Load some more phalanx files. require_once PHALANX_ROOT . '/events/unit_test_output_handler.php'; // Test Bugdar files. require_once BUGDAR_ROOT . '/testing/test_case.php'; require_once BUGDAR_ROOT . '/testing/standard_events.php'; // Read the configuration file. $config_path = BUGDAR_ROOT . '/testing/config.php'; if (!file_exists($config_path) || !is_readable($config_path)) { throw new CoreException('Could not read TESTING configuration file'); } $config = new phalanx\base\KeyDescender(require $config_path); // Setup common functionality. Bugdar::BootstrapDatabase($config); // Clean out the test database. $stmt = Bugdar::$db->Query("SHOW TABLES"); while ($table = $stmt->Fetch(PDO::FETCH_NUM)) { Bugdar::$db->Query("TRUNCATE TABLE " . TABLE_PREFIX . $table[0]); }
public function setUp() { parent::setUp(); Bugdar::$settings = array(); $this->_RequireAuthentication(); }
$dispatcher->AddBypassRule('view', 'view_bug'); $dispatcher->AddBypassRule('login', 'login_user'); $dispatcher->AddBypassRule('logout', 'logout_user'); // Transform the event name into a template name. phalanx\views\View::set_template_path(dirname(__FILE__) . '/templates/%s.tpl'); phalanx\views\View::set_cache_path(dirname(__FILE__) . '/cache'); $view_handler->set_template_loader(function ($event_class) { $name = preg_replace('/Event$/', '', $event_class); return phalanx\base\CamelCaseToUnderscore($name); }); // Read the configuration file. $config_path = BUGDAR_ROOT . '/includes/config.php'; if (!file_exists($config_path) || !is_readable($config_path)) { throw new CoreException('Could not read configuration file'); } $config = new phalanx\base\KeyDescender(require $config_path); // Setup common functionality. Bugdar::BootstrapDatabase($config); Bugdar::BootstrapAuthentication($config); Bugdar::LoadSettings(); // Finally, begin processing events. $dispatcher->Start(); try { $pump->StopPump(); } catch (phalanx\views\ViewException $e) { // We got a view exception, meaning a template couldn't be loaded. If we // have any output on the buffer, let it slide. Otherwise, re-throw. if (strlen(ob_get_contents()) <= 0) { throw $e; } }