From 1b46cf7c5490491c6a8de62a9dc0de4205f72769 Mon Sep 17 00:00:00 2001 From: Murali Date: Mon, 6 Feb 2012 09:50:11 -0800 Subject: [PATCH] Bug 720596 - Set both serverURL and clusterURL in test code; utilize constants; r=gps --- .../sync/tests/unit/test_bookmark_engine.js | 14 ++-- .../unit/test_bookmark_smart_bookmarks.js | 8 +- .../sync/tests/unit/test_clients_engine.js | 12 ++- .../tests/unit/test_collections_recovery.js | 4 +- services/sync/tests/unit/test_corrupt_keys.js | 4 +- services/sync/tests/unit/test_engine_abort.js | 3 +- services/sync/tests/unit/test_errorhandler.js | 82 +++++++++++++------ ...test_errorhandler_sync_checkServerError.js | 3 +- .../sync/tests/unit/test_history_engine.js | 3 +- services/sync/tests/unit/test_hmac_error.js | 4 +- .../sync/tests/unit/test_interval_triggers.js | 3 +- services/sync/tests/unit/test_jpakeclient.js | 2 +- .../sync/tests/unit/test_node_reassignment.js | 4 +- .../sync/tests/unit/test_resource_async.js | 35 ++++---- services/sync/tests/unit/test_resource_ua.js | 12 +-- services/sync/tests/unit/test_restrequest.js | 38 +++++---- .../sync/tests/unit/test_score_triggers.js | 3 +- .../tests/unit/test_service_changePassword.js | 3 +- .../tests/unit/test_service_checkAccount.js | 2 +- .../sync/tests/unit/test_service_cluster.js | 6 +- .../tests/unit/test_service_createAccount.js | 2 +- .../tests/unit/test_service_detect_upgrade.js | 12 +-- .../tests/unit/test_service_getStorageInfo.js | 3 +- .../sync/tests/unit/test_service_login.js | 4 +- .../tests/unit/test_service_passwordUTF8.js | 2 +- .../sync/tests/unit/test_service_startOver.js | 4 +- .../sync/tests/unit/test_service_sync_401.js | 4 +- .../unit/test_service_sync_remoteSetup.js | 8 +- .../test_service_sync_updateEnabledEngines.js | 3 +- .../tests/unit/test_service_verifyLogin.js | 2 +- .../tests/unit/test_service_wipeServer.js | 3 +- services/sync/tests/unit/test_syncengine.js | 3 +- .../sync/tests/unit/test_syncengine_sync.js | 73 +++++++++++------ .../sync/tests/unit/test_syncscheduler.js | 12 +-- .../tests/unit/test_syncstoragerequest.js | 18 ++-- 35 files changed, 238 insertions(+), 160 deletions(-) diff --git a/services/sync/tests/unit/test_bookmark_engine.js b/services/sync/tests/unit/test_bookmark_engine.js index f2f3c4db387..16221f3e9cb 100644 --- a/services/sync/tests/unit/test_bookmark_engine.js +++ b/services/sync/tests/unit/test_bookmark_engine.js @@ -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; diff --git a/services/sync/tests/unit/test_bookmark_smart_bookmarks.js b/services/sync/tests/unit/test_bookmark_smart_bookmarks.js index 70a44bbffa9..cc09259e16a 100644 --- a/services/sync/tests/unit/test_bookmark_smart_bookmarks.js +++ b/services/sync/tests/unit/test_bookmark_smart_bookmarks.js @@ -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"); diff --git a/services/sync/tests/unit/test_clients_engine.js b/services/sync/tests/unit/test_clients_engine.js index af16ee9314c..e889bf96f15 100644 --- a/services/sync/tests/unit/test_clients_engine.js +++ b/services/sync/tests/unit/test_clients_engine.js @@ -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(); diff --git a/services/sync/tests/unit/test_collections_recovery.js b/services/sync/tests/unit/test_collections_recovery.js index 14eba948608..d489ba41d1f 100644 --- a/services/sync/tests/unit/test_collections_recovery.js +++ b/services/sync/tests/unit/test_collections_recovery.js @@ -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"; diff --git a/services/sync/tests/unit/test_corrupt_keys.js b/services/sync/tests/unit/test_corrupt_keys.js index 905be67facb..05e0858b34f 100644 --- a/services/sync/tests/unit/test_corrupt_keys.js +++ b/services/sync/tests/unit/test_corrupt_keys.js @@ -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(); diff --git a/services/sync/tests/unit/test_engine_abort.js b/services/sync/tests/unit/test_engine_abort.js index 59cc180bf80..ab73cececa0 100644 --- a/services/sync/tests/unit/test_engine_abort.js +++ b/services/sync/tests/unit/test_engine_abort.js @@ -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(); diff --git a/services/sync/tests/unit/test_errorhandler.js b/services/sync/tests/unit/test_errorhandler.js index 666cbe4591f..d062e27d1bd 100644 --- a/services/sync/tests/unit/test_errorhandler.js +++ b/services/sync/tests/unit/test_errorhandler.js @@ -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) { diff --git a/services/sync/tests/unit/test_errorhandler_sync_checkServerError.js b/services/sync/tests/unit/test_errorhandler_sync_checkServerError.js index 9b926c08fad..a5c6c4dd989 100644 --- a/services/sync/tests/unit/test_errorhandler_sync_checkServerError.js +++ b/services/sync/tests/unit/test_errorhandler_sync_checkServerError.js @@ -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(); } diff --git a/services/sync/tests/unit/test_history_engine.js b/services/sync/tests/unit/test_history_engine.js index 1a352d6f90b..3d0c9eac207 100644 --- a/services/sync/tests/unit/test_history_engine.js +++ b/services/sync/tests/unit/test_history_engine.js @@ -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(); diff --git a/services/sync/tests/unit/test_hmac_error.js b/services/sync/tests/unit/test_hmac_error.js index 46605e16188..cb2475d44ff 100644 --- a/services/sync/tests/unit/test_hmac_error.js +++ b/services/sync/tests/unit/test_hmac_error.js @@ -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"; diff --git a/services/sync/tests/unit/test_interval_triggers.js b/services/sync/tests/unit/test_interval_triggers.js index 229629d56e4..9a35bf6bafe 100644 --- a/services/sync/tests/unit/test_interval_triggers.js +++ b/services/sync/tests/unit/test_interval_triggers.js @@ -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"); diff --git a/services/sync/tests/unit/test_jpakeclient.js b/services/sync/tests/unit/test_jpakeclient.js index a0aea74f0b6..36a478672a7 100644 --- a/services/sync/tests/unit/test_jpakeclient.js +++ b/services/sync/tests/unit/test_jpakeclient.js @@ -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); diff --git a/services/sync/tests/unit/test_node_reassignment.js b/services/sync/tests/unit/test_node_reassignment.js index c5f0a416f43..d61738279ea 100644 --- a/services/sync/tests/unit/test_node_reassignment.js +++ b/services/sync/tests/unit/test_node_reassignment.js @@ -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(); diff --git a/services/sync/tests/unit/test_resource_async.js b/services/sync/tests/unit/test_resource_async.js index d343d064e21..423ada72b24 100644 --- a/services/sync/tests/unit/test_resource_async.js +++ b/services/sync/tests/unit/test_resource_async.js @@ -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); diff --git a/services/sync/tests/unit/test_resource_ua.js b/services/sync/tests/unit/test_resource_ua.js index 5660ac8fa8e..1bfdd4c39c0 100644 --- a/services/sync/tests/unit/test_resource_ua.js +++ b/services/sync/tests/unit/test_resource_ua.js @@ -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"); diff --git a/services/sync/tests/unit/test_restrequest.js b/services/sync/tests/unit/test_restrequest.js index 78f6af56593..15d2e5f180d 100644 --- a/services/sync/tests/unit/test_restrequest.js +++ b/services/sync/tests/unit/test_restrequest.js @@ -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(); }; diff --git a/services/sync/tests/unit/test_score_triggers.js b/services/sync/tests/unit/test_score_triggers.js index 9d34d515362..b588a090aa0 100644 --- a/services/sync/tests/unit/test_score_triggers.js +++ b/services/sync/tests/unit/test_score_triggers.js @@ -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(); } diff --git a/services/sync/tests/unit/test_service_changePassword.js b/services/sync/tests/unit/test_service_changePassword.js index fc9858e62b7..d8463729b1e 100644 --- a/services/sync/tests/unit/test_service_changePassword.js +++ b/services/sync/tests/unit/test_service_changePassword.js @@ -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"; diff --git a/services/sync/tests/unit/test_service_checkAccount.js b/services/sync/tests/unit/test_service_checkAccount.js index f35e66c9066..d8bf4190067 100644 --- a/services/sync/tests/unit/test_service_checkAccount.js +++ b/services/sync/tests/unit/test_service_checkAccount.js @@ -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"); diff --git a/services/sync/tests/unit/test_service_cluster.js b/services/sync/tests/unit/test_service_cluster.js index 7e95e14fc34..6e641b5c709 100644 --- a/services/sync/tests/unit/test_service_cluster.js +++ b/services/sync/tests/unit/test_service_cluster.js @@ -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."); diff --git a/services/sync/tests/unit/test_service_createAccount.js b/services/sync/tests/unit/test_service_createAccount.js index 7cb18ce66a4..4bf12c4f2b2 100644 --- a/services/sync/tests/unit/test_service_createAccount.js +++ b/services/sync/tests/unit/test_service_createAccount.js @@ -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", diff --git a/services/sync/tests/unit/test_service_detect_upgrade.js b/services/sync/tests/unit/test_service_detect_upgrade.js index b120e6a90d1..3101fa5091c 100644 --- a/services/sync/tests/unit/test_service_detect_upgrade.js +++ b/services/sync/tests/unit/test_service_detect_upgrade.js @@ -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 diff --git a/services/sync/tests/unit/test_service_getStorageInfo.js b/services/sync/tests/unit/test_service_getStorageInfo.js index 74c265e32d9..c13a088edc0 100644 --- a/services/sync/tests/unit/test_service_getStorageInfo.js +++ b/services/sync/tests/unit/test_service_getStorageInfo.js @@ -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; diff --git a/services/sync/tests/unit/test_service_login.js b/services/sync/tests/unit/test_service_login.js index 7cd3f07c0c4..d6dd3d0a451 100644 --- a/services/sync/tests/unit/test_service_login.js +++ b/services/sync/tests/unit/test_service_login.js @@ -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; diff --git a/services/sync/tests/unit/test_service_passwordUTF8.js b/services/sync/tests/unit/test_service_passwordUTF8.js index b2854a45f41..e98afdaaf34 100644 --- a/services/sync/tests/unit/test_service_passwordUTF8.js +++ b/services/sync/tests/unit/test_service_passwordUTF8.js @@ -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."); diff --git a/services/sync/tests/unit/test_service_startOver.js b/services/sync/tests/unit/test_service_startOver.js index 813f89129db..29c3938c52f 100644 --- a/services/sync/tests/unit/test_service_startOver.js +++ b/services/sync/tests/unit/test_service_startOver.js @@ -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); diff --git a/services/sync/tests/unit/test_service_sync_401.js b/services/sync/tests/unit/test_service_sync_401.js index c4d4b17d36f..56e74e15620 100644 --- a/services/sync/tests/unit/test_service_sync_401.js +++ b/services/sync/tests/unit/test_service_sync_401.js @@ -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"; diff --git a/services/sync/tests/unit/test_service_sync_remoteSetup.js b/services/sync/tests/unit/test_service_sync_remoteSetup.js index 511f0b73205..319d694fec2 100644 --- a/services/sync/tests/unit/test_service_sync_remoteSetup.js +++ b/services/sync/tests/unit/test_service_sync_remoteSetup.js @@ -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); diff --git a/services/sync/tests/unit/test_service_sync_updateEnabledEngines.js b/services/sync/tests/unit/test_service_sync_updateEnabledEngines.js index 598633b3c32..21afe4042c6 100644 --- a/services/sync/tests/unit/test_service_sync_updateEnabledEngines.js +++ b/services/sync/tests/unit/test_service_sync_updateEnabledEngines.js @@ -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(); diff --git a/services/sync/tests/unit/test_service_verifyLogin.js b/services/sync/tests/unit/test_service_verifyLogin.js index 94c75fee732..76c2a471d4e 100644 --- a/services/sync/tests/unit/test_service_verifyLogin.js +++ b/services/sync/tests/unit/test_service_verifyLogin.js @@ -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; diff --git a/services/sync/tests/unit/test_service_wipeServer.js b/services/sync/tests/unit/test_service_wipeServer.js index c91cc5041d7..6a4eb170a87 100644 --- a/services/sync/tests/unit/test_service_wipeServer.js +++ b/services/sync/tests/unit/test_service_wipeServer.js @@ -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"; } diff --git a/services/sync/tests/unit/test_syncengine.js b/services/sync/tests/unit/test_syncengine.js index 7db36cb51ab..b828df22799 100644 --- a/services/sync/tests/unit/test_syncengine.js +++ b/services/sync/tests/unit/test_syncengine.js @@ -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; diff --git a/services/sync/tests/unit/test_syncengine_sync.js b/services/sync/tests/unit/test_syncengine_sync.js index 5ab9c04045d..476300797a5 100644 --- a/services/sync/tests/unit/test_syncengine_sync.js +++ b/services/sync/tests/unit/test_syncengine_sync.js @@ -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; diff --git a/services/sync/tests/unit/test_syncscheduler.js b/services/sync/tests/unit/test_syncscheduler.js index 2bad8597513..1a2159cc4e9 100644 --- a/services/sync/tests/unit/test_syncscheduler.js +++ b/services/sync/tests/unit/test_syncscheduler.js @@ -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 diff --git a/services/sync/tests/unit/test_syncstoragerequest.js b/services/sync/tests/unit/test_syncstoragerequest.js index 6f29125a15a..3374e3cba3f 100644 --- a/services/sync/tests/unit/test_syncstoragerequest.js +++ b/services/sync/tests/unit/test_syncstoragerequest.js @@ -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 () {