Bug 720596 - Set both serverURL and clusterURL in test code; utilize constants; r=gps

This commit is contained in:
Murali 2012-02-06 09:50:11 -08:00
parent a3f5ccd40d
commit bc3fef50d8
35 changed files with 238 additions and 160 deletions

View File

@ -93,7 +93,8 @@ function serverForFoo(engine) {
add_test(function test_processIncoming_error_orderChildren() {
_("Ensure that _orderChildren() is called even when _processIncoming() throws an error.");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
let engine = new BookmarksEngine();
@ -166,8 +167,8 @@ add_test(function test_restorePromptsReupload() {
_("Ensure that restoring from a backup will reupload all records.");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("username", "foo");
Service.serverURL = "http://localhost:8080/";
Service.clusterURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.clusterURL = TEST_CLUSTER_URL;
let engine = new BookmarksEngine();
let store = engine._store;
@ -334,8 +335,8 @@ add_test(function test_mismatched_types() {
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("username", "foo");
Service.serverURL = "http://localhost:8080/";
Service.clusterURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.clusterURL = TEST_CLUSTER_URL;
let engine = new BookmarksEngine();
let store = engine._store;
@ -377,7 +378,8 @@ add_test(function test_bookmark_guidMap_fail() {
_("Ensure that failures building the GUID map cause early death.");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
let engine = new BookmarksEngine();
let store = engine._store;

View File

@ -107,8 +107,8 @@ add_test(function test_annotation_uploaded() {
_("Sync record to the server.");
Svc.Prefs.set("username", "foo");
Service.serverURL = "http://localhost:8080/";
Service.clusterURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.clusterURL = TEST_CLUSTER_URL;
let server = serverForFoo(engine);
let collection = server.user("foo").collection("bookmarks");
@ -193,8 +193,8 @@ add_test(function test_smart_bookmarks_duped() {
_("Prepare sync.");
Svc.Prefs.set("username", "foo");
Service.serverURL = "http://localhost:8080/";
Service.clusterURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.clusterURL = TEST_CLUSTER_URL;
let server = serverForFoo(engine);
let collection = server.user("foo").collection("bookmarks");

View File

@ -54,8 +54,8 @@ add_test(function test_bad_hmac() {
try {
let passphrase = "abcdeabcdeabcdeabcdeabcdea";
Service.serverURL = "http://localhost:8080/";
Service.clusterURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.clusterURL = TEST_CLUSTER_URL;
Service.login("foo", "ilovejane", passphrase);
generateNewKeys();
@ -164,7 +164,9 @@ add_test(function test_properties() {
add_test(function test_sync() {
_("Ensure that Clients engine uploads a new client record once a week.");
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
generateNewKeys();
@ -402,7 +404,9 @@ add_test(function test_process_incoming_commands() {
add_test(function test_command_sync() {
_("Ensure that commands are synced across clients.");
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
Clients._store.wipe();

View File

@ -19,8 +19,8 @@ add_test(function test_missing_crypto_collection() {
};
}
Service.serverURL = "http://localhost:8080/";
Service.clusterURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.clusterURL = TEST_CLUSTER_URL;
Service.username = "johndoe";
Service.password = "ilovejane";
Service.passphrase = "a-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa";

View File

@ -55,8 +55,8 @@ add_test(function test_locally_changed_keys() {
Weave.Service.password = "ilovejane";
Weave.Service.passphrase = passphrase;
Weave.Service.serverURL = "http://localhost:8080/";
Weave.Service.clusterURL = "http://localhost:8080/";
Weave.Service.serverURL = TEST_SERVER_URL;
Weave.Service.clusterURL = TEST_CLUSTER_URL;
Engines.register(HistoryEngine);
Weave.Service._registerEngines();

View File

@ -4,7 +4,8 @@ Cu.import("resource://services-sync/util.js");
add_test(function test_processIncoming_abort() {
_("An abort exception, raised in applyIncoming, will abort _processIncoming.");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
generateNewKeys();

View File

@ -9,6 +9,7 @@ Cu.import("resource://services-sync/status.js");
Svc.DefaultPrefs.set("registerEngines", "");
Cu.import("resource://services-sync/service.js");
const TEST_MAINTENANCE_URL = "http://localhost:8080/maintenance/";
const logsdir = FileUtils.getDir("ProfD", ["weave", "logs"], true);
const LOG_PREFIX_SUCCESS = "success-";
const LOG_PREFIX_ERROR = "error-";
@ -120,8 +121,10 @@ function setUp() {
Service.username = "johndoe";
Service.password = "ilovejane";
Service.passphrase = "abcdeabcdeabcdeabcdeabcdea";
Service.serverURL = "http://localhost:8080/";
Service.clusterURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.clusterURL = TEST_CLUSTER_URL;
return generateAndUploadKeys();
}
@ -219,7 +222,8 @@ add_test(function test_shouldReportError() {
// Give ourselves a clusterURL so that the temporary 401 no-error situation
// doesn't come into play.
Service.clusterURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.clusterURL = TEST_CLUSTER_URL;
// Test dontIgnoreErrors, non-network, non-prolonged, login error reported
Status.resetSync();
@ -510,7 +514,8 @@ add_test(function test_login_syncAndReportErrors_network_error() {
Service.username = "johndoe";
Service.password = "ilovejane";
Service.passphrase = "abcdeabcdeabcdeabcdeabcdea";
Service.clusterURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.clusterURL = TEST_CLUSTER_URL;
Svc.Obs.add("weave:ui:login:error", function onSyncError() {
Svc.Obs.remove("weave:ui:login:error", onSyncError);
@ -548,7 +553,8 @@ add_test(function test_login_syncAndReportErrors_prolonged_network_error() {
Service.username = "johndoe";
Service.password = "ilovejane";
Service.passphrase = "abcdeabcdeabcdeabcdeabcdea";
Service.clusterURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.clusterURL = TEST_CLUSTER_URL;
Svc.Obs.add("weave:ui:login:error", function onSyncError() {
Svc.Obs.remove("weave:ui:login:error", onSyncError);
@ -627,7 +633,8 @@ add_test(function test_login_prolonged_network_error() {
Service.username = "johndoe";
Service.password = "ilovejane";
Service.passphrase = "abcdeabcdeabcdeabcdeabcdea";
Service.clusterURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.clusterURL = TEST_CLUSTER_URL;
Svc.Obs.add("weave:ui:login:error", function onSyncError() {
Svc.Obs.remove("weave:ui:login:error", onSyncError);
@ -704,7 +711,8 @@ add_test(function test_login_network_error() {
Service.username = "johndoe";
Service.password = "ilovejane";
Service.passphrase = "abcdeabcdeabcdeabcdeabcdea";
Service.clusterURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.clusterURL = TEST_CLUSTER_URL;
// Test network errors are not reported.
Svc.Obs.add("weave:ui:clear-error", function onClearError() {
@ -777,7 +785,8 @@ add_test(function test_info_collections_login_server_maintenance_error() {
setUp();
Service.username = "broken.info";
Service.clusterURL = "http://localhost:8080/maintenance/";
Service.serverURL = TEST_MAINTENANCE_URL;
Service.clusterURL = TEST_MAINTENANCE_URL;
let backoffInterval;
Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) {
@ -816,7 +825,8 @@ add_test(function test_meta_global_login_server_maintenance_error() {
setUp();
Service.username = "broken.meta";
Service.clusterURL = "http://localhost:8080/maintenance/";
Service.serverURL = TEST_MAINTENANCE_URL;
Service.clusterURL = TEST_MAINTENANCE_URL;
let backoffInterval;
Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) {
@ -855,7 +865,8 @@ add_test(function test_crypto_keys_login_server_maintenance_error() {
setUp();
Service.username = "broken.keys";
Service.clusterURL = "http://localhost:8080/maintenance/";
Service.serverURL = TEST_MAINTENANCE_URL;
Service.clusterURL = TEST_MAINTENANCE_URL;
// Force re-download of keys
CollectionKeys.clear();
@ -922,7 +933,8 @@ add_test(function test_info_collections_login_prolonged_server_maintenance_error
setUp();
Service.username = "broken.info";
Service.clusterURL = "http://localhost:8080/maintenance/";
Service.serverURL = TEST_MAINTENANCE_URL;
Service.clusterURL = TEST_MAINTENANCE_URL;
let backoffInterval;
Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) {
@ -954,7 +966,8 @@ add_test(function test_meta_global_login_prolonged_server_maintenance_error(){
setUp();
Service.username = "broken.meta";
Service.clusterURL = "http://localhost:8080/maintenance/";
Service.serverURL = TEST_MAINTENANCE_URL;
Service.clusterURL = TEST_MAINTENANCE_URL;
let backoffInterval;
Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) {
@ -986,7 +999,8 @@ add_test(function test_download_crypto_keys_login_prolonged_server_maintenance_e
setUp();
Service.username = "broken.keys";
Service.clusterURL = "http://localhost:8080/maintenance/";
Service.serverURL = TEST_MAINTENANCE_URL;
Service.clusterURL = TEST_MAINTENANCE_URL;
// Force re-download of keys
CollectionKeys.clear();
@ -1022,7 +1036,8 @@ add_test(function test_upload_crypto_keys_login_prolonged_server_maintenance_err
Service.username = "broken.keys";
Service.password = "ilovejane";
Service.passphrase = "abcdeabcdeabcdeabcdeabcdea";
Service.clusterURL = "http://localhost:8080/maintenance/";
Service.serverURL = TEST_MAINTENANCE_URL;
Service.clusterURL = TEST_MAINTENANCE_URL;
let backoffInterval;
Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) {
@ -1057,7 +1072,8 @@ add_test(function test_wipeServer_login_prolonged_server_maintenance_error(){
Service.username = "broken.wipe";
Service.password = "ilovejane";
Service.passphrase = "abcdeabcdeabcdeabcdeabcdea";
Service.clusterURL = "http://localhost:8080/maintenance/";
Service.serverURL = TEST_MAINTENANCE_URL;
Service.clusterURL = TEST_MAINTENANCE_URL;
let backoffInterval;
Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) {
@ -1091,7 +1107,8 @@ add_test(function test_wipeRemote_prolonged_server_maintenance_error(){
Service.username = "broken.wipe";
Service.password = "ilovejane";
Service.passphrase = "abcdeabcdeabcdeabcdeabcdea";
Service.clusterURL = "http://localhost:8080/maintenance/";
Service.serverURL = TEST_MAINTENANCE_URL;
Service.clusterURL = TEST_MAINTENANCE_URL;
generateAndUploadKeys();
let engine = Engines.get("catapult");
@ -1158,7 +1175,8 @@ add_test(function test_info_collections_login_syncAndReportErrors_server_mainten
setUp();
Service.username = "broken.info";
Service.clusterURL = "http://localhost:8080/maintenance/";
Service.serverURL = TEST_MAINTENANCE_URL;
Service.clusterURL = TEST_MAINTENANCE_URL;
let backoffInterval;
Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) {
@ -1191,7 +1209,8 @@ add_test(function test_meta_global_login_syncAndReportErrors_server_maintenance_
setUp();
Service.username = "broken.meta";
Service.clusterURL = "http://localhost:8080/maintenance/";
Service.serverURL = TEST_MAINTENANCE_URL;
Service.clusterURL = TEST_MAINTENANCE_URL;
let backoffInterval;
Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) {
@ -1224,7 +1243,8 @@ add_test(function test_download_crypto_keys_login_syncAndReportErrors_server_mai
setUp();
Service.username = "broken.keys";
Service.clusterURL = "http://localhost:8080/maintenance/";
Service.serverURL = TEST_MAINTENANCE_URL;
Service.clusterURL = TEST_MAINTENANCE_URL;
// Force re-download of keys
CollectionKeys.clear();
@ -1261,7 +1281,8 @@ add_test(function test_upload_crypto_keys_login_syncAndReportErrors_server_maint
Service.username = "broken.keys";
Service.password = "ilovejane";
Service.passphrase = "abcdeabcdeabcdeabcdeabcdea";
Service.clusterURL = "http://localhost:8080/maintenance/";
Service.serverURL = TEST_MAINTENANCE_URL;
Service.clusterURL = TEST_MAINTENANCE_URL;
let backoffInterval;
Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) {
@ -1296,7 +1317,8 @@ add_test(function test_wipeServer_login_syncAndReportErrors_server_maintenance_e
Service.username = "broken.wipe";
Service.password = "ilovejane";
Service.passphrase = "abcdeabcdeabcdeabcdeabcdea";
Service.clusterURL = "http://localhost:8080/maintenance/";
Service.serverURL = TEST_MAINTENANCE_URL;
Service.clusterURL = TEST_MAINTENANCE_URL;
let backoffInterval;
Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) {
@ -1330,7 +1352,8 @@ add_test(function test_wipeRemote_syncAndReportErrors_server_maintenance_error()
Service.username = "broken.wipe";
Service.password = "ilovejane";
Service.passphrase = "abcdeabcdeabcdeabcdeabcdea";
Service.clusterURL = "http://localhost:8080/maintenance/";
Service.serverURL = TEST_MAINTENANCE_URL;
Service.clusterURL = TEST_MAINTENANCE_URL;
generateAndUploadKeys();
let engine = Engines.get("catapult");
@ -1397,7 +1420,8 @@ add_test(function test_info_collections_login_syncAndReportErrors_prolonged_serv
setUp();
Service.username = "broken.info";
Service.clusterURL = "http://localhost:8080/maintenance/";
Service.serverURL = TEST_MAINTENANCE_URL;
Service.clusterURL = TEST_MAINTENANCE_URL;
let backoffInterval;
Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) {
@ -1430,7 +1454,8 @@ add_test(function test_meta_global_login_syncAndReportErrors_prolonged_server_ma
setUp();
Service.username = "broken.meta";
Service.clusterURL = "http://localhost:8080/maintenance/";
Service.serverURL = TEST_MAINTENANCE_URL;
Service.clusterURL = TEST_MAINTENANCE_URL;
let backoffInterval;
Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) {
@ -1463,7 +1488,8 @@ add_test(function test_download_crypto_keys_login_syncAndReportErrors_prolonged_
setUp();
Service.username = "broken.keys";
Service.clusterURL = "http://localhost:8080/maintenance/";
Service.serverURL = TEST_MAINTENANCE_URL;
Service.clusterURL = TEST_MAINTENANCE_URL;
// Force re-download of keys
CollectionKeys.clear();
@ -1500,7 +1526,8 @@ add_test(function test_upload_crypto_keys_login_syncAndReportErrors_prolonged_se
Service.username = "broken.keys";
Service.password = "ilovejane";
Service.passphrase = "abcdeabcdeabcdeabcdeabcdea";
Service.clusterURL = "http://localhost:8080/maintenance/";
Service.serverURL = TEST_MAINTENANCE_URL;
Service.clusterURL = TEST_MAINTENANCE_URL;
let backoffInterval;
Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) {
@ -1535,7 +1562,8 @@ add_test(function test_wipeServer_login_syncAndReportErrors_prolonged_server_mai
Service.username = "broken.wipe";
Service.password = "ilovejane";
Service.passphrase = "abcdeabcdeabcdeabcdeabcdea";
Service.clusterURL = "http://localhost:8080/maintenance/";
Service.serverURL = TEST_MAINTENANCE_URL;
Service.clusterURL = TEST_MAINTENANCE_URL;
let backoffInterval;
Svc.Obs.add("weave:service:backoff:interval", function observe(subject, data) {

View File

@ -51,7 +51,8 @@ function setUp() {
Service.username = "johndoe";
Service.password = "ilovejane";
Service.passphrase = "aabcdeabcdeabcdeabcdeabcde";
Service.clusterURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.clusterURL = TEST_CLUSTER_URL;
new FakeCryptoService();
}

View File

@ -12,7 +12,8 @@ add_test(function test_processIncoming_mobile_history_batched() {
let FAKE_DOWNLOAD_LIMIT = 100;
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
Svc.Prefs.set("client.type", "mobile");
PlacesUtils.history.removeAllPages();

View File

@ -18,8 +18,8 @@ function shared_setup() {
hmacErrorCount = 0;
// Do not instantiate SyncTestingInfrastructure; we need real crypto.
Service.serverURL = "http://localhost:8080/";
Service.clusterURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.clusterURL = TEST_CLUSTER_URL;
Service.username = "foo";
Service.password = "foo";
Service.passphrase = "aabcdeabcdeabcdeabcdeabcde";

View File

@ -35,7 +35,8 @@ function setUp() {
Service.username = "johndoe";
Service.password = "ilovejane";
Service.passphrase = "abcdeabcdeabcdeabcdeabcdea";
Service.clusterURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.clusterURL = TEST_CLUSTER_URL;
generateNewKeys();
let serverKeys = CollectionKeys.asWBO("crypto", "keys");

View File

@ -159,7 +159,7 @@ const DATA = {"msg": "eggstreamly sekrit"};
const POLLINTERVAL = 50;
function run_test() {
Svc.Prefs.set("jpake.serverURL", "http://localhost:8080/");
Svc.Prefs.set("jpake.serverURL", TEST_SERVER_URL);
Svc.Prefs.set("jpake.pollInterval", POLLINTERVAL);
Svc.Prefs.set("jpake.maxTries", 2);
Svc.Prefs.set("jpake.firstMsgMaxTries", 5);

View File

@ -76,8 +76,8 @@ function prepareServer() {
Service.username = "johndoe";
Service.passphrase = "abcdeabcdeabcdeabcdeabcdea";
Service.password = "ilovejane";
Service.serverURL = "http://localhost:8080/";
Service.clusterURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.clusterURL = TEST_CLUSTER_URL;
do_check_eq(Service.userAPI, "http://localhost:8080/user/1.0/");
let server = new SyncServer();

View File

@ -4,6 +4,9 @@ Cu.import("resource://services-sync/log4moz.js");
Cu.import("resource://services-sync/resource.js");
Cu.import("resource://services-sync/util.js");
const RES_UPLOAD_URL = "http://localhost:8080/upload";
const RES_HEADERS_URL = "http://localhost:8080/headers";
let logger;
let fetched = false;
@ -322,7 +325,7 @@ add_test(function test_get_404() {
add_test(function test_put_string() {
_("PUT to a resource (string)");
let res_upload = new AsyncResource("http://localhost:8080/upload");
let res_upload = new AsyncResource(RES_UPLOAD_URL);
res_upload.put(JSON.stringify(sample_data), function(error, content) {
do_check_eq(error, null);
do_check_eq(content, "Valid data upload via PUT");
@ -334,7 +337,7 @@ add_test(function test_put_string() {
add_test(function test_put_object() {
_("PUT to a resource (object)");
let res_upload = new AsyncResource("http://localhost:8080/upload");
let res_upload = new AsyncResource(RES_UPLOAD_URL);
res_upload.put(sample_data, function (error, content) {
do_check_eq(error, null);
do_check_eq(content, "Valid data upload via PUT");
@ -346,7 +349,7 @@ add_test(function test_put_object() {
add_test(function test_put_data_string() {
_("PUT without data arg (uses resource.data) (string)");
let res_upload = new AsyncResource("http://localhost:8080/upload");
let res_upload = new AsyncResource(RES_UPLOAD_URL);
res_upload.data = JSON.stringify(sample_data);
res_upload.put(function (error, content) {
do_check_eq(error, null);
@ -359,7 +362,7 @@ add_test(function test_put_data_string() {
add_test(function test_put_data_object() {
_("PUT without data arg (uses resource.data) (object)");
let res_upload = new AsyncResource("http://localhost:8080/upload");
let res_upload = new AsyncResource(RES_UPLOAD_URL);
res_upload.data = sample_data;
res_upload.put(function (error, content) {
do_check_eq(error, null);
@ -372,7 +375,7 @@ add_test(function test_put_data_object() {
add_test(function test_post_string() {
_("POST to a resource (string)");
let res_upload = new AsyncResource("http://localhost:8080/upload");
let res_upload = new AsyncResource(RES_UPLOAD_URL);
res_upload.post(JSON.stringify(sample_data), function (error, content) {
do_check_eq(error, null);
do_check_eq(content, "Valid data upload via POST");
@ -384,7 +387,7 @@ add_test(function test_post_string() {
add_test(function test_post_object() {
_("POST to a resource (object)");
let res_upload = new AsyncResource("http://localhost:8080/upload");
let res_upload = new AsyncResource(RES_UPLOAD_URL);
res_upload.post(sample_data, function (error, content) {
do_check_eq(error, null);
do_check_eq(content, "Valid data upload via POST");
@ -396,7 +399,7 @@ add_test(function test_post_object() {
add_test(function test_post_data_string() {
_("POST without data arg (uses resource.data) (string)");
let res_upload = new AsyncResource("http://localhost:8080/upload");
let res_upload = new AsyncResource(RES_UPLOAD_URL);
res_upload.data = JSON.stringify(sample_data);
res_upload.post(function (error, content) {
do_check_eq(error, null);
@ -409,7 +412,7 @@ add_test(function test_post_data_string() {
add_test(function test_post_data_object() {
_("POST without data arg (uses resource.data) (object)");
let res_upload = new AsyncResource("http://localhost:8080/upload");
let res_upload = new AsyncResource(RES_UPLOAD_URL);
res_upload.data = sample_data;
res_upload.post(function (error, content) {
do_check_eq(error, null);
@ -458,7 +461,7 @@ add_test(function test_weave_timestamp() {
add_test(function test_get_no_headers() {
_("GET: no special request headers");
let res_headers = new AsyncResource("http://localhost:8080/headers");
let res_headers = new AsyncResource(RES_HEADERS_URL);
res_headers.get(function (error, content) {
do_check_eq(error, null);
do_check_eq(content, '{}');
@ -468,7 +471,7 @@ add_test(function test_get_no_headers() {
add_test(function test_put_default_content_type() {
_("PUT: Content-Type defaults to text/plain");
let res_headers = new AsyncResource("http://localhost:8080/headers");
let res_headers = new AsyncResource(RES_HEADERS_URL);
res_headers.put('data', function (error, content) {
do_check_eq(error, null);
do_check_eq(content, JSON.stringify({"content-type": "text/plain"}));
@ -478,7 +481,7 @@ add_test(function test_put_default_content_type() {
add_test(function test_post_default_content_type() {
_("POST: Content-Type defaults to text/plain");
let res_headers = new AsyncResource("http://localhost:8080/headers");
let res_headers = new AsyncResource(RES_HEADERS_URL);
res_headers.post('data', function (error, content) {
do_check_eq(error, null);
do_check_eq(content, JSON.stringify({"content-type": "text/plain"}));
@ -488,7 +491,7 @@ add_test(function test_post_default_content_type() {
add_test(function test_setHeader() {
_("setHeader(): setting simple header");
let res_headers = new AsyncResource("http://localhost:8080/headers");
let res_headers = new AsyncResource(RES_HEADERS_URL);
res_headers.setHeader('X-What-Is-Weave', 'awesome');
do_check_eq(res_headers.headers['x-what-is-weave'], 'awesome');
res_headers.get(function (error, content) {
@ -500,7 +503,7 @@ add_test(function test_setHeader() {
add_test(function test_setHeader_overwrite() {
_("setHeader(): setting multiple headers, overwriting existing header");
let res_headers = new AsyncResource("http://localhost:8080/headers");
let res_headers = new AsyncResource(RES_HEADERS_URL);
res_headers.setHeader('X-WHAT-is-Weave', 'more awesomer');
res_headers.setHeader('X-Another-Header', 'hello world');
do_check_eq(res_headers.headers['x-what-is-weave'], 'more awesomer');
@ -516,7 +519,7 @@ add_test(function test_setHeader_overwrite() {
add_test(function test_headers_object() {
_("Setting headers object");
let res_headers = new AsyncResource("http://localhost:8080/headers");
let res_headers = new AsyncResource(RES_HEADERS_URL);
res_headers.headers = {};
res_headers.get(function (error, content) {
do_check_eq(error, null);
@ -527,7 +530,7 @@ add_test(function test_headers_object() {
add_test(function test_put_override_content_type() {
_("PUT: override default Content-Type");
let res_headers = new AsyncResource("http://localhost:8080/headers");
let res_headers = new AsyncResource(RES_HEADERS_URL);
res_headers.setHeader('Content-Type', 'application/foobar');
do_check_eq(res_headers.headers['content-type'], 'application/foobar');
res_headers.put('data', function (error, content) {
@ -539,7 +542,7 @@ add_test(function test_put_override_content_type() {
add_test(function test_post_override_content_type() {
_("POST: override default Content-Type");
let res_headers = new AsyncResource("http://localhost:8080/headers");
let res_headers = new AsyncResource(RES_HEADERS_URL);
res_headers.setHeader('Content-Type', 'application/foobar');
res_headers.post('data', function (error, content) {
do_check_eq(error, null);

View File

@ -2,6 +2,8 @@ Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/resource.js");
Cu.import("resource://services-sync/service.js");
const TEST_GET_URL = "http://localhost:8080/1.1/johndoe/storage/meta/global";
function test_resource_user_agent() {
let meta_global = new ServerWBO('global');
@ -23,8 +25,8 @@ function test_resource_user_agent() {
"/1.1/johndoe/storage/meta/global": uaHandler(meta_global.handler()),
});
Weave.Service.serverURL = "http://localhost:8080/";
Weave.Service.clusterURL = "http://localhost:8080/";
Weave.Service.serverURL = TEST_SERVER_URL;
Weave.Service.clusterURL = TEST_CLUSTER_URL;
Weave.Service.username = "johndoe";
Weave.Service.password = "ilovejane";
@ -43,7 +45,7 @@ function test_resource_user_agent() {
function test_desktop_post(next) {
_("Testing direct Resource POST.");
let r = new AsyncResource("http://localhost:8080/1.1/johndoe/storage/meta/global");
let r = new AsyncResource(TEST_GET_URL);
r.post("foo=bar", function (error, content) {
_("User-Agent: " + ua);
do_check_eq(ua, expectedUA + ".desktop");
@ -55,7 +57,7 @@ function test_resource_user_agent() {
function test_desktop_get(next) {
_("Testing async.");
Svc.Prefs.set("client.type", "desktop");
let r = new AsyncResource("http://localhost:8080/1.1/johndoe/storage/meta/global");
let r = new AsyncResource(TEST_GET_URL);
r.get(function(error, content) {
_("User-Agent: " + ua);
do_check_eq(ua, expectedUA + ".desktop");
@ -67,7 +69,7 @@ function test_resource_user_agent() {
function test_mobile_get(next) {
_("Testing mobile.");
Svc.Prefs.set("client.type", "mobile");
let r = new AsyncResource("http://localhost:8080/1.1/johndoe/storage/meta/global");
let r = new AsyncResource(TEST_GET_URL);
r.get(function (error, content) {
_("User-Agent: " + ua);
do_check_eq(ua, expectedUA + ".mobile");

View File

@ -5,6 +5,8 @@ Cu.import("resource://services-sync/rest.js");
Cu.import("resource://services-sync/log4moz.js");
Cu.import("resource://gre/modules/NetUtil.jsm");
const TEST_RESOURCE_URL = TEST_SERVER_URL + "resource";
function run_test() {
Log4Moz.repository.getLogger("Sync.RESTRequest").level = Log4Moz.Level.Trace;
initTestLogging();
@ -89,7 +91,7 @@ add_test(function test_simple_get() {
let handler = httpd_handler(200, "OK", "Huzzah!");
let server = httpd_setup({"/resource": handler});
let uri = "http://localhost:8080/resource";
let uri = TEST_RESOURCE_URL;
let request = new RESTRequest(uri).get(function (error) {
do_check_eq(error, null);
@ -111,7 +113,7 @@ add_test(function test_get() {
let handler = httpd_handler(200, "OK", "Huzzah!");
let server = httpd_setup({"/resource": handler});
let request = new RESTRequest("http://localhost:8080/resource");
let request = new RESTRequest(TEST_RESOURCE_URL);
do_check_eq(request.status, request.NOT_SENT);
request.onProgress = request.onComplete = function () {
@ -160,7 +162,7 @@ add_test(function test_put() {
let handler = httpd_handler(200, "OK", "Got it!");
let server = httpd_setup({"/resource": handler});
let request = new RESTRequest("http://localhost:8080/resource");
let request = new RESTRequest(TEST_RESOURCE_URL);
do_check_eq(request.status, request.NOT_SENT);
request.onProgress = request.onComplete = function () {
@ -209,7 +211,7 @@ add_test(function test_post() {
let handler = httpd_handler(200, "OK", "Got it!");
let server = httpd_setup({"/resource": handler});
let request = new RESTRequest("http://localhost:8080/resource");
let request = new RESTRequest(TEST_RESOURCE_URL);
do_check_eq(request.status, request.NOT_SENT);
request.onProgress = request.onComplete = function () {
@ -258,7 +260,7 @@ add_test(function test_delete() {
let handler = httpd_handler(200, "OK", "Got it!");
let server = httpd_setup({"/resource": handler});
let request = new RESTRequest("http://localhost:8080/resource");
let request = new RESTRequest(TEST_RESOURCE_URL);
do_check_eq(request.status, request.NOT_SENT);
request.onProgress = request.onComplete = function () {
@ -304,7 +306,7 @@ add_test(function test_get_404() {
let handler = httpd_handler(404, "Not Found", "Cannae find it!");
let server = httpd_setup({"/resource": handler});
let request = new RESTRequest("http://localhost:8080/resource");
let request = new RESTRequest(TEST_RESOURCE_URL);
request.get(function (error) {
do_check_eq(error, null);
@ -330,7 +332,7 @@ add_test(function test_put_json() {
injson: "format",
number: 42
};
let request = new RESTRequest("http://localhost:8080/resource");
let request = new RESTRequest(TEST_RESOURCE_URL);
request.put(sample_data, function (error) {
do_check_eq(error, null);
@ -360,7 +362,7 @@ add_test(function test_post_json() {
injson: "format",
number: 42
};
let request = new RESTRequest("http://localhost:8080/resource");
let request = new RESTRequest(TEST_RESOURCE_URL);
request.post(sample_data, function (error) {
do_check_eq(error, null);
@ -384,7 +386,7 @@ add_test(function test_put_override_content_type() {
let handler = httpd_handler(200, "OK");
let server = httpd_setup({"/resource": handler});
let request = new RESTRequest("http://localhost:8080/resource");
let request = new RESTRequest(TEST_RESOURCE_URL);
request.setHeader("Content-Type", "application/lolcat");
request.put("O HAI!!1!", function (error) {
do_check_eq(error, null);
@ -409,7 +411,7 @@ add_test(function test_post_override_content_type() {
let handler = httpd_handler(200, "OK");
let server = httpd_setup({"/resource": handler});
let request = new RESTRequest("http://localhost:8080/resource");
let request = new RESTRequest(TEST_RESOURCE_URL);
request.setHeader("Content-Type", "application/lolcat");
request.post("O HAI!!1!", function (error) {
do_check_eq(error, null);
@ -439,7 +441,7 @@ add_test(function test_get_no_headers() {
"connection", "pragma", "cache-control",
"content-length"];
new RESTRequest("http://localhost:8080/resource").get(function (error) {
new RESTRequest(TEST_RESOURCE_URL).get(function (error) {
do_check_eq(error, null);
do_check_eq(this.response.status, 200);
@ -465,7 +467,7 @@ add_test(function test_changing_uri() {
let server = httpd_setup({"/resource": handler});
let request = new RESTRequest("http://localhost:8080/the-wrong-resource");
request.uri = Utils.makeURI("http://localhost:8080/resource");
request.uri = Utils.makeURI(TEST_RESOURCE_URL);
request.get(function (error) {
do_check_eq(error, null);
do_check_eq(this.response.status, 200);
@ -480,7 +482,7 @@ add_test(function test_request_setHeader() {
let handler = httpd_handler(200, "OK");
let server = httpd_setup({"/resource": handler});
let request = new RESTRequest("http://localhost:8080/resource");
let request = new RESTRequest(TEST_RESOURCE_URL);
request.setHeader("X-What-Is-Weave", "awesome");
request.setHeader("X-WHAT-is-Weave", "more awesomer");
@ -509,7 +511,7 @@ add_test(function test_response_headers() {
response.setStatusLine(request.httpVersion, 200, "OK");
}
let server = httpd_setup({"/resource": handler});
let request = new RESTRequest("http://localhost:8080/resource");
let request = new RESTRequest(TEST_RESOURCE_URL);
request.get(function (error) {
do_check_eq(error, null);
@ -529,7 +531,7 @@ add_test(function test_response_headers() {
* (e.g. NS_ERROR_CONNECTION_REFUSED).
*/
add_test(function test_connection_refused() {
let request = new RESTRequest("http://localhost:8080/resource");
let request = new RESTRequest(TEST_RESOURCE_URL);
request.onProgress = function onProgress() {
do_throw("Shouldn't have called request.onProgress()!");
};
@ -551,7 +553,7 @@ add_test(function test_abort() {
}
let server = httpd_setup({"/resource": handler});
let request = new RESTRequest("http://localhost:8080/resource");
let request = new RESTRequest(TEST_RESOURCE_URL);
// Aborting a request that hasn't been sent yet is pointless and will throw.
do_check_throws(function () {
@ -591,7 +593,7 @@ add_test(function test_timeout() {
};
server.start(8080);
let request = new RESTRequest("http://localhost:8080/resource");
let request = new RESTRequest(TEST_RESOURCE_URL);
request.timeout = 0.1; // 100 milliseconds
request.get(function (error) {
do_check_eq(error.result, Cr.NS_ERROR_NET_TIMEOUT);
@ -609,7 +611,7 @@ add_test(function test_exception_in_onProgress() {
let handler = httpd_handler(200, "OK", "Foobar");
let server = httpd_setup({"/resource": handler});
let request = new RESTRequest("http://localhost:8080/resource");
let request = new RESTRequest(TEST_RESOURCE_URL);
request.onProgress = function onProgress() {
it.does.not.exist();
};

View File

@ -46,7 +46,8 @@ function setUp() {
Service.username = "johndoe";
Service.password = "ilovejane";
Service.passphrase = "sekrit";
Service.clusterURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.clusterURL = TEST_CLUSTER_URL;
new FakeCryptoService();
}

View File

@ -26,7 +26,8 @@ add_test(function test_change_password() {
}
try {
Weave.Service.serverURL = "http://localhost:8080/";
Weave.Service.serverURL = TEST_SERVER_URL;
Weave.Service.clusterURL = TEST_CLUSTER_URL;
Weave.Service.username = "johndoe";
Weave.Service.password = "ilovejane";

View File

@ -12,7 +12,7 @@ function run_test() {
"/user/1.0/vuuf3eqgloxpxmzph27f5a6ve7gzlrms": httpd_handler(200, "OK", "1")
});
try {
Service.serverURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
_("A 404 will be recorded as 'generic-server-error'");
do_check_eq(Service.checkAccount("jimdoe"), "generic-server-error");

View File

@ -15,7 +15,7 @@ function test_findCluster() {
_("Test Service._findCluster()");
let server;
try {
Service.serverURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.username = "johndoe";
_("_findCluster() throws on network errors (e.g. connection refused).");
@ -73,7 +73,7 @@ function test_setCluster() {
"/user/1.0/jimdoe/node/weave": httpd_handler(200, "OK", "null")
});
try {
Service.serverURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.username = "johndoe";
_("Check initial state.");
@ -105,7 +105,7 @@ function test_updateCluster() {
"/user/1.0/janedoe/node/weave": httpd_handler(200, "OK", "http://weave.cluster.url/")
});
try {
Service.serverURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.username = "johndoe";
_("Check initial state.");

View File

@ -26,7 +26,7 @@ function run_test() {
"/user/1.0/vz6fhecgw5t3sgx3a4cektoiokyczkqd": send(500, "Server Error", "Server Error")
});
try {
Service.serverURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
_("Create an account.");
let res = Service.createAccount("john@doe.com", "mysecretpw",

View File

@ -63,8 +63,8 @@ add_test(function v4_upgrade() {
Status.resetSync();
_("Logging in.");
Weave.Service.serverURL = "http://localhost:8080/";
Weave.Service.clusterURL = "http://localhost:8080/";
Weave.Service.serverURL = TEST_SERVER_URL;
Weave.Service.clusterURL = TEST_CLUSTER_URL;
Weave.Service.login("johndoe", "ilovejane", passphrase);
do_check_true(Weave.Service.isLoggedIn);
@ -99,8 +99,8 @@ add_test(function v4_upgrade() {
_("Syncing afresh...");
Weave.Service.logout();
CollectionKeys.clear();
Weave.Service.serverURL = "http://localhost:8080/";
Weave.Service.clusterURL = "http://localhost:8080/";
Weave.Service.serverURL = TEST_SERVER_URL;
Weave.Service.clusterURL = TEST_CLUSTER_URL;
meta_global.payload = JSON.stringify({"syncID": "foooooooooooooobbbbbbbbbbbb",
"storageVersion": STORAGE_VERSION});
collections.meta = Date.now() / 1000;
@ -239,8 +239,8 @@ add_test(function v5_upgrade() {
Weave.Service.password = "ilovejane";
Weave.Service.passphrase = passphrase;
Weave.Service.serverURL = "http://localhost:8080/";
Weave.Service.clusterURL = "http://localhost:8080/";
Weave.Service.serverURL = TEST_SERVER_URL;
Weave.Service.clusterURL = TEST_CLUSTER_URL;
//
// Test an upgrade where the contents of the server would cause us to error

View File

@ -13,7 +13,8 @@ let collections = {steam: 65.11328,
function run_test() {
Service.username = "johndoe";
Service.password = "ilovejane";
Service.clusterURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.clusterURL = TEST_CLUSTER_URL;
Log4Moz.repository.getLogger("Sync.Service").level = Log4Moz.Level.Trace;
Log4Moz.repository.getLogger("Sync.StorageRequest").level = Log4Moz.Level.Trace;

View File

@ -39,8 +39,8 @@ add_test(function test_offline() {
});
function setup() {
Service.serverURL = "http://localhost:8080/";
Service.clusterURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.clusterURL = TEST_CLUSTER_URL;
let janeHelper = track_collections_helper();
let janeU = janeHelper.with_updated_collection;

View File

@ -65,7 +65,7 @@ function run_test() {
Service.username = "johndoe";
Service.password = JAPANESE;
Service.passphrase = "cantentsveryrelevantabbbb";
Service.serverURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
try {
_("Try to log in with the password.");

View File

@ -71,7 +71,9 @@ add_test(function test_removeClientData() {
Service.startOver();
do_check_false(engine.removed);
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
do_check_false(engine.removed);
Service.startOver();
do_check_true(engine.removed);

View File

@ -32,8 +32,8 @@ function run_test() {
try {
_("Set up test fixtures.");
Weave.Service.serverURL = "http://localhost:8080/";
Weave.Service.clusterURL = "http://localhost:8080/";
Weave.Service.serverURL = TEST_SERVER_URL;
Weave.Service.clusterURL = TEST_CLUSTER_URL;
Weave.Service.username = "johndoe";
Weave.Service.password = "ilovejane";
Weave.Service.passphrase = "foo";

View File

@ -61,8 +61,8 @@ function run_test() {
try {
_("Log in.");
Weave.Service.serverURL = "http://localhost:8080/";
Weave.Service.clusterURL = "http://localhost:8080/";
Weave.Service.serverURL = TEST_SERVER_URL;
Weave.Service.clusterURL = TEST_CLUSTER_URL;
_("Checking Status.sync with no credentials.");
Weave.Service.verifyAndFetchSymmetricKeys();
@ -77,8 +77,8 @@ function run_test() {
let syncKey = Weave.Service.passphrase;
Weave.Service.startOver();
Weave.Service.serverURL = "http://localhost:8080/";
Weave.Service.clusterURL = "http://localhost:8080/";
Weave.Service.serverURL = TEST_SERVER_URL;
Weave.Service.clusterURL = TEST_CLUSTER_URL;
Weave.Service.login("johndoe", "ilovejane", syncKey);
do_check_true(Weave.Service.isLoggedIn);

View File

@ -69,7 +69,8 @@ function setUp() {
Service.username = "johndoe";
Service.password = "ilovejane";
Service.passphrase = "abcdeabcdeabcdeabcdeabcdea";
Service.clusterURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.clusterURL = TEST_CLUSTER_URL;
// So that we can poke at meta/global.
new FakeCryptoService();

View File

@ -44,7 +44,7 @@ function run_test() {
});
try {
Service.serverURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
_("Force the initial state.");
Status.service = STATUS_OK;

View File

@ -29,7 +29,8 @@ FakeCollection.prototype = {
function setUpTestFixtures() {
let cryptoService = new FakeCryptoService();
Service.clusterURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.clusterURL = TEST_CLUSTER_URL;
Service.username = "johndoe";
Service.passphrase = "aabcdeabcdeabcdeabcdeabcde";
}

View File

@ -158,7 +158,8 @@ function test_resetClient() {
function test_wipeServer() {
_("SyncEngine.wipeServer deletes server data and resets the client.");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
let engine = makeSteamEngine();
const PAYLOAD = 42;

View File

@ -29,8 +29,8 @@ function createServerAndConfigureClient() {
};
const USER = "foo";
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", USER);
let server = new SyncServer();
@ -65,7 +65,8 @@ add_test(function test_syncStartup_emptyOrOutdatedGlobalsResetsSync() {
_("SyncEngine._syncStartup resets sync and wipes server data if there's no or an outdated global record");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
// Some server side data that's going to be wiped
@ -118,7 +119,8 @@ add_test(function test_syncStartup_serverHasNewerVersion() {
_("SyncEngine._syncStartup ");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
let global = new ServerWBO('global', {engines: {rotary: {version: 23456}}});
let server = httpd_setup({
@ -148,7 +150,8 @@ add_test(function test_syncStartup_syncIDMismatchResetsClient() {
_("SyncEngine._syncStartup resets sync if syncIDs don't match");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
let server = sync_httpd_setup({});
@ -185,7 +188,8 @@ add_test(function test_processIncoming_emptyServer() {
_("SyncEngine._processIncoming working with an empty server backend");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
let collection = new ServerCollection();
@ -210,7 +214,8 @@ add_test(function test_processIncoming_createFromServer() {
_("SyncEngine._processIncoming creates new records from server data");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
generateNewKeys();
@ -271,7 +276,8 @@ add_test(function test_processIncoming_reconcile() {
_("SyncEngine._processIncoming updates local records");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
let collection = new ServerCollection();
@ -590,7 +596,8 @@ add_test(function test_processIncoming_mobile_batchSize() {
_("SyncEngine._processIncoming doesn't fetch everything at once on mobile clients");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
Svc.Prefs.set("client.type", "mobile");
@ -659,7 +666,8 @@ add_test(function test_processIncoming_mobile_batchSize() {
add_test(function test_processIncoming_store_toFetch() {
_("If processIncoming fails in the middle of a batch on mobile, state is saved in toFetch and lastSync.");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
Svc.Prefs.set("client.type", "mobile");
@ -726,7 +734,8 @@ add_test(function test_processIncoming_store_toFetch() {
add_test(function test_processIncoming_resume_toFetch() {
_("toFetch and previousFailed items left over from previous syncs are fetched on the next sync, along with new items.");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
const LASTSYNC = Date.now() / 1000;
@ -794,7 +803,8 @@ add_test(function test_processIncoming_resume_toFetch() {
add_test(function test_processIncoming_applyIncomingBatchSize_smaller() {
_("Ensure that a number of incoming items less than applyIncomingBatchSize is still applied.");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
// Engine that doesn't like the first and last record it's given.
@ -848,7 +858,7 @@ add_test(function test_processIncoming_applyIncomingBatchSize_smaller() {
add_test(function test_processIncoming_applyIncomingBatchSize_multiple() {
_("Ensure that incoming items are applied according to applyIncomingBatchSize.");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
const APPLY_BATCH_SIZE = 10;
@ -900,7 +910,8 @@ add_test(function test_processIncoming_applyIncomingBatchSize_multiple() {
add_test(function test_processIncoming_notify_count() {
_("Ensure that failed records are reported only once.");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
const APPLY_BATCH_SIZE = 5;
@ -986,7 +997,8 @@ add_test(function test_processIncoming_notify_count() {
add_test(function test_processIncoming_previousFailed() {
_("Ensure that failed records are retried.");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
Svc.Prefs.set("client.type", "mobile");
@ -1071,7 +1083,8 @@ add_test(function test_processIncoming_previousFailed() {
add_test(function test_processIncoming_failed_records() {
_("Ensure that failed records from _reconcile and applyIncomingBatch are refetched.");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
// Let's create three and a bit batches worth of server side records.
@ -1205,7 +1218,8 @@ add_test(function test_processIncoming_decrypt_failed() {
_("Ensure that records failing to decrypt are either replaced or refetched.");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
// Some good and some bogus records. One doesn't contain valid JSON,
@ -1282,7 +1296,8 @@ add_test(function test_uploadOutgoing_toEmptyServer() {
_("SyncEngine._uploadOutgoing uploads new records to server");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
let collection = new ServerCollection();
collection._wbos.flying = new ServerWBO('flying');
@ -1340,7 +1355,8 @@ add_test(function test_uploadOutgoing_failed() {
_("SyncEngine._uploadOutgoing doesn't clear the tracker of objects that failed to upload.");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
let collection = new ServerCollection();
// We only define the "flying" WBO on the server, not the "scotsman"
@ -1402,7 +1418,8 @@ add_test(function test_uploadOutgoing_MAX_UPLOAD_RECORDS() {
_("SyncEngine._uploadOutgoing uploads in batches of MAX_UPLOAD_RECORDS");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
let collection = new ServerCollection();
@ -1473,7 +1490,8 @@ add_test(function test_syncFinish_deleteByIds() {
_("SyncEngine._syncFinish deletes server records slated for deletion (list of record IDs).");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
let collection = new ServerCollection();
collection._wbos.flying = new ServerWBO(
@ -1514,7 +1532,8 @@ add_test(function test_syncFinish_deleteLotsInBatches() {
_("SyncEngine._syncFinish deletes server records in batches of 100 (list of record IDs).");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
let collection = new ServerCollection();
@ -1585,7 +1604,8 @@ add_test(function test_sync_partialUpload() {
_("SyncEngine.sync() keeps changedIDs that couldn't be uploaded.");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
let collection = new ServerCollection();
@ -1658,7 +1678,8 @@ add_test(function test_sync_partialUpload() {
add_test(function test_canDecrypt_noCryptoKeys() {
_("SyncEngine.canDecrypt returns false if the engine fails to decrypt items on the server, e.g. due to a missing crypto key collection.");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
// Wipe CollectionKeys so we can test the desired scenario.
@ -1686,7 +1707,8 @@ add_test(function test_canDecrypt_noCryptoKeys() {
add_test(function test_canDecrypt_true() {
_("SyncEngine.canDecrypt returns true if the engine can decrypt the items on the server.");
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
// Set up CollectionKeys, as service.js does.
@ -1714,7 +1736,8 @@ add_test(function test_canDecrypt_true() {
add_test(function test_syncapplied_observer() {
let syncTesting = new SyncTestingInfrastructure();
Svc.Prefs.set("clusterURL", "http://localhost:8080/");
Svc.Prefs.set("serverURL", TEST_SERVER_URL);
Svc.Prefs.set("clusterURL", TEST_CLUSTER_URL);
Svc.Prefs.set("username", "foo");
const NUMBER_OF_RECORDS = 10;

View File

@ -52,7 +52,7 @@ function setUp() {
Service.username = "johndoe";
Service.password = "ilovejane";
Service.passphrase = "abcdeabcdeabcdeabcdeabcdea";
Service.clusterURL = "http://localhost:8080/";
Service.clusterURL = TEST_CLUSTER_URL;
generateNewKeys();
let serverKeys = CollectionKeys.asWBO("crypto", "keys");
@ -667,7 +667,7 @@ add_test(function test_no_sync_node() {
let server = sync_httpd_setup();
setUp();
Service.serverURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.sync();
do_check_eq(Status.sync, NO_SYNC_NODE_FOUND);
@ -852,8 +852,8 @@ add_test(function test_loginError_recoverable_reschedules() {
Service.username = "johndoe";
Service.password = "ilovejane";
Service.passphrase = "abcdeabcdeabcdeabcdeabcdea";
Service.serverURL = "http://localhost:8080/";
Service.clusterURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.clusterURL = TEST_CLUSTER_URL;
Service.persistLogin();
Status.resetSync(); // reset Status.login
@ -896,8 +896,8 @@ add_test(function test_loginError_fatal_clearsTriggers() {
Service.username = "johndoe";
Service.password = "ilovejane";
Service.passphrase = "abcdeabcdeabcdeabcdeabcdea";
Service.serverURL = "http://localhost:8080/";
Service.clusterURL = "http://localhost:8080/";
Service.serverURL = TEST_SERVER_URL;
Service.clusterURL = TEST_CLUSTER_URL;
Service.persistLogin();
Status.resetSync(); // reset Status.login

View File

@ -7,6 +7,8 @@ Cu.import("resource://services-sync/identity.js");
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/log4moz.js");
const STORAGE_REQUEST_RESOURCE_URL = TEST_SERVER_URL + "resource";
function run_test() {
Log4Moz.repository.getLogger("Sync.RESTRequest").level = Log4Moz.Level.Trace;
initTestLogging();
@ -22,7 +24,7 @@ add_test(function test_user_agent_desktop() {
" FxSync/" + WEAVE_VERSION + "." +
Services.appinfo.appBuildID + ".desktop";
let request = new SyncStorageRequest("http://localhost:8080/resource");
let request = new SyncStorageRequest(STORAGE_REQUEST_RESOURCE_URL);
request.onComplete = function onComplete(error) {
do_check_eq(error, null);
do_check_eq(this.response.status, 200);
@ -41,7 +43,7 @@ add_test(function test_user_agent_mobile() {
" FxSync/" + WEAVE_VERSION + "." +
Services.appinfo.appBuildID + ".mobile";
let request = new SyncStorageRequest("http://localhost:8080/resource");
let request = new SyncStorageRequest(STORAGE_REQUEST_RESOURCE_URL);
request.get(function (error) {
do_check_eq(error, null);
do_check_eq(this.response.status, 200);
@ -59,7 +61,7 @@ add_test(function test_auth() {
id.password = "ilovejane";
ID.set("WeaveID", id);
let request = new SyncStorageRequest("http://localhost:8080/resource");
let request = new SyncStorageRequest(STORAGE_REQUEST_RESOURCE_URL);
request.get(function (error) {
do_check_eq(error, null);
do_check_eq(this.response.status, 200);
@ -82,7 +84,7 @@ add_test(function test_weave_timestamp() {
let server = httpd_setup({"/resource": handler});
do_check_eq(SyncStorageRequest.serverTime, undefined);
let request = new SyncStorageRequest("http://localhost:8080/resource");
let request = new SyncStorageRequest(STORAGE_REQUEST_RESOURCE_URL);
request.get(function (error) {
do_check_eq(error, null);
do_check_eq(this.response.status, 200);
@ -108,7 +110,7 @@ add_test(function test_weave_backoff() {
backoffInterval = subject;
});
let request = new SyncStorageRequest("http://localhost:8080/resource");
let request = new SyncStorageRequest(STORAGE_REQUEST_RESOURCE_URL);
request.get(function (error) {
do_check_eq(error, null);
do_check_eq(this.response.status, 200);
@ -133,7 +135,7 @@ add_test(function test_weave_quota_notice() {
quotaValue = subject;
});
let request = new SyncStorageRequest("http://localhost:8080/resource");
let request = new SyncStorageRequest(STORAGE_REQUEST_RESOURCE_URL);
request.get(function (error) {
do_check_eq(error, null);
do_check_eq(this.response.status, 200);
@ -158,7 +160,7 @@ add_test(function test_weave_quota_error() {
}
Svc.Obs.add("weave:service:quota:remaining", onQuota);
let request = new SyncStorageRequest("http://localhost:8080/resource");
let request = new SyncStorageRequest(STORAGE_REQUEST_RESOURCE_URL);
request.get(function (error) {
do_check_eq(error, null);
do_check_eq(this.response.status, 400);
@ -177,7 +179,7 @@ add_test(function test_abort() {
}
let server = httpd_setup({"/resource": handler});
let request = new SyncStorageRequest("http://localhost:8080/resource");
let request = new SyncStorageRequest(STORAGE_REQUEST_RESOURCE_URL);
// Aborting a request that hasn't been sent yet is pointless and will throw.
do_check_throws(function () {