Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'dev' of github.com:mozilla/browserid into dev

  • Loading branch information...
commit 350636a2369fdb02ef0f4a5f64d666bc8a4534c6 2 parents c82698a + dced8e2
@ozten ozten authored
View
2  package.json
@@ -9,7 +9,7 @@
"connect": "1.7.2",
"convict": "0.0.6",
"cjson": "0.0.6",
- "client-sessions": "https://github.com/downloads/lloyd/node-client-sessions/d5f06c5.tgz",
+ "client-sessions": "0.0.6",
"connect-cachify": "0.0.9",
"connect-cookie-session": "0.0.2",
"connect-logger-statsd": "0.0.1",
View
12 resources/static/dialog/controllers/check_registration.js
@@ -18,12 +18,13 @@ BrowserID.Modules.CheckRegistration = (function() {
options.required = !!options.required;
self.renderWait("confirm_email", options);
+
self.email = options.email;
self.verifier = options.verifier;
self.verificationMessage = options.verificationMessage;
+ self.required = options.required;
self.click("#back", self.back);
- self.click("#cancel", self.cancel);
Module.sc.start.call(self, options);
},
@@ -46,16 +47,9 @@ BrowserID.Modules.CheckRegistration = (function() {
},
back: function() {
- // XXX this should change to cancelEmailValidation for email, but this
- // will work.
user.cancelUserValidation();
- this.close("cancel_state");
- },
-
- cancel: function() {
- this.close("cancel");
+ this.publish(this.required ? "cancel" : "cancel_state");
}
-
});
return Module;
View
20 resources/static/dialog/resources/state.js
@@ -249,15 +249,17 @@ BrowserID.State = (function() {
handleState("assertion_generated", function(msg, info) {
self.success = true;
if (info.assertion !== null) {
- if (storage.usersComputer.shouldAsk(network.userid())) {
- // We have to confirm the user's status
- self.assertion_info = info;
- redirectToState("is_this_your_computer", info);
- }
- else {
- storage.setLoggedIn(user.getOrigin(), self.email);
- startAction("doAssertionGenerated", { assertion: info.assertion, email: self.email });
- }
+ user.shouldAskIfUsersComputer(function(shouldAsk) {
+ if (shouldAsk) {
+ // We have to confirm the user's status
+ self.assertion_info = info;
+ redirectToState("is_this_your_computer", info);
+ }
+ else {
+ storage.setLoggedIn(user.getOrigin(), self.email);
+ startAction("doAssertionGenerated", { assertion: info.assertion, email: self.email });
+ }
+ });
}
else {
redirectToState("pick_email");
View
4 resources/static/dialog/views/confirm_email.ejs
@@ -15,9 +15,9 @@
<p>
<% if(required) { %>
- <%= gettext('If this is a mistake, just ignore the sent email and <a href="#" id="cancel">cancel</a>.') %>
+ <%= format(gettext('If this is a mistake, just ignore the sent email and <a %s>cancel</a>.'), [' href="#" id="back"']) %>
<% } else { %>
- <%= gettext('If this is a mistake, just ignore the sent email and <a href="#" id="back">use another email address</a>.') %>
+ <%= format(gettext('If this is a mistake, just ignore the sent email and <a %s>use another email address</a>.'), [' href="#" id="back"']) %>
<% } %>
</p>
View
32 resources/static/shared/user.js
@@ -15,7 +15,8 @@ BrowserID.User = (function() {
provisioning = bid.Provisioning,
addressCache = {},
primaryAuthCache = {},
- complete = bid.Helpers.complete;
+ complete = bid.Helpers.complete,
+ registrationComplete = false;
function prepareDeps() {
if (!jwk) {
@@ -130,6 +131,11 @@ BrowserID.User = (function() {
addressCache[email].known = true;
}
+ // registrationComplete is used in shouldAskIfUsersComputer to
+ // prevent the user from seeing the "is this your computer" screen if
+ // they just completed a registration.
+ registrationComplete = true;
+
if (onSuccess) {
onSuccess(status);
}
@@ -220,11 +226,13 @@ BrowserID.User = (function() {
if (config.provisioning) {
provisioning = config.provisioning;
}
+
},
reset: function() {
provisioning = BrowserID.Provisioning;
User.resetCaches();
+ registrationComplete = false;
},
resetCaches: function() {
@@ -1152,6 +1160,10 @@ BrowserID.User = (function() {
}
},
+ /**
+ * Check if the user owns the computer
+ * @method isUsersComputer
+ */
isUsersComputer: function(onComplete, onFailure) {
var userID = network.userid();
if(typeof userID !== "undefined") {
@@ -1159,7 +1171,25 @@ BrowserID.User = (function() {
} else {
complete(onFailure, "user is not authenticated");
}
+ },
+
+ /**
+ * Check whether the user should be asked if this is their computer
+ * @method shouldAskIfUsersComputer
+ */
+ shouldAskIfUsersComputer: function(onComplete, onFailure) {
+ var userID = network.userid();
+ if(typeof userID !== "undefined") {
+ // A user should never be asked if they completed an email
+ // registration/validation in this dialog session.
+ var shouldAsk = storage.usersComputer.shouldAsk(userID)
+ && !registrationComplete;
+ complete(onComplete, shouldAsk);
+ } else {
+ complete(onFailure, "user is not authenticated");
+ }
+ return shouldAsk;
}
};
View
13 resources/static/test/cases/controllers/check_registration.js
@@ -13,12 +13,13 @@
testHelpers = bid.TestHelpers,
register = testHelpers.register;
- function createController(verifier, message) {
+ function createController(verifier, message, required) {
controller = bid.Modules.CheckRegistration.create();
controller.start({
email: "registered@testuser.com",
verifier: verifier,
- verificationMessage: message
+ verificationMessage: message,
+ required: required
});
}
@@ -76,7 +77,7 @@
});
});
- asyncTest("back - raise cancel_state", function() {
+ asyncTest("back for normal account creation/email addition - raise cancel_state", function() {
createController("waitForUserValidation", "user_verified");
controller.startCheck(function() {
register("cancel_state", function() {
@@ -87,14 +88,14 @@
});
});
- asyncTest("cancel - raise cancel", function() {
- createController("waitForUserValidation", "user_verified");
+ asyncTest("back for required email - raise cancel", function() {
+ createController("waitForUserValidation", "user_verified", true);
controller.startCheck(function() {
register("cancel", function() {
ok(true, "cancel is triggered");
start();
});
- controller.cancel();
+ controller.back();
});
});
View
135 resources/static/test/cases/shared/user.js
@@ -1,5 +1,5 @@
/*jshint browsers:true, forin: true, laxbreak: true */
-/*global test: true, start: true, module: true, ok: true, equal: true, BrowserID: true */
+/*global test: true, start: true, module: true, ok: true, equal: true, strictEqual: true, BrowserID: true */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@@ -17,7 +17,8 @@ var vep = require("./vep");
testHelpers = bid.TestHelpers,
testOrigin = testHelpers.testOrigin,
failureCheck = testHelpers.failureCheck,
- provisioning = bid.Mocks.Provisioning
+ provisioning = bid.Mocks.Provisioning,
+ TEST_EMAIL = "testuser@testuser.com";
// I generated these locally, they are used nowhere else.
var pubkey = {"algorithm":"RS","n":"56063028070432982322087418176876748072035482898334811368408525596198252519267108132604198004792849077868951906170812540713982954653810539949384712773390200791949565903439521424909576832418890819204354729217207360105906039023299561374098942789996780102073071760852841068989860403431737480182725853899733706069","e":"65537"};
@@ -104,8 +105,8 @@ var vep = require("./vep");
});
asyncTest("getStoredEmailKeypair with known key - return identity", function() {
- lib.syncEmailKeypair("testuser@testuser.com", function() {
- var identity = lib.getStoredEmailKeypair("testuser@testuser.com");
+ lib.syncEmailKeypair(TEST_EMAIL, function() {
+ var identity = lib.getStoredEmailKeypair(TEST_EMAIL);
ok(identity, "we have an identity");
start();
@@ -113,7 +114,7 @@ var vep = require("./vep");
});
test("getStoredEmailKeypair with unknown key", function() {
- var identity = lib.getStoredEmailKeypair("testuser@testuser.com");
+ var identity = lib.getStoredEmailKeypair(TEST_EMAIL);
equal(typeof identity, "undefined", "identity is undefined for unknown key");
});
@@ -132,7 +133,7 @@ var vep = require("./vep");
});
asyncTest("createSecondaryUser", function() {
- lib.createSecondaryUser("testuser@testuser.com", function(status) {
+ lib.createSecondaryUser(TEST_EMAIL, function(status) {
ok(status, "user created");
start();
}, testHelpers.unexpectedXHRFailure);
@@ -141,14 +142,14 @@ var vep = require("./vep");
asyncTest("createSecondaryUser with user creation refused", function() {
xhr.useResult("throttle");
- lib.createSecondaryUser("testuser@testuser.com", function(status) {
+ lib.createSecondaryUser(TEST_EMAIL, function(status) {
equal(status, false, "user creation refused");
start();
}, testHelpers.unexpectedXHRFailure);
});
asyncTest("createSecondaryUser with XHR failure", function() {
- failureCheck(lib.createSecondaryUser, "testuser@testuser.com");
+ failureCheck(lib.createSecondaryUser, TEST_EMAIL);
});
asyncTest("createUser with unknown secondary happy case - expect 'secondary.verify'", function() {
@@ -252,7 +253,7 @@ var vep = require("./vep");
asyncTest("primaryUserAuthenticationInfo, user authenticated to IdP, expect keypair, cert, authenticated status", function() {
provisioning.setStatus(provisioning.AUTHENTICATED);
- lib.primaryUserAuthenticationInfo("testuser@testuser.com", {},
+ lib.primaryUserAuthenticationInfo(TEST_EMAIL, {},
function(info) {
equal(info.authenticated, true, "user is authenticated");
ok(info.keypair, "keypair passed");
@@ -266,7 +267,7 @@ var vep = require("./vep");
asyncTest("primaryUserAuthenticationInfo, user not authenticated to IdP, expect false authenticated status", function() {
provisioning.setStatus(provisioning.NOT_AUTHENTICATED);
- lib.primaryUserAuthenticationInfo("testuser@testuser.com", {},
+ lib.primaryUserAuthenticationInfo(TEST_EMAIL, {},
function(info) {
equal(info.authenticated, false, "user is not authenticated");
start();
@@ -279,7 +280,7 @@ var vep = require("./vep");
provisioning.setFailure("failure");
lib.primaryUserAuthenticationInfo(
- "testuser@testuser.com",
+ TEST_EMAIL,
{},
testHelpers.unexpectedSuccess,
testHelpers.expectedXHRFailure
@@ -289,7 +290,7 @@ var vep = require("./vep");
asyncTest("isUserAuthenticatedToPrimary with authed user, expect true status", function() {
provisioning.setStatus(provisioning.AUTHENTICATED);
- lib.isUserAuthenticatedToPrimary("testuser@testuser.com", {},
+ lib.isUserAuthenticatedToPrimary(TEST_EMAIL, {},
function(status) {
equal(status, true, "user is authenticated, correct status");
start();
@@ -301,7 +302,7 @@ var vep = require("./vep");
asyncTest("isUserAuthenticatedToPrimary with non-authed user, expect false status", function() {
provisioning.setStatus(provisioning.NOT_AUTHENTICATED);
- lib.isUserAuthenticatedToPrimary("testuser@testuser.com", {},
+ lib.isUserAuthenticatedToPrimary(TEST_EMAIL, {},
function(status) {
equal(status, false, "user is not authenticated, correct status");
start();
@@ -313,7 +314,7 @@ var vep = require("./vep");
asyncTest("isUserAuthenticatedToPrimary with failure", function() {
provisioning.setFailure("failure");
- lib.isUserAuthenticatedToPrimary("testuser@testuser.com", {},
+ lib.isUserAuthenticatedToPrimary(TEST_EMAIL, {},
testHelpers.unexpectedSuccess,
testHelpers.expectedXHRFailure
);
@@ -397,7 +398,7 @@ var vep = require("./vep");
storage.setStagedOnBehalfOf(testOrigin);
lib.tokenInfo("token", function(info) {
- equal(info.email, "testuser@testuser.com", "correct email");
+ equal(info.email, TEST_EMAIL, "correct email");
equal(info.origin, testOrigin, "correct origin");
start();
}, testHelpers.unexpectedXHRFailure);
@@ -405,7 +406,7 @@ var vep = require("./vep");
asyncTest("tokenInfo with a bad token without site info, no site in results", function() {
lib.tokenInfo("token", function(info) {
- equal(info.email, "testuser@testuser.com", "correct email");
+ equal(info.email, TEST_EMAIL, "correct email");
equal(typeof info.origin, "undefined", "origin is undefined");
start();
}, testHelpers.unexpectedXHRFailure);
@@ -421,7 +422,7 @@ var vep = require("./vep");
lib.verifyUser("token", "password", function onSuccess(info) {
ok(info.valid, "token was valid");
- equal(info.email, "testuser@testuser.com", "email part of info");
+ equal(info.email, TEST_EMAIL, "email part of info");
equal(info.origin, testOrigin, "origin in info");
equal(storage.getStagedOnBehalfOf(), "", "initiating origin was removed");
@@ -450,7 +451,7 @@ var vep = require("./vep");
});
asyncTest("canSetPassword with only primary addresses - expect false", function() {
- storage.addEmail("testuser@testuser.com", { type: "primary" });
+ storage.addEmail(TEST_EMAIL, { type: "primary" });
lib.canSetPassword(function(status) {
equal(false, status, "status is false with user with only primaries");
@@ -459,7 +460,7 @@ var vep = require("./vep");
});
asyncTest("canSetPassword with secondary addresses - expect true", function() {
- storage.addEmail("testuser@testuser.com", { type: "secondary" });
+ storage.addEmail(TEST_EMAIL, { type: "secondary" });
lib.canSetPassword(function(status) {
equal(true, status, "status is true with user with secondaries");
@@ -518,7 +519,7 @@ var vep = require("./vep");
asyncTest("authenticate with valid credentials, also syncs email with server", function() {
- lib.authenticate("testuser@testuser.com", "testuser", function(authenticated) {
+ lib.authenticate(TEST_EMAIL, "testuser", function(authenticated) {
equal(true, authenticated, "we are authenticated!");
var emails = lib.getStoredEmailKeypairs();
equal(_.size(emails) > 0, true, "emails have been synced to server");
@@ -529,7 +530,7 @@ var vep = require("./vep");
asyncTest("authenticate with invalid credentials", function() {
xhr.useResult("invalid");
- lib.authenticate("testuser@testuser.com", "testuser", function onComplete(authenticated) {
+ lib.authenticate(TEST_EMAIL, "testuser", function onComplete(authenticated) {
equal(false, authenticated, "invalid authentication.");
start();
}, testHelpers.unexpectedXHRFailure);
@@ -537,7 +538,7 @@ var vep = require("./vep");
asyncTest("authenticate with XHR failure", function() {
- failureCheck(lib.authenticate, "testuser@testuser.com", "testuser");
+ failureCheck(lib.authenticate, TEST_EMAIL, "testuser");
});
@@ -717,7 +718,7 @@ var vep = require("./vep");
lib.verifyEmailNoPassword("token", function onSuccess(info) {
ok(info.valid, "token was valid");
- equal(info.email, "testuser@testuser.com", "email part of info");
+ equal(info.email, TEST_EMAIL, "email part of info");
equal(info.origin, testOrigin, "origin in info");
equal(storage.getStagedOnBehalfOf(), "", "initiating origin was removed");
@@ -750,7 +751,7 @@ var vep = require("./vep");
lib.verifyEmailWithPassword("token", "password", function onSuccess(info) {
ok(info.valid, "token was valid");
- equal(info.email, "testuser@testuser.com", "email part of info");
+ equal(info.email, TEST_EMAIL, "email part of info");
equal(info.origin, testOrigin, "origin in info");
equal(storage.getStagedOnBehalfOf(), "", "initiating origin was removed");
@@ -853,17 +854,17 @@ var vep = require("./vep");
asyncTest("syncEmails with no pre-loaded identities and identities to add", function() {
lib.syncEmails(function onSuccess() {
var identities = lib.getStoredEmailKeypairs();
- ok("testuser@testuser.com" in identities, "Our new email is added");
+ ok(TEST_EMAIL in identities, "Our new email is added");
equal(_.size(identities), 1, "there is one identity");
start();
}, testHelpers.unexpectedXHRFailure);
});
asyncTest("syncEmails with identities preloaded and none to add", function() {
- storage.addEmail("testuser@testuser.com", {});
+ storage.addEmail(TEST_EMAIL, {});
lib.syncEmails(function onSuccess() {
var identities = lib.getStoredEmailKeypairs();
- ok("testuser@testuser.com" in identities, "Our new email is added");
+ ok(TEST_EMAIL in identities, "Our new email is added");
equal(_.size(identities), 1, "there is one identity");
start();
}, testHelpers.unexpectedXHRFailure);
@@ -871,13 +872,13 @@ var vep = require("./vep");
asyncTest("syncEmails with identities preloaded and one to add", function() {
- storage.addEmail("testuser@testuser.com", {pubkey: pubkey, cert: random_cert});
+ storage.addEmail(TEST_EMAIL, {pubkey: pubkey, cert: random_cert});
xhr.useResult("multiple");
lib.syncEmails(function onSuccess() {
var identities = lib.getStoredEmailKeypairs();
- ok("testuser@testuser.com" in identities, "Our old email address is still there");
+ ok(TEST_EMAIL in identities, "Our old email address is still there");
ok("testuser2@testuser.com" in identities, "Our new email is added");
equal(_.size(identities), 2, "there are two identities");
start();
@@ -886,12 +887,12 @@ var vep = require("./vep");
asyncTest("syncEmails with identities preloaded and one to remove", function() {
- storage.addEmail("testuser@testuser.com", {pub: pubkey, cert: random_cert});
+ storage.addEmail(TEST_EMAIL, {pub: pubkey, cert: random_cert});
storage.addEmail("testuser2@testuser.com", {pub: pubkey, cert: random_cert});
lib.syncEmails(function onSuccess() {
var identities = lib.getStoredEmailKeypairs();
- ok("testuser@testuser.com" in identities, "Our old email address is still there");
+ ok(TEST_EMAIL in identities, "Our old email address is still there");
equal("testuser2@testuser.com" in identities, false, "Our unknown email is removed");
equal(_.size(identities), 1, "there is one identity");
start();
@@ -899,11 +900,11 @@ var vep = require("./vep");
});
asyncTest("syncEmails with one to refresh", function() {
- storage.addEmail("testuser@testuser.com", {pub: pubkey, cert: random_cert});
+ storage.addEmail(TEST_EMAIL, {pub: pubkey, cert: random_cert});
lib.syncEmails(function onSuccess() {
var identities = lib.getStoredEmailKeypairs();
- ok("testuser@testuser.com" in identities, "refreshed key is synced");
+ ok(TEST_EMAIL in identities, "refreshed key is synced");
start();
}, testHelpers.unexpectedXHRFailure);
});
@@ -913,20 +914,20 @@ var vep = require("./vep");
});
asyncTest("getAssertion with known email that has key", function() {
- lib.syncEmailKeypair("testuser@testuser.com", function() {
- lib.getAssertion("testuser@testuser.com", lib.getOrigin(), function onSuccess(assertion) {
+ lib.syncEmailKeypair(TEST_EMAIL, function() {
+ lib.getAssertion(TEST_EMAIL, lib.getOrigin(), function onSuccess(assertion) {
testAssertion(assertion, start);
- equal(storage.site.get(testOrigin, "email"), "testuser@testuser.com", "email address was persisted");
+ equal(storage.site.get(testOrigin, "email"), TEST_EMAIL, "email address was persisted");
}, testHelpers.unexpectedXHRFailure);
}, testHelpers.unexpectedXHRFailure);
});
asyncTest("getAssertion with known secondary email that does not have a key", function() {
- storage.addEmail("testuser@testuser.com", { type: "secondary" });
- lib.getAssertion("testuser@testuser.com", lib.getOrigin(), function onSuccess(assertion) {
+ storage.addEmail(TEST_EMAIL, { type: "secondary" });
+ lib.getAssertion(TEST_EMAIL, lib.getOrigin(), function onSuccess(assertion) {
testAssertion(assertion, start);
- equal(storage.site.get(testOrigin, "email"), "testuser@testuser.com", "email address was persisted");
+ equal(storage.site.get(testOrigin, "email"), TEST_EMAIL, "email address was persisted");
}, testHelpers.unexpectedXHRFailure);
});
@@ -962,7 +963,7 @@ var vep = require("./vep");
});
asyncTest("getAssertion with unknown email", function() {
- lib.syncEmailKeypair("testuser@testuser.com", function() {
+ lib.syncEmailKeypair(TEST_EMAIL, function() {
lib.getAssertion("testuser2@testuser.com", lib.getOrigin(), function onSuccess(assertion) {
equal(null, assertion, "email was unknown, we do not have an assertion");
equal(storage.site.get(testOrigin, "email"), undefined, "email address was not set");
@@ -972,13 +973,13 @@ var vep = require("./vep");
});
asyncTest("getAssertion with XHR failure", function() {
- storage.addEmail("testuser@testuser.com", {});
- failureCheck(lib.getAssertion, "testuser@testuser.com", lib.getOrigin());
+ storage.addEmail(TEST_EMAIL, {});
+ failureCheck(lib.getAssertion, TEST_EMAIL, lib.getOrigin());
});
asyncTest("logoutUser", function(onSuccess) {
- lib.authenticate("testuser@testuser.com", "testuser", function(authenticated) {
+ lib.authenticate(TEST_EMAIL, "testuser", function(authenticated) {
lib.syncEmails(function() {
var storedIdentities = storage.getEmails();
equal(_.size(storedIdentities), 1, "one identity");
@@ -996,7 +997,7 @@ var vep = require("./vep");
});
asyncTest("logoutUser with XHR failure", function(onSuccess) {
- lib.authenticate("testuser@testuser.com", "testuser", function(authenticated) {
+ lib.authenticate(TEST_EMAIL, "testuser", function(authenticated) {
lib.syncEmails(function() {
failureCheck(lib.logoutUser);
}, testHelpers.unexpectedXHRFailure);
@@ -1036,7 +1037,7 @@ var vep = require("./vep");
});
asyncTest("addressInfo with XHR Error", function() {
- failureCheck(lib.addressInfo, "testuser@testuser.com");
+ failureCheck(lib.addressInfo, TEST_EMAIL);
});
asyncTest("addressInfo with unknown secondary user", function() {
@@ -1106,7 +1107,7 @@ var vep = require("./vep");
});
asyncTest("hasSecondary returns true if the user has at least one secondary email address", function() {
- storage.addEmail("testuser@testuser.com", { type: "secondary" });
+ storage.addEmail(TEST_EMAIL, { type: "secondary" });
lib.hasSecondary(function(hasSecondary) {
equal(hasSecondary, true, "hasSecondary is true");
start();
@@ -1114,7 +1115,7 @@ var vep = require("./vep");
});
asyncTest("setComputerOwnershipStatus with true, isUsersComputer - mark the computer as the users, prolongs the user's session", function() {
- lib.authenticate("testuser@testuser.com", "password", function() {
+ lib.authenticate(TEST_EMAIL, "password", function() {
storage.usersComputer.clear(network.userid());
lib.setComputerOwnershipStatus(true, function() {
lib.isUsersComputer(function(usersComputer) {
@@ -1126,7 +1127,7 @@ var vep = require("./vep");
});
asyncTest("setComputerOwnershipStatus with false, isUsersComputer - mark the computer as not the users", function() {
- lib.authenticate("testuser@testuser.com", "password", function() {
+ lib.authenticate(TEST_EMAIL, "password", function() {
storage.usersComputer.clear(network.userid());
lib.setComputerOwnershipStatus(false, function() {
lib.isUsersComputer(function(usersComputer) {
@@ -1145,7 +1146,7 @@ var vep = require("./vep");
});
asyncTest("setComputerOwnershipStatus with true & XHR Failure - call onFailure", function() {
- lib.authenticate("testuser@testuser.com", "password", function() {
+ lib.authenticate(TEST_EMAIL, "password", function() {
xhr.useResult("ajaxError");
lib.setComputerOwnershipStatus(true,
testHelpers.unexpectedSuccess,
@@ -1154,4 +1155,40 @@ var vep = require("./vep");
}, testHelpers.unexpectedXHRFailure);
});
+ asyncTest("shouldAskIfUsersComputer with user who has been asked - call onSuccess with false", function() {
+ lib.authenticate(TEST_EMAIL, "password", function() {
+ storage.usersComputer.setConfirmed(network.userid());
+ lib.shouldAskIfUsersComputer(function(shouldAsk) {
+ equal(shouldAsk, false, "user has been asked already, do not ask again");
+ start();
+ }, testHelpers.expectedXHRFailure);
+ }, testHelpers.unexpectedXHRFailure);
+ });
+
+ asyncTest("shouldAskIfUsersComputer with user who has not been asked and has not verified email this dialog session - call onSuccess with true", function() {
+ lib.authenticate(TEST_EMAIL, "password", function() {
+ storage.usersComputer.forceAsk(network.userid());
+ lib.shouldAskIfUsersComputer(function(shouldAsk) {
+ equal(shouldAsk, true, "user has not verified an email this dialog session and should be asked");
+ start();
+ }, testHelpers.expectedXHRFailure);
+ }, testHelpers.unexpectedXHRFailure);
+ });
+
+ asyncTest("shouldAskIfUsersComputer with user who has not been asked and has verified email in this dialog session - call onSuccess with false", function() {
+ lib.authenticate(TEST_EMAIL, "password", function() {
+ storage.setStagedOnBehalfOf(testOrigin);
+ xhr.useResult("complete");
+
+ lib.waitForEmailValidation(TEST_EMAIL, function() {
+ storage.usersComputer.forceAsk(network.userid());
+ lib.shouldAskIfUsersComputer(function(shouldAsk) {
+ equal(shouldAsk, false, "user has verified an email this dialog session and should be asked");
+ start();
+ }, testHelpers.expectedXHRFailure);
+ }, testHelpers.unexpectedXHRFailure);
+ xhr.useResult
+ }, testHelpers.unexpectedXHRFailure);
+ });
+
}());
View
1  resources/static/test/mocks/xhr.js
@@ -82,6 +82,7 @@ BrowserID.Mocks.xhr = (function() {
"post /wsapi/stage_email throttle": 429,
"post /wsapi/stage_email ajaxError": undefined,
"post /wsapi/cert_key ajaxError": undefined,
+ "get /wsapi/email_addition_status?email=testuser%40testuser.com complete": { status: "complete" },
"get /wsapi/email_addition_status?email=registered%40testuser.com pending": { status: "pending" },
"get /wsapi/email_addition_status?email=registered%40testuser.com complete": { status: "complete" },
"get /wsapi/email_addition_status?email=registered%40testuser.com mustAuth": { status: "mustAuth" },
Please sign in to comment.
Something went wrong with that request. Please try again.