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

CORS: change userinfo tests due to URL parser changes #5121

Merged
merged 1 commit into from
Mar 27, 2017
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
31 changes: 10 additions & 21 deletions cors/redirect-userinfo.htm
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@ <h1>CORS userinfo redirect handling</h1>
// Test count for cache busting and easy identifying of request in traffic analyzer
var num_test = 0

shouldFail("Disallow redirect with userinfo (//user:pass@)", [
shouldFail("Disallow redirect with userinfo (user:pass@)", [
CROSSDOMAIN + "resources/cors-makeheader.py?",
CROSSDOMAIN.replace("http://", "http://test:test@") + "resources/cors-makeheader.py?"]);

shouldFail("Disallow redirect with userinfo (//user:@)", [
shouldFail("Disallow redirect with userinfo (user:@)", [
CROSSDOMAIN + "resources/cors-makeheader.py?",
CROSSDOMAIN.replace("http://", "http://user:@") + "resources/cors-makeheader.py?"]);

shouldFail("Disallow redirect with userinfo (//user@)", [
shouldFail("Disallow redirect with userinfo (user@)", [
CROSSDOMAIN + "resources/cors-makeheader.py?",
CROSSDOMAIN.replace("http://", "http://user:@") + "resources/cors-makeheader.py?"]);

shouldFail("Disallow redirect with userinfo (//:@)", [
shouldPass("Allow redirect without userinfo (:@ is trimmed during URL parsing)", [
CROSSDOMAIN + "resources/cors-makeheader.py?",
CROSSDOMAIN.replace("http://", "http://:@") + "resources/cors-makeheader.py?"]);

shouldFail("Disallow redirect with userinfo (//:pass@)", [
shouldFail("Disallow redirect with userinfo (:pass@)", [
CROSSDOMAIN + "resources/cors-makeheader.py?",
CROSSDOMAIN.replace("http://", "http://:pass@") + "resources/cors-makeheader.py?"]);

shouldPass("Allow redirect with userinfo (//@)", [
shouldPass("Allow redirect without userinfo (@ is trimmed during URL parsing)", [
CROSSDOMAIN + "resources/cors-makeheader.py?",
CROSSDOMAIN.replace("http://", "http://@") + "resources/cors-makeheader.py?"]);

Expand All @@ -51,12 +51,8 @@ <h1>CORS userinfo redirect handling</h1>

client.open('GET', buildURL(urls, test_id));

client.onload = t.step_func(function() {
assert_false(!!client.response, "Got response");
});
client.onerror = t.step_func(function(e) {
t.done();
});
client.onload = t.unreached_func();
client.onerror = t.step_func_done();

client.send(null)
});
Expand All @@ -73,25 +69,18 @@ <h1>CORS userinfo redirect handling</h1>

client.open('GET', buildURL(urls, test_id));

client.onreadystatechange = t.step_func(function() {
if (client.readyState != client.DONE)
return;
assert_true(!!client.response, "Got response");
client.onload = t.step_func_done(function() {
r = JSON.parse(client.response)
assert_equals(r['get_value'], 'last', 'get_value')
t.done();
});
client.onerror = t.unreached_func()
client.send(null)
});
}

function buildURL(urls, id) {
var tmp_url;

if (typeof(urls) == "string") {
return urls + "&" + id + "_0";
}

for (var i = urls.length; i--; ) {
if (!tmp_url)
{
Expand Down