mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1104279 - Part 2: Add sequence verification to logInToFxa test. r=dmose
This commit is contained in:
parent
1c4282edcb
commit
a1a8f48b9c
@ -65,6 +65,7 @@ function setup_params(request, response) {
|
||||
if (request.method == "DELETE") {
|
||||
setSharedState("/fxa-oauth/params", "");
|
||||
setSharedState("/registration", "");
|
||||
setSharedState("/fxa-oauth/token", "");
|
||||
response.write("Params deleted");
|
||||
return;
|
||||
}
|
||||
@ -166,13 +167,14 @@ function token(request, response) {
|
||||
return;
|
||||
}
|
||||
|
||||
let tokenData = {
|
||||
access_token: payload.code + "_access_token",
|
||||
scope: "profile",
|
||||
token_type: "bearer",
|
||||
};
|
||||
let tokenData = JSON.stringify(
|
||||
{access_token: payload.code + "_access_token",
|
||||
scope: "profile",
|
||||
token_type: "bearer"},
|
||||
null, 2);
|
||||
setSharedState("/fxa-oauth/token", tokenData);
|
||||
response.setHeader("Content-Type", "application/json; charset=utf-8", false);
|
||||
response.write(JSON.stringify(tokenData, null, 2));
|
||||
response.write(tokenData);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -194,17 +196,27 @@ function profile(request, response) {
|
||||
* Mock Loop registration endpoint. Hawk Authorization headers are expected only for FxA sessions.
|
||||
*/
|
||||
function registration(request, response) {
|
||||
let isFxARequest = function(payload) {
|
||||
return (payload.simplePushURL == "https://localhost/pushUrl/fxa" ||
|
||||
payload.simplePushURLs.calls == "https://localhost/pushUrl/fxa-calls" ||
|
||||
payload.simplePushURLs.rooms == "https://localhost/pushUrl/fxa-rooms");
|
||||
};
|
||||
|
||||
let body = NetUtil.readInputStreamToString(request.bodyInputStream,
|
||||
request.bodyInputStream.available());
|
||||
let payload = JSON.parse(body);
|
||||
if ((payload.simplePushURL == "https://localhost/pushUrl/fxa" ||
|
||||
payload.simplePushURLs.calls == "https://localhost/pushUrl/fxa-calls" ||
|
||||
payload.simplePushURLs.rooms == "https://localhost/pushUrl/fxa-rooms") &&
|
||||
(!request.hasHeader("Authorization") ||
|
||||
!request.getHeader("Authorization").startsWith("Hawk"))) {
|
||||
response.setStatusLine(request.httpVersion, 401, "Missing Hawk");
|
||||
response.write("401 Missing Hawk Authorization header");
|
||||
return;
|
||||
if (isFxARequest(payload)) {
|
||||
if (!request.hasHeader("Authorization") ||
|
||||
!request.getHeader("Authorization").startsWith("Hawk")) {
|
||||
response.setStatusLine(request.httpVersion, 401, "Missing Hawk");
|
||||
response.write("401 Missing Hawk Authorization header");
|
||||
return;
|
||||
}
|
||||
if (!getSharedState("/fxa-oauth/token")) {
|
||||
response.setStatusLine(request.httpVersion, 409, "Wrong State");
|
||||
response.write("409 complete OAuth before attempting registration");
|
||||
return;
|
||||
}
|
||||
}
|
||||
setSharedState("/registration", body);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user