mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 927457 - processTokenResponse fails to handle 401 response correctly. r=gps
This commit is contained in:
parent
42002b918e
commit
e883ceb840
@ -331,6 +331,31 @@ add_test(function test_400_response() {
|
||||
});
|
||||
});
|
||||
|
||||
add_test(function test_401_response() {
|
||||
_("Ensure HTTP 401 is converted to invalid-credentials.");
|
||||
|
||||
let server = httpd_setup({
|
||||
"/1.0/foo/1.0": function(request, response) {
|
||||
response.setStatusLine(request.httpVersion, 401, "Unauthorized");
|
||||
response.setHeader("Content-Type", "application/json; charset=utf-8");
|
||||
|
||||
let body = "{}"; // Actual content may not be used.
|
||||
response.bodyOutputStream.write(body, body.length);
|
||||
}
|
||||
});
|
||||
|
||||
let client = new TokenServerClient();
|
||||
let url = server.baseURI + "/1.0/foo/1.0";
|
||||
client.getTokenFromBrowserIDAssertion(url, "assertion", function(error, r) {
|
||||
do_check_neq(null, error);
|
||||
do_check_eq("TokenServerClientServerError", error.name);
|
||||
do_check_neq(null, error.response);
|
||||
do_check_eq(error.cause, "invalid-credentials");
|
||||
|
||||
server.stop(run_next_test);
|
||||
});
|
||||
});
|
||||
|
||||
add_test(function test_unhandled_media_type() {
|
||||
_("Ensure that unhandled media types throw an error.");
|
||||
|
||||
|
@ -326,7 +326,7 @@ TokenServerClient.prototype = {
|
||||
error.message = "Malformed request.";
|
||||
error.cause = "malformed-request";
|
||||
} else if (response.status == 401) {
|
||||
error.message("Authentication failed.");
|
||||
error.message = "Authentication failed.";
|
||||
error.cause = "invalid-credentials";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user