forked from nodejs/undici
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fetch: implement whatwg/fetch#1544 (nodejs#1780)
* fetch: implement whatwg/fetch#1544 * add wpt * chore: update url
- Loading branch information
Showing
3 changed files
with
65 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
test/wpt/tests/fetch/api/credentials/authentication-redirection.any.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// META: global=window,worker | ||
// META: script=/common/get-host-info.sub.js | ||
|
||
const authorizationValue = "Basic " + btoa("user:pass"); | ||
async function getAuthorizationHeaderValue(url) | ||
{ | ||
const headers = { "Authorization": authorizationValue}; | ||
const requestInit = {"headers": headers}; | ||
const response = await fetch(url, requestInit); | ||
return response.text(); | ||
} | ||
|
||
promise_test(async test => { | ||
const result = await getAuthorizationHeaderValue("/fetch/api/resources/dump-authorization-header.py"); | ||
assert_equals(result, authorizationValue); | ||
}, "getAuthorizationHeaderValue - no redirection"); | ||
|
||
promise_test(async test => { | ||
const result = await getAuthorizationHeaderValue("/fetch/api/resources/redirect.py?location=" + encodeURIComponent("/fetch/api/resources/dump-authorization-header.py")); | ||
assert_equals(result, authorizationValue); | ||
}, "getAuthorizationHeaderValue - same origin redirection"); | ||
|
||
promise_test(async (test) => { | ||
const result = await getAuthorizationHeaderValue(get_host_info().HTTP_REMOTE_ORIGIN + "/fetch/api/resources/redirect.py?allow_headers=Authorization&location=" + encodeURIComponent(get_host_info().HTTP_ORIGIN + "/fetch/api/resources/dump-authorization-header.py")); | ||
assert_equals(result, "none"); | ||
}, "getAuthorizationHeaderValue - cross origin redirection"); |