Bug 772261 - Add duration to token server and client. r=rnewman

This commit is contained in:
Chris Karlof 2013-12-13 12:12:00 -05:00
Родитель dd731e9a22
Коммит 654bf66577
2 изменённых файлов: 12 добавлений и 3 удалений

Просмотреть файл

@ -14,6 +14,7 @@ add_test(function test_working_bid_exchange() {
_("Ensure that working BrowserID token exchange works as expected."); _("Ensure that working BrowserID token exchange works as expected.");
let service = "http://example.com/foo"; let service = "http://example.com/foo";
let duration = 300;
let server = httpd_setup({ let server = httpd_setup({
"/1.0/foo/1.0": function(request, response) { "/1.0/foo/1.0": function(request, response) {
@ -29,6 +30,7 @@ add_test(function test_working_bid_exchange() {
key: "key", key: "key",
api_endpoint: service, api_endpoint: service,
uid: "uid", uid: "uid",
duration: duration,
}); });
response.bodyOutputStream.write(body, body.length); response.bodyOutputStream.write(body, body.length);
} }
@ -40,12 +42,12 @@ add_test(function test_working_bid_exchange() {
client.getTokenFromBrowserIDAssertion(url, "assertion", cb); client.getTokenFromBrowserIDAssertion(url, "assertion", cb);
let result = cb.wait(); let result = cb.wait();
do_check_eq("object", typeof(result)); do_check_eq("object", typeof(result));
do_check_attribute_count(result, 4); do_check_attribute_count(result, 5);
do_check_eq(service, result.endpoint); do_check_eq(service, result.endpoint);
do_check_eq("id", result.id); do_check_eq("id", result.id);
do_check_eq("key", result.key); do_check_eq("key", result.key);
do_check_eq("uid", result.uid); do_check_eq("uid", result.uid);
do_check_eq(duration, result.duration);
server.stop(run_next_test); server.stop(run_next_test);
}); });
@ -200,6 +202,7 @@ add_test(function test_403_no_urls() {
add_test(function test_send_conditions_accepted() { add_test(function test_send_conditions_accepted() {
_("Ensures that the condition acceptance header is sent when asked."); _("Ensures that the condition acceptance header is sent when asked.");
let duration = 300;
let server = httpd_setup({ let server = httpd_setup({
"/1.0/foo/1.0": function(request, response) { "/1.0/foo/1.0": function(request, response) {
do_check_true(request.hasHeader("x-conditions-accepted")); do_check_true(request.hasHeader("x-conditions-accepted"));
@ -213,6 +216,7 @@ add_test(function test_send_conditions_accepted() {
key: "key", key: "key",
api_endpoint: "http://example.com/", api_endpoint: "http://example.com/",
uid: "uid", uid: "uid",
duration: duration,
}); });
response.bodyOutputStream.write(body, body.length); response.bodyOutputStream.write(body, body.length);
} }
@ -384,6 +388,7 @@ add_test(function test_unhandled_media_type() {
add_test(function test_rich_media_types() { add_test(function test_rich_media_types() {
_("Ensure that extra tokens in the media type aren't rejected."); _("Ensure that extra tokens in the media type aren't rejected.");
let duration = 300;
let server = httpd_setup({ let server = httpd_setup({
"/foo": function(request, response) { "/foo": function(request, response) {
response.setStatusLine(request.httpVersion, 200, "OK"); response.setStatusLine(request.httpVersion, 200, "OK");
@ -394,6 +399,7 @@ add_test(function test_rich_media_types() {
key: "key", key: "key",
api_endpoint: "foo", api_endpoint: "foo",
uid: "uid", uid: "uid",
duration: duration,
}); });
response.bodyOutputStream.write(body, body.length); response.bodyOutputStream.write(body, body.length);
} }
@ -411,6 +417,7 @@ add_test(function test_rich_media_types() {
add_test(function test_exception_during_callback() { add_test(function test_exception_during_callback() {
_("Ensure that exceptions thrown during callback handling are handled."); _("Ensure that exceptions thrown during callback handling are handled.");
let duration = 300;
let server = httpd_setup({ let server = httpd_setup({
"/foo": function(request, response) { "/foo": function(request, response) {
response.setStatusLine(request.httpVersion, 200, "OK"); response.setStatusLine(request.httpVersion, 200, "OK");
@ -421,6 +428,7 @@ add_test(function test_exception_during_callback() {
key: "key", key: "key",
api_endpoint: "foo", api_endpoint: "foo",
uid: "uid", uid: "uid",
duration: duration,
}); });
response.bodyOutputStream.write(body, body.length); response.bodyOutputStream.write(body, body.length);
} }

Просмотреть файл

@ -359,7 +359,7 @@ TokenServerClient.prototype = {
return; return;
} }
for (let k of ["id", "key", "api_endpoint", "uid"]) { for (let k of ["id", "key", "api_endpoint", "uid", "duration"]) {
if (!(k in result)) { if (!(k in result)) {
let error = new TokenServerClientServerError("Expected key not " + let error = new TokenServerClientServerError("Expected key not " +
" present in result: " + " present in result: " +
@ -377,6 +377,7 @@ TokenServerClient.prototype = {
key: result.key, key: result.key,
endpoint: result.api_endpoint, endpoint: result.api_endpoint,
uid: result.uid, uid: result.uid,
duration: result.duration,
}); });
} }
}; };