Bug 1635937 - Enable 'identity.sync.useOAuthForSyncToken' pref for Nightly users r=rfkelly
authorVlad Filippov <vlad.filippov@gmail.com>
Tue, 19 May 2020 21:32:50 +0000
changeset 530899 c5016a961cb54dc2510571bef6acc98a57d897dd
parent 530898 01bf5f7b070ae18840f3e579c3208af40add2aa4
child 530900 97079b757b57d21c17f3690d13efb625c8079c89
push id37434
push userabutkovits@mozilla.com
push dateWed, 20 May 2020 10:05:10 +0000
treeherdermozilla-central@005ef1c25992 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrfkelly
bugs1635937
milestone78.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1635937 - Enable 'identity.sync.useOAuthForSyncToken' pref for Nightly users r=rfkelly Differential Revision: https://phabricator.services.mozilla.com/D75130
browser/app/profile/firefox.js
services/sync/modules-testing/utils.js
services/sync/tests/unit/test_fxa_node_reassignment.js
services/sync/tests/unit/test_node_reassignment.js
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1435,17 +1435,22 @@ pref("identity.fxaccounts.pairing.enable
 
 // The remote URI of the FxA pairing server
 pref("identity.fxaccounts.remote.pairing.uri", "wss://channelserver.services.mozilla.com");
 
 // Token server used by the FxA Sync identity.
 pref("identity.sync.tokenserver.uri", "https://token.services.mozilla.com/1.0/sync/1.5");
 
 // Fetch Sync tokens using the OAuth token function
-pref("identity.sync.useOAuthForSyncToken", false);
+#ifdef NIGHTLY_BUILD
+  // Only enabled in Nightly to avoid excessive / abnormal traffic to FxA
+  pref("identity.sync.useOAuthForSyncToken", true);
+#else
+  pref("identity.sync.useOAuthForSyncToken", false);
+#endif
 
 // Auto-config URL for FxA self-hosters, makes an HTTP request to
 // [identity.fxaccounts.autoconfig.uri]/.well-known/fxa-client-configuration
 // This is now the prefered way of pointing to a custom FxA server, instead
 // of making changes to "identity.fxaccounts.*.uri".
 pref("identity.fxaccounts.autoconfig.uri", "");
 
 // URL for help link about Send Tab.
--- a/services/sync/modules-testing/utils.js
+++ b/services/sync/modules-testing/utils.js
@@ -195,16 +195,28 @@ var makeFxAccountsInternalMock = functio
       let storageManager = new MockFxaStorageManager();
       storageManager.initialize(config.fxaccount.user);
       let accountState = new AccountState(storageManager);
       return accountState;
     },
     _getAssertion(audience) {
       return Promise.resolve(config.fxaccount.user.assertion);
     },
+    getOAuthToken: () => Promise.resolve("some-access-token"),
+    keys: {
+      getScopedKeys: () =>
+        Promise.resolve({
+          "https://identity.mozilla.com/apps/oldsync": {
+            identifier: "https://identity.mozilla.com/apps/oldsync",
+            keyRotationSecret:
+              "0000000000000000000000000000000000000000000000000000000000000000",
+            keyRotationTimestamp: 1510726317123,
+          },
+        }),
+    },
     profile: {
       getProfile() {
         return null;
       },
     },
   };
 };
 
--- a/services/sync/tests/unit/test_fxa_node_reassignment.js
+++ b/services/sync/tests/unit/test_fxa_node_reassignment.js
@@ -79,16 +79,34 @@ function prepareServer(cbAfterTokenFetch
           _(`test server saw token fetch - endpoint now ${token.endpoint}`);
           numTokenRequests += 1;
           res(token);
           if (cbAfterTokenFetch) {
             cbAfterTokenFetch();
           }
         });
       },
+      getTokenFromOAuthToken() {
+        return new Promise(res => {
+          // Build a new URL with trailing zeros for the SYNC_VERSION part - this
+          // will still be seen as equivalent by the test server, but different
+          // by sync itself.
+          numReassigns += 1;
+          let trailingZeros = new Array(numReassigns + 1).join("0");
+          let token = config.fxaccount.token;
+          token.endpoint = server.baseURI + "1.1" + trailingZeros + "/johndoe";
+          token.uid = config.username;
+          _(`test server saw token fetch - endpoint now ${token.endpoint}`);
+          numTokenRequests += 1;
+          res(token);
+          if (cbAfterTokenFetch) {
+            cbAfterTokenFetch();
+          }
+        });
+      },
     };
     return server;
   });
 }
 
 function getReassigned() {
   try {
     return Services.prefs.getBoolPref("services.sync.lastSyncReassigned");
--- a/services/sync/tests/unit/test_node_reassignment.js
+++ b/services/sync/tests/unit/test_node_reassignment.js
@@ -77,16 +77,20 @@ async function syncAndExpectNodeReassign
 
   let getTokenCount = 0;
   let mockTSC = {
     // TokenServerClient
     async getTokenFromBrowserIDAssertion(uri, assertion) {
       getTokenCount++;
       return { endpoint: server.baseURI + "1.1/johndoe/" };
     },
+    async getTokenFromOAuthToken() {
+      getTokenCount++;
+      return { endpoint: server.baseURI + "1.1/johndoe/" };
+    },
   };
   Service.identity._tokenServerClient = mockTSC;
 
   // Make sure that it works!
   let request = new RESTRequest(url);
   let response = await request.get();
   Assert.equal(response.status, 401);
 
@@ -289,16 +293,20 @@ add_task(async function test_loop_avoida
 
   let getTokenCount = 0;
   let mockTSC = {
     // TokenServerClient
     async getTokenFromBrowserIDAssertion(uri, assertion) {
       getTokenCount++;
       return { endpoint: server.baseURI + "1.1/johndoe/" };
     },
+    async getTokenFromOAuthToken() {
+      getTokenCount++;
+      return { endpoint: server.baseURI + "1.1/johndoe/" };
+    },
   };
   Service.identity._tokenServerClient = mockTSC;
 
   // Track the time. We want to make sure the duration between the first and
   // second sync is small, and then that the duration between second and third
   // is set to be large.
   let now;
 
@@ -387,16 +395,20 @@ add_task(async function test_loop_avoida
 
   let getTokenCount = 0;
   let mockTSC = {
     // TokenServerClient
     getTokenFromBrowserIDAssertion(uri, assertion) {
       getTokenCount++;
       return { endpoint: server.baseURI + "1.1/johndoe/" };
     },
+    async getTokenFromOAuthToken() {
+      getTokenCount++;
+      return { endpoint: server.baseURI + "1.1/johndoe/" };
+    },
   };
   Service.identity._tokenServerClient = mockTSC;
 
   // We need the server to be correctly set up prior to experimenting. Do this
   // through a sync.
   let global = {
     syncID: Service.syncID,
     storageVersion: STORAGE_VERSION,