Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this fixes #2132 for basic auth specifically, but is not yet optimized. This logic could stand to be central and shared #2159

Merged
merged 2 commits into from
Jul 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions www/runtest.php
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,27 @@ function buildSelfHost($hosts)
$recipeScript .= ";";
}
}

// Handle HTTP Basic Auth
// TODO centralize this logic as it's borrowed from above temporarily
if ((isset($test['login']) && strlen($test['login'])) || (isset($test['password']) && strlen($test['password']))) {
$header = "Authorization: Basic " . base64_encode("{$test['login']}:{$test['password']}");
if (!isset($script) || !strlen($script))
$script = "navigate\t$url";
$script = "addHeader\t$header\r\n" . $script;
}
// Add custom headers
if (isset($test['customHeaders']) && strlen($test['customHeaders'])) {
if (!isset($script) || !strlen($script))
$script = "navigate\t$url";
$headers = preg_split("/\r\n|\n|\r/", $test['customHeaders']);
$headerCommands = "";
foreach ($headers as $header) {
$headerCommands = $headerCommands . "addHeader\t" . $header . "\r\n";
}
$script = $headerCommands . $script;
}
// END TODO centralize this logic as it's borrowed from above temporarily



Expand Down