Skip to content
Snippets Groups Projects
Commit c4948dbc authored by Shane Tomlinson's avatar Shane Tomlinson
Browse files

Only do the code check if session_context returns a version.

* Update network to allow for undefined code_version
* Update unit tests.
* Move code_check to static/shared/modules/
* Update build script for new location.

issue #226
parent e37e49a3
No related branches found
No related tags found
No related merge requests found
......@@ -51,22 +51,18 @@ BrowserID.Modules.CodeCheck = (function() {
data = data || {};
self.checkRequired(data, "code_ver", "environment");
self.checkRequired(data, "code_ver");
expectedCodeVer = data.code_ver;
if(data.environment === "PRODUCTION") {
getMostRecentCodeVersion.call(self, function(version) {
if(version) {
updateCodeIfNeeded.call(self, complete, version);
}
else {
complete();
}
});
}
else {
complete(true);
}
getMostRecentCodeVersion.call(self, function(version) {
if(version) {
updateCodeIfNeeded.call(self, complete, version);
}
else {
complete(true);
}
});
sc.start.call(self, data);
}
});
......
......@@ -112,8 +112,7 @@ BrowserID.Network = (function() {
};
domain_key_creation_time = result.domain_key_creation_time;
auth_status = result.auth_level;
// XXX remove the ABC123
code_version = result.code_version || "ABC123";
code_version = result.code_version;
// seed the PRNG
// FIXME: properly abstract this out, probably by exposing a jwcrypto
......@@ -676,7 +675,6 @@ BrowserID.Network = (function() {
codeVersion: function(onComplete, onFailure) {
withContext(function() {
try {
if (!code_version) throw "can't get code version!";
if (onComplete) onComplete(code_version);
} catch(e) {
if (onFailure) onFailure(e.toString());
......
......@@ -7,22 +7,20 @@
"use strict";
var bid = BrowserID,
network = bid.Network,
xhr = bid.Mocks.xhr,
transport = bid.Mocks.xhr,
helpers = bid.TestHelpers,
controller;
function createController(config) {
var config = $.extend({
code_ver: "ABC123",
environment: "PRODUCTION"
code_ver: "ABC123"
}, config);
controller = BrowserID.Modules.CodeCheck.create();
controller.start(config);
}
module("controllers/code_check", {
module("shared/modules/code_check", {
setup: function() {
helpers.setup();
},
......@@ -34,18 +32,29 @@
}
});
asyncTest("create controller with 'environment: DEBUG' - no code check performed", function() {
asyncTest("create controller with most recent scripts", function() {
createController({
ready: function(mostRecent) {
equal(mostRecent, true, "scripts are the most recent");
start();
}
});
});
asyncTest("create controller with no 'current' code_version given - do not update scripts", function() {
transport.setContextInfo("code_version", undefined);
var scriptCount = $("head > script").length;
createController({
environment: "DEBUG",
code_ver: "ABC123",
ready: function(mostRecent) {
equal(mostRecent, true, "working on the most recent version");
equal(mostRecent, true, "scripts are the most recent");
var scripts = $("head > script");
var scriptAdded = scripts.length !== scriptCount;
equal(scriptAdded, false, "a script was not added");
equal(scriptAdded, false, "a script was not added to the dom");
if(scriptAdded) {
// Only remove the last script if the script was actually added.
......@@ -56,18 +65,9 @@
}
});
});
asyncTest("create controller with most recent scripts", function() {
createController({
ready: function(mostRecent) {
equal(mostRecent, true, "scripts are the most recent");
start();
}
});
});
asyncTest("create controller with out of date scripts", function() {
var scriptCount = $("head > script").length;
transport.setContextInfo("code_version", "ABC123");
createController({
code_ver: "ABC122",
......@@ -89,7 +89,7 @@
});
asyncTest("create controller with XHR error during script check", function() {
xhr.useResult("contextAjaxError");
transport.useResult("contextAjaxError");
var scriptCount = $("head > script").length;
createController({
......
......@@ -88,12 +88,12 @@
<script src="/shared/modules/page_module.js"></script>
<script src="/shared/modules/xhr_delay.js"></script>
<script src="/shared/modules/xhr_disable_form.js"></script>
<script src="/shared/modules/code_check.js"></script>
<script src="/dialog/resources/internal_api.js"></script>
<script src="/dialog/resources/helpers.js"></script>
<script src="/dialog/resources/state_machine.js"></script>
<script src="/dialog/controllers/code_check.js"></script>
<script src="/dialog/controllers/actions.js"></script>
<script src="/dialog/controllers/dialog.js"></script>
<script src="/dialog/controllers/authenticate.js"></script>
......
......@@ -49,6 +49,7 @@
<script src="/shared/modules/page_module.js"></script>
<script src="/shared/modules/xhr_delay.js"></script>
<script src="/shared/modules/xhr_disable_form.js"></script>
<script src="/shared/modules/code_check.js"></script>
<script src="/pages/page_helpers.js"></script>
<script src="/pages/index.js"></script>
......
......@@ -102,12 +102,12 @@
<script src="/shared/modules/page_module.js"></script>
<script src="/shared/modules/xhr_delay.js"></script>
<script src="/shared/modules/xhr_disable_form.js"></script>
<script src="/shared/modules/code_check.js"></script>
<script src="/dialog/resources/internal_api.js"></script>
<script src="/dialog/resources/helpers.js"></script>
<script src="/dialog/resources/state_machine.js"></script>
<script src="/dialog/controllers/code_check.js"></script>
<script src="/dialog/controllers/actions.js"></script>
<script src="/dialog/controllers/pick_email.js"></script>
<script src="/dialog/controllers/add_email.js"></script>
......@@ -147,6 +147,7 @@
<script src="qunit/shared/modules/page_module_unit_test.js"></script>
<script src="qunit/shared/modules/xhr_delay_unit_test.js"></script>
<script src="qunit/shared/modules/xhr_disable_form_unit_test.js"></script>
<script src="qunit/shared/modules/code_check_unit_test.js"></script>
<script src="qunit/pages/browserid_unit_test.js"></script>
<script src="qunit/pages/page_helpers_unit_test.js"></script>
......@@ -161,7 +162,6 @@
<script src="qunit/resources/helpers_unit_test.js"></script>
<script src="qunit/resources/state_machine_unit_test.js"></script>
<script src="qunit/controllers/code_check_unit_test.js"></script>
<script src="qunit/controllers/actions_unit_test.js"></script>
<script src="qunit/controllers/pick_email_unit_test.js"></script>
<script src="qunit/controllers/add_email_unit_test.js"></script>
......
......@@ -60,7 +60,7 @@ cd ../..
# produce the dialog js
for locale in `../../scripts/production_locales`; do
mkdir -p $BUILD_PATH/$locale
cat lib/jquery-1.7.1.min.js lib/winchan.js lib/underscore-min.js lib/vepbundle.js lib/ejs.js i18n/${locale}/client.json shared/gettext.js shared/browserid.js lib/hub.js lib/dom-jquery.js lib/module.js lib/jschannel.js shared/javascript-extensions.js shared/mediator.js shared/class.js shared/storage.js $BUILD_PATH/templates.js shared/renderer.js shared/error-display.js shared/screens.js shared/tooltip.js shared/validation.js shared/provisioning.js shared/network.js shared/user.js shared/error-messages.js shared/browser-support.js shared/wait-messages.js shared/helpers.js shared/modules/page_module.js shared/modules/xhr_delay.js shared/modules/xhr_disable_form.js dialog/resources/internal_api.js dialog/resources/helpers.js dialog/resources/state_machine.js dialog/controllers/code_check.js dialog/controllers/actions.js dialog/controllers/dialog.js dialog/controllers/authenticate.js dialog/controllers/forgot_password.js dialog/controllers/check_registration.js dialog/controllers/pick_email.js dialog/controllers/add_email.js dialog/controllers/required_email.js dialog/controllers/verify_primary_user.js dialog/controllers/provision_primary_user.js dialog/controllers/primary_user_provisioned.js dialog/controllers/email_chosen.js dialog/start.js > $BUILD_PATH/$locale/dialog.uncompressed.js
cat lib/jquery-1.7.1.min.js lib/winchan.js lib/underscore-min.js lib/vepbundle.js lib/ejs.js i18n/${locale}/client.json shared/gettext.js shared/browserid.js lib/hub.js lib/dom-jquery.js lib/module.js lib/jschannel.js shared/javascript-extensions.js shared/mediator.js shared/class.js shared/storage.js $BUILD_PATH/templates.js shared/renderer.js shared/error-display.js shared/screens.js shared/tooltip.js shared/validation.js shared/provisioning.js shared/network.js shared/user.js shared/error-messages.js shared/browser-support.js shared/wait-messages.js shared/helpers.js shared/modules/page_module.js shared/modules/xhr_delay.js shared/modules/xhr_disable_form.js shared/modules/code_check.js dialog/resources/internal_api.js dialog/resources/helpers.js dialog/resources/state_machine.js dialog/controllers/actions.js dialog/controllers/dialog.js dialog/controllers/authenticate.js dialog/controllers/forgot_password.js dialog/controllers/check_registration.js dialog/controllers/pick_email.js dialog/controllers/add_email.js dialog/controllers/required_email.js dialog/controllers/verify_primary_user.js dialog/controllers/provision_primary_user.js dialog/controllers/primary_user_provisioned.js dialog/controllers/email_chosen.js dialog/start.js > $BUILD_PATH/$locale/dialog.uncompressed.js
done
# produce the dialog css
......@@ -74,7 +74,7 @@ echo '****Building BrowserID.org HTML, CSS, and JS****'
echo ''
#produce the main site js
cat lib/vepbundle.js lib/jquery-1.7.1.min.js lib/underscore-min.js lib/ejs.js shared/javascript-extensions.js shared/browserid.js lib/dom-jquery.js lib/jschannel.js lib/winchan.js lib/hub.js $BUILD_PATH/templates.js shared/renderer.js shared/error-display.js shared/screens.js shared/error-messages.js shared/wait-messages.js shared/mediator.js shared/storage.js shared/network.js shared/provisioning.js shared/user.js shared/tooltip.js shared/validation.js shared/helpers.js shared/class.js shared/modules/page_module.js shared/modules/xhr_delay.js shared/modules/xhr_disable_form.js pages/page_helpers.js pages/start.js pages/index.js pages/add_email_address.js pages/verify_email_address.js pages/forgot.js pages/manage_account.js pages/signin.js pages/signup.js > $BUILD_PATH/browserid.uncompressed.js
cat lib/vepbundle.js lib/jquery-1.7.1.min.js lib/underscore-min.js lib/ejs.js shared/javascript-extensions.js shared/browserid.js lib/dom-jquery.js lib/jschannel.js lib/winchan.js lib/hub.js $BUILD_PATH/templates.js shared/renderer.js shared/error-display.js shared/screens.js shared/error-messages.js shared/wait-messages.js shared/mediator.js shared/storage.js shared/network.js shared/provisioning.js shared/user.js shared/tooltip.js shared/validation.js shared/helpers.js shared/class.js shared/modules/page_module.js shared/modules/xhr_delay.js shared/modules/xhr_disable_form.js shared/modules/code_check.js pages/page_helpers.js pages/start.js pages/index.js pages/add_email_address.js pages/verify_email_address.js pages/forgot.js pages/manage_account.js pages/signin.js pages/signup.js > $BUILD_PATH/browserid.uncompressed.js
# produce the main site css
cat css/common.css css/style.css css/m.css > $BUILD_PATH/browserid.uncompressed.css
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment