From ccb6d8a5135ec97776f926a5f483d9f1f88d061b Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Fri, 13 May 2011 18:10:25 +0200 Subject: fix ssl client cert login process --- src/SemanticScuttle/Service/User.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/SemanticScuttle') diff --git a/src/SemanticScuttle/Service/User.php b/src/SemanticScuttle/Service/User.php index 09a2cb1..0e437c2 100644 --- a/src/SemanticScuttle/Service/User.php +++ b/src/SemanticScuttle/Service/User.php @@ -426,8 +426,8 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService if ($ssls->hasValidCert()) { $id = $ssls->getUserIdFromCert(); if ($id !== false) { - $this->setCurrentUserId($id); - return (int)$_SESSION[$this->getSessionKey()]; + $this->setCurrentUserId($id, true); + return $this->currentuserId; } } return false; -- cgit v1.2.3 From 62afb014825e85c40df225358d608bef430a8949 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Fri, 13 May 2011 18:11:14 +0200 Subject: allow ssl client login with other authentication sources --- src/SemanticScuttle/Service/AuthUser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/SemanticScuttle') diff --git a/src/SemanticScuttle/Service/AuthUser.php b/src/SemanticScuttle/Service/AuthUser.php index 479b68a..9447ee4 100644 --- a/src/SemanticScuttle/Service/AuthUser.php +++ b/src/SemanticScuttle/Service/AuthUser.php @@ -130,7 +130,7 @@ class SemanticScuttle_Service_AuthUser extends SemanticScuttle_Service_User //FIXME: caching? $name = $this->auth->getUsername(); if (!$name) { - return false; + return parent::getCurrentUserId(); } return $this->getIdFromUser($name); } -- cgit v1.2.3 From ef23f01ebab448f10cb3935af4a2723f0e362c38 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Thu, 19 May 2011 07:38:35 +0200 Subject: begin supporting a different database for unit tests --- src/SemanticScuttle/header-standalone.php | 2 +- src/SemanticScuttle/header.php | 17 ++++++++++++----- tests/TestBaseApi.php | 7 ++++--- tests/prepare.php | 4 ++-- 4 files changed, 19 insertions(+), 11 deletions(-) (limited to 'src/SemanticScuttle') diff --git a/src/SemanticScuttle/header-standalone.php b/src/SemanticScuttle/header-standalone.php index cc1b0bd..50732a6 100644 --- a/src/SemanticScuttle/header-standalone.php +++ b/src/SemanticScuttle/header-standalone.php @@ -14,7 +14,7 @@ * @link http://sourceforge.net/projects/semanticscuttle */ $_SERVER['HTTP_HOST'] = 'http://localhost/'; -define('UNIT_TEST_MODE', true); +//define('UNIT_TEST_MODE', true); require_once dirname(__FILE__) . '/header.php'; ?> \ No newline at end of file diff --git a/src/SemanticScuttle/header.php b/src/SemanticScuttle/header.php index b0705b0..098e5c3 100644 --- a/src/SemanticScuttle/header.php +++ b/src/SemanticScuttle/header.php @@ -46,14 +46,21 @@ if (isset($_GET['unittestMode']) && $_GET['unittestMode'] == 1 die("Unittestmode is not allowed\n"); } - $unittestConfigFile = $datadir . '/config.unittest.php'; - if (file_exists($unittestConfigFile)) { - require_once $unittestConfigFile; - } define('HTTP_UNIT_TEST_MODE', true); define('UNIT_TEST_MODE', true); } if (defined('UNIT_TEST_MODE')) { + //load configuration for unit tests + $testingConfigFile = $datadir . '/config.testing.php'; + if (file_exists($testingConfigFile)) { + require_once $testingConfigFile; + } + //test-specific configuration file + $unittestConfigFile = $datadir . '/config.testing-tmp.php'; + if (file_exists($unittestConfigFile)) { + require_once $unittestConfigFile; + } + //make local config vars global - needed for unit tests //run with phpunit foreach (get_defined_vars() as $var => $value) { @@ -107,7 +114,7 @@ T_bind_textdomain_codeset($domain, 'UTF-8'); T_textdomain($domain); // 4 // Session -if (!defined('UNIT_TEST_MODE') || defined('HTTP_UNIT_TEST_MODE')) { +if (isset($_SERVER['REMOTE_ADDR'])) { session_start(); if ($GLOBALS['enableVoting']) { if (isset($_SESSION['lastUrl'])) { diff --git a/tests/TestBaseApi.php b/tests/TestBaseApi.php index 2caa701..31797c9 100644 --- a/tests/TestBaseApi.php +++ b/tests/TestBaseApi.php @@ -50,8 +50,9 @@ class TestBaseApi extends TestBase $this->url = $GLOBALS['unittestUrl'] . $this->urlPart; //clean up before test - if (file_exists($GLOBALS['datadir'] . '/config.unittest.php')) { - unlink($GLOBALS['datadir'] . '/config.unittest.php'); + $configFile = $GLOBALS['datadir'] . '/config.testing-tmp.php'; + if (file_exists($configFile)) { + unlink($configFile); } $this->us = SemanticScuttle_Service_Factory::get('User'); @@ -230,7 +231,7 @@ class TestBaseApi extends TestBase $this->assertInternalType( 'integer', - file_put_contents($GLOBALS['datadir'] . '/config.unittest.php', $str), + file_put_contents($GLOBALS['datadir'] . '/config.testing-tmp.php', $str), 'Writing config.unittest.php failed' ); } diff --git a/tests/prepare.php b/tests/prepare.php index c80306e..ea4d77d 100644 --- a/tests/prepare.php +++ b/tests/prepare.php @@ -22,7 +22,7 @@ $_SERVER['HTTP_HOST'] = 'http://localhost/'; define('UNIT_TEST_MODE', true); if ('@data_dir@' == '@' . 'data_dir@') { - //non pear-install + //non pear-installation (i.e. git checkout) require_once dirname(__FILE__) . '/../src/SemanticScuttle/header.php'; } else { //pear installation; files are in include path @@ -35,7 +35,7 @@ if ($GLOBALS['debugMode'] == true && $GLOBALS['dbtype'] == 'mysql4' ) { echo "\n" - . '!!! The combination of debugMode and dbtype==mysql4' + . '!! The combination of debugMode and dbtype==mysql4' . ' will wreck some tests' . "\n\n"; } ?> \ No newline at end of file -- cgit v1.2.3 From 97bba97049eeed2ecec022caa641b50ca507cb72 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Fri, 20 May 2011 17:11:45 +0200 Subject: no need for that anymore --- src/SemanticScuttle/header-standalone.php | 1 - 1 file changed, 1 deletion(-) (limited to 'src/SemanticScuttle') diff --git a/src/SemanticScuttle/header-standalone.php b/src/SemanticScuttle/header-standalone.php index 50732a6..3755ea1 100644 --- a/src/SemanticScuttle/header-standalone.php +++ b/src/SemanticScuttle/header-standalone.php @@ -14,7 +14,6 @@ * @link http://sourceforge.net/projects/semanticscuttle */ $_SERVER['HTTP_HOST'] = 'http://localhost/'; -//define('UNIT_TEST_MODE', true); require_once dirname(__FILE__) . '/header.php'; ?> \ No newline at end of file -- cgit v1.2.3