Bug 1064606 - Update FxAccountsManager tests with Principal. r=ferjm
authorSam Penrose <spenrose@mozilla.com>
Mon, 08 Sep 2014 16:32:10 -0700
changeset 204336 c2b0c3d348d474582f96d8417d4978a229c33ff8
parent 204335 94342d2b81e623dd1a6e0af3e3ec114b20dd506a
child 204337 1ecd31c5070b0cd483cb358eb9eae1ec03f9a156
child 204442 152ef25e89aeacb9cf1046dd926520fdbe407b85
push id48894
push userryanvm@gmail.com
push dateTue, 09 Sep 2014 22:04:24 +0000
treeherdermozilla-inbound@c2b0c3d348d4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersferjm
bugs1064606
milestone35.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 1064606 - Update FxAccountsManager tests with Principal. r=ferjm CLOSED TREE
services/fxaccounts/tests/xpcshell/test_manager.js
--- a/services/fxaccounts/tests/xpcshell/test_manager.js
+++ b/services/fxaccounts/tests/xpcshell/test_manager.js
@@ -11,16 +11,19 @@ Cu.import("resource://gre/modules/FxAcco
 Cu.import("resource://gre/modules/Promise.jsm");
 
 // === Mocks ===
 
 // Globals representing server state
 let passwordResetOnServer = false;
 let deletedOnServer = false;
 
+// Mock RP
+let principal = {origin: 'app://settings.gaiamobile.org', appId: 27}
+
 // Override FxAccountsUIGlue.
 const kFxAccountsUIGlueUUID = "{8f6d5d87-41ed-4bb5-aa28-625de57564c5}";
 const kFxAccountsUIGlueContractID =
   "@mozilla.org/fxaccounts/fxaccounts-ui-glue;1";
 
 // Save original FxAccountsUIGlue factory.
 const kFxAccountsUIGlueFactory =
   Cm.getClassObject(Cc[kFxAccountsUIGlueContractID], Ci.nsIFactory);
@@ -299,63 +302,63 @@ add_test(function(test_getAssertion_no_a
       run_next_test();
     }
   );
 });
 
 add_test(function(test_getAssertion_no_session_ui_error) {
   do_print("= getAssertion no session, UI error =");
   FxAccountsUIGlue._reject = true;
-  FxAccountsManager.getAssertion("audience").then(
+  FxAccountsManager.getAssertion("audience", principal).then(
     () => {
       do_throw("Unexpected success");
     },
     error => {
       do_check_eq(error.error, ERROR_UI_ERROR);
       do_check_eq(error.details, "error");
       FxAccountsUIGlue._reset();
       run_next_test();
     }
   );
 });
 
 add_test(function(test_getAssertion_no_session_ui_success) {
   do_print("= getAssertion no session, UI success =");
-  FxAccountsManager.getAssertion("audience").then(
+  FxAccountsManager.getAssertion("audience", principal).then(
     () => {
       do_throw("Unexpected success");
     },
     error => {
       do_check_true(FxAccountsUIGlue._signInFlowCalled);
       do_check_eq(error.error, ERROR_UNVERIFIED_ACCOUNT);
       FxAccountsUIGlue._reset();
       run_next_test();
     }
   );
 });
 
 add_test(function(test_getAssertion_active_session_unverified_account) {
   do_print("= getAssertion active session, unverified account =");
-  FxAccountsManager.getAssertion("audience").then(
+  FxAccountsManager.getAssertion("audience", principal).then(
     result => {
       do_throw("Unexpected success");
     },
     error => {
       do_check_false(FxAccountsUIGlue._signInFlowCalled);
       do_check_eq(error.error, ERROR_UNVERIFIED_ACCOUNT);
       run_next_test();
     }
   );
 });
 
 add_test(function(test_getAssertion_active_session_verified_account) {
   do_print("= getAssertion active session, verified account =");
   FxAccountsManager._fxAccounts._signedInUser.verified = true;
   FxAccountsManager._activeSession.verified = true;
-  FxAccountsManager.getAssertion("audience").then(
+  FxAccountsManager.getAssertion("audience", principal).then(
     result => {
       do_check_false(FxAccountsUIGlue._signInFlowCalled);
       do_check_eq(result, "assertion");
       FxAccountsManager._fxAccounts._reset();
       run_next_test();
     },
     error => {
       do_throw("Unexpected error: " + error);
@@ -370,17 +373,17 @@ add_test(function(test_getAssertion_refr
     email: "user@domain.org",
     verified: true,
     sessionToken: "1234"
   };
   FxAccountsManager._fxAccounts._signedInUser.verified = true;
   FxAccountsManager._activeSession.verified = true;
   FxAccountsManager._activeSession.authAt =
     (Date.now() / 1000) - gracePeriod;
-  FxAccountsManager.getAssertion("audience", {
+  FxAccountsManager.getAssertion("audience", principal, {
     "refreshAuthentication": gracePeriod
   }).then(
     result => {
       do_check_false(FxAccountsUIGlue._signInFlowCalled);
       do_check_true(FxAccountsUIGlue._refreshAuthCalled);
       do_check_eq(result, "assertion");
       FxAccountsManager._fxAccounts._reset();
       FxAccountsUIGlue._reset();
@@ -391,29 +394,29 @@ add_test(function(test_getAssertion_refr
     }
   );
 });
 
 add_test(function(test_getAssertion_server_state_change) {
   FxAccountsManager._fxAccounts._signedInUser.verified = true;
   FxAccountsManager._activeSession.verified = true;
   passwordResetOnServer = true;
-  FxAccountsManager.getAssertion("audience").then(
+  FxAccountsManager.getAssertion("audience", principal).then(
     (result) => {
       // For password reset, the UIGlue mock simulates sucessful
       // refreshAuth which supplies new password, not signin/signup.
       do_check_true(FxAccountsUIGlue._refreshAuthCalled);
       do_check_false(FxAccountsUIGlue._signInFlowCalled)
       do_check_eq(result, "assertion");
       FxAccountsUIGlue._refreshAuthCalled = false;
     }
   ).then(
     () => {
       deletedOnServer = true;
-      FxAccountsManager.getAssertion("audience").then(
+      FxAccountsManager.getAssertion("audience", principal).then(
         (result) => {
           // For account deletion, the UIGlue's signin/signup is called.
           do_check_true(FxAccountsUIGlue._signInFlowCalled)
           do_check_false(FxAccountsUIGlue._refreshAuthCalled);
           do_check_eq(result, "assertion");
           deletedOnServer = false;
           passwordResetOnServer = false;
           FxAccountsUIGlue._reset()
@@ -422,17 +425,17 @@ add_test(function(test_getAssertion_serv
       );
     }
   );
 });
 
 add_test(function(test_getAssertion_refreshAuth_NaN) {
   do_print("= getAssertion refreshAuth NaN=");
   let gracePeriod = "NaN";
-  FxAccountsManager.getAssertion("audience", {
+  FxAccountsManager.getAssertion("audience", principal, {
     "refreshAuthentication": gracePeriod
   }).then(
     result => {
       do_throw("Unexpected success");
     },
     error => {
       do_check_false(FxAccountsUIGlue._signInFlowCalled);
       do_check_false(FxAccountsUIGlue._refreshAuthCalled);
@@ -444,17 +447,17 @@ add_test(function(test_getAssertion_refr
 });
 
 add_test(function(test_getAssertion_refresh_auth_no_refresh) {
   do_print("= getAssertion refreshAuth no refresh =");
   FxAccountsManager._fxAccounts._signedInUser.verified = true;
   FxAccountsManager._activeSession.verified = true;
   FxAccountsManager._activeSession.authAt =
     (Date.now() / 1000) + 10000;
-  FxAccountsManager.getAssertion("audience", {
+  FxAccountsManager.getAssertion("audience", principal, {
     "refreshAuthentication": 1
   }).then(
     result => {
       do_check_false(FxAccountsUIGlue._signInFlowCalled);
       do_check_eq(result, "assertion");
       FxAccountsManager._fxAccounts._reset();
       run_next_test();
     },