Bug 1296767 part 13 - Repair Weave Service getStorageInfo. r=markh

MozReview-Commit-ID: E4S5xYTNDIH

--HG--
extra : rebase_source : 6a98b9503183bbf679622b00073d162fd3e4f5e4
This commit is contained in:
Edouard Oger 2017-01-23 15:19:04 -05:00
Родитель b0e947451a
Коммит 1595b78c75
4 изменённых файлов: 27 добавлений и 30 удалений

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

@ -39,7 +39,12 @@ SyncStorageRequest.prototype = {
}
if (this.authenticator) {
this.authenticator(this);
let result = this.authenticator(this, method);
if (result && result.headers) {
for (let [k, v] of Object.entries(result.headers)) {
setHeader(k, v);
}
}
} else {
this._log.debug("No authenticator found.");
}

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

@ -19,25 +19,20 @@ function run_test() {
Log.repository.getLogger("Sync.StorageRequest").level = Log.Level.Trace;
initTestLogging();
ensureLegacyIdentityManager();
setBasicCredentials("johndoe", "ilovejane");
run_next_test();
}
add_test(function test_success() {
add_task(async function test_success() {
let handler = httpd_handler(200, "OK", JSON.stringify(collections));
let server = httpd_setup({"/1.1/johndoe/info/collections": handler});
Service.clusterURL = server.baseURI + "/";
await configureIdentity({ username: "johndoe" }, server);
let request = Service.getStorageInfo("collections", function(error, info) {
do_check_eq(error, null);
do_check_true(Utils.deepEquals(info, collections));
// Ensure that the request is sent off with the right bits.
do_check_true(basic_auth_matches(handler.request,
Service.identity.username,
Service.identity.basicPassword));
do_check_true(has_hawk_header(handler.request));
let expectedUA = Services.appinfo.name + "/" + Services.appinfo.version +
" (" + httpProtocolHandler.oscpu + ")" +
" FxSync/" + WEAVE_VERSION + "." +
@ -66,10 +61,10 @@ add_test(function test_network_error() {
});
});
add_test(function test_http_error() {
add_task(async function test_http_error() {
let handler = httpd_handler(500, "Oh noez", "Something went wrong!");
let server = httpd_setup({"/1.1/johndoe/info/collections": handler});
Service.clusterURL = server.baseURI + "/";
await configureIdentity({ username: "johndoe" }, server);
Service.getStorageInfo(INFO_COLLECTIONS, function(error, info) {
do_check_eq(error.status, 500);
@ -78,10 +73,10 @@ add_test(function test_http_error() {
});
});
add_test(function test_invalid_json() {
add_task(async function test_invalid_json() {
let handler = httpd_handler(200, "OK", "Invalid JSON");
let server = httpd_setup({"/1.1/johndoe/info/collections": handler});
Service.clusterURL = server.baseURI + "/";
await configureIdentity({ username: "johndoe" }, server);
Service.getStorageInfo(INFO_COLLECTIONS, function(error, info) {
do_check_eq(error.name, "SyntaxError");

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

@ -57,24 +57,22 @@ add_test(function test_user_agent_mobile() {
});
});
// XXX - DISABLED BECAUSE getStorageRequest broken with browserid_manager
// add_test(function test_auth() {
// let handler = httpd_handler(200, "OK");
// let server = httpd_setup({"/resource": handler});
add_task(async function test_auth() {
let handler = httpd_handler(200, "OK");
let server = httpd_setup({"/resource": handler});
await configureIdentity({ username: "foo" }, server);
// configureIdentity();
let request = Service.getStorageRequest(server.baseURI + "/resource");
request.get(function(error) {
do_check_eq(error, null);
do_check_eq(this.response.status, 200);
do_check_true(has_hawk_header(handler.request));
// let request = Service.getStorageRequest(server.baseURI + "/resource");
// request.get(function(error) {
// do_check_eq(error, null);
// do_check_eq(this.response.status, 200);
// do_check_true(has_hawk_header(handler.request));
Svc.Prefs.reset("");
// Svc.Prefs.reset("");
// server.stop(run_next_test);
// });
// });
server.stop(run_next_test);
});
});
/**
* The X-Weave-Timestamp header updates SyncStorageRequest.serverTime.

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

@ -74,8 +74,7 @@ skip-if = os == "android"
skip-if = os == "mac" || os == "linux"
[test_service_cluster.js]
[test_service_detect_upgrade.js]
# XXX - Disabled because getStorageInfo is broken
# [test_service_getStorageInfo.js]
[test_service_getStorageInfo.js]
[test_service_login.js]
[test_service_migratePrefs.js]
[test_service_startOver.js]