\n";
echo "if (!window.testRunner) {\n";
echo " document.write('This test only works as an automated one');\n";
echo " throw 0;\n";
echo "}\n";
echo "testRunner.waitUntilDone();\n";
echo "testRunner.dumpAsText();\n";
echo "testRunner.setHandlesAuthenticationChallenges(true)\n";
echo "testRunner.setAuthenticationUsername('username')\n";
echo "testRunner.setAuthenticationPassword('password')\n";
echo "location = 'http://127.0.0.1:8000/security/401-logout/401-logout.php?uid=username';\n";
echo "\n";
} else if (!isset($_SERVER['PHP_AUTH_USER']) || ($_REQUEST['uid'] != $_SERVER['PHP_AUTH_USER'])) {
if (isset($_REQUEST['laststep'])) {
// Step 4 - Credentials are no longer being sent
echo "PASS";
echo "\n";
} else {
// Ask for credentials if there are none
header('WWW-Authenticate: Basic realm="401-logout"');
header('HTTP/1.0 401 Unauthorized');
}
} else {
if (!isset($_REQUEST['logout'])) {
// Step 2 - navigate to a page that will make us forget the credentials
echo "\n";
} else {
// Step 3 - logout
header('WWW-Authenticate: Basic realm="401-logout"');
header('HTTP/1.0 401 Unauthorized');
echo "\n";
}
}
?>