Permalink
Browse files

Make test run even without runkit

Signed-off-by: Michal Čihař <michal@cihar.com>
  • Loading branch information...
nijel committed Feb 3, 2016
1 parent 9d10b94 commit 431450a23752752cda8b88ccc39829ab09888a13
View
@@ -488,6 +488,10 @@ function PMA_getenv($var_name)
*/
function PMA_sendHeaderLocation($uri, $use_refresh = false)
{
if (defined('TESTSUITE') && ! defined('PMA_TEST_HEADERS')) {
return;
}
if (PMA_IS_IIS && mb_strlen($uri) > 600) {
include_once './libraries/js_escape.lib.php';
PMA\libraries\Response::getInstance()->disable();
@@ -72,11 +72,13 @@ public function authForm()
$realm_message = $GLOBALS['cfg']['Server']['auth_http_realm'];
}
// remove non US-ASCII to respect RFC2616
$realm_message = preg_replace('/[^\x20-\x7e]/i', '', $realm_message);
header('WWW-Authenticate: Basic realm="' . $realm_message . '"');
header('HTTP/1.0 401 Unauthorized');
if (php_sapi_name() !== 'cgi-fcgi') {
header('status: 401 Unauthorized');
if (! defined('TESTSUITE') || defined('PMA_TEST_HEADERS')) {
$realm_message = preg_replace('/[^\x20-\x7e]/i', '', $realm_message);
header('WWW-Authenticate: Basic realm="' . $realm_message . '"');
header('HTTP/1.0 401 Unauthorized');
if (php_sapi_name() !== 'cgi-fcgi') {
header('status: 401 Unauthorized');
}
}
/* HTML header */
@@ -58,23 +58,19 @@ public function tearDown()
*/
public function testAuth()
{
if (! defined('PMA_TEST_HEADERS')) {
$this->markTestSkipped(
'Cannot redefine constant/function - missing runkit extension'
);
}
$_REQUEST['old_usr'] = '1';
$GLOBALS['cfg']['Server']['LogoutURL'] = 'http://phpmyadmin.net/logout';
$this->assertFalse(
$this->object->auth()
);
$this->assertContains(
'Location: http://phpmyadmin.net/logout',
$GLOBALS['header'][0]
);
if (defined('PMA_TEST_HEADERS')) {
$this->assertContains(
'Location: http://phpmyadmin.net/logout',
$GLOBALS['header'][0]
);
}
// case 2
@@ -143,14 +139,16 @@ public function testAuth()
$this->object->auth()
);
$this->assertEquals(
array(
'WWW-Authenticate: Basic realm="phpMyAdmin verboseMessag"',
'HTTP/1.0 401 Unauthorized',
'status: 401 Unauthorized'
),
$GLOBALS['header']
);
if (defined('PMA_TEST_HEADERS')) {
$this->assertEquals(
array(
'WWW-Authenticate: Basic realm="phpMyAdmin verboseMessag"',
'HTTP/1.0 401 Unauthorized',
'status: 401 Unauthorized'
),
$GLOBALS['header']
);
}
$attrInstance->setValue($restoreInstance);
@@ -163,14 +161,16 @@ public function testAuth()
$this->object->auth()
);
$this->assertEquals(
array(
'WWW-Authenticate: Basic realm="phpMyAdmin hst"',
'HTTP/1.0 401 Unauthorized',
'status: 401 Unauthorized'
),
$GLOBALS['header']
);
if (defined('PMA_TEST_HEADERS')) {
$this->assertEquals(
array(
'WWW-Authenticate: Basic realm="phpMyAdmin hst"',
'HTTP/1.0 401 Unauthorized',
'status: 401 Unauthorized'
),
$GLOBALS['header']
);
}
// case 4
@@ -181,14 +181,16 @@ public function testAuth()
$this->object->auth()
);
$this->assertEquals(
array(
'WWW-Authenticate: Basic realm="realmmessage"',
'HTTP/1.0 401 Unauthorized',
'status: 401 Unauthorized'
),
$GLOBALS['header']
);
if (defined('PMA_TEST_HEADERS')) {
$this->assertEquals(
array(
'WWW-Authenticate: Basic realm="realmmessage"',
'HTTP/1.0 401 Unauthorized',
'status: 401 Unauthorized'
),
$GLOBALS['header']
);
}
}
/**

0 comments on commit 431450a

Please sign in to comment.