You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bh...@apache.org on 2013/09/20 15:55:11 UTC
webworks commit: [CB-4345] Added warning message for when signing
keys are not installed
Updated Branches:
refs/heads/master acc99de20 -> 95c454032
[CB-4345] Added warning message for when signing keys are not installed
- Added check for bbidtoken.csk
- Added information to link old signing keys to the blackberry id token
- changed check_reqs-utils into signing-utils
- Migrated and added unit tests for signing-utils.js
- switched warning message for when author.p12 DNE to when barsigner.db DNE
Reviewed by Bryan Higgins <bh...@blackberry.com>
Tested by Daniel Audino <da...@blackberry.com>
Project: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/commit/95c45403
Tree: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/tree/95c45403
Diff: http://git-wip-us.apache.org/repos/asf/cordova-blackberry/diff/95c45403
Branch: refs/heads/master
Commit: 95c4540327dcccdd49e0275bbbc9a83a2f090f55
Parents: acc99de
Author: Kristoffer Flores <kf...@blackberry.com>
Authored: Fri Sep 6 15:03:06 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri Sep 20 09:55:31 2013 -0400
----------------------------------------------------------------------
blackberry10/bin/check_reqs.js | 11 +-
.../project/cordova/lib/signing-helper.js | 44 +-
.../project/cordova/lib/signing-utils.js | 64 +++
.../cordova/unit/spec/lib/signing-helper.js | 332 ---------------
.../test/cordova/unit/spec/lib/signing-utils.js | 419 +++++++++++++++++++
5 files changed, 497 insertions(+), 373 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/95c45403/blackberry10/bin/check_reqs.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/check_reqs.js b/blackberry10/bin/check_reqs.js
index e55803e..e052335 100644
--- a/blackberry10/bin/check_reqs.js
+++ b/blackberry10/bin/check_reqs.js
@@ -17,7 +17,8 @@
* under the License.
*/
-var MIN_NODE_VER = "0.9.9";
+var MIN_NODE_VER = "0.9.9",
+ signingUtils = require('./templates/project/cordova/lib/signing-utils');
function isNodeNewerThanMin () {
//Current version is stored as a String in format "X.X.X"
@@ -31,4 +32,12 @@ if (!isNodeNewerThanMin()) {
process.exit(1);
}
+if (!signingUtils.getKeyStorePath() && !signingUtils.getKeyStorePathBBID()) {
+ console.log('WARNING: Signing keys are not installed on this machine.');
+}
+
+if (signingUtils.getDbPath()) {
+ console.log('NOTE: BlackBerry ID tokens can now be used in place of your old signing keys. For more information on linking old signing keys with a BlackBerry ID token, please log in at http://developer.blackberry.com and click on Code Signing in the top menu bar.');
+}
+
process.exit(0);
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/95c45403/blackberry10/bin/templates/project/cordova/lib/signing-helper.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/signing-helper.js b/blackberry10/bin/templates/project/cordova/lib/signing-helper.js
index cb7d60d..307a740 100644
--- a/blackberry10/bin/templates/project/cordova/lib/signing-helper.js
+++ b/blackberry10/bin/templates/project/cordova/lib/signing-helper.js
@@ -22,45 +22,9 @@ var path = require('path'),
conf = require("./conf"),
pkgrUtils = require("./packager-utils"),
logger = require("./logger"),
- AUTHOR_P12 = "author.p12",
- CSK = "barsigner.csk",
- DB = "barsigner.db",
+ signingUtils = require("./signing-utils.js"),
_self;
-function getDefaultPath(file) {
- // The default location where signing key files are stored will vary based on the OS:
- // Windows XP: %HOMEPATH%\Local Settings\Application Data\Research In Motion
- // Windows Vista and Windows 7: %HOMEPATH%\AppData\Local\Research In Motion
- // Mac OS: ~/Library/Research In Motion
- // UNIX or Linux: ~/.rim
- var p = "";
- if (os.type().toLowerCase().indexOf("windows") >= 0) {
- // Try Windows XP location
- p = process.env.HOMEDRIVE + process.env.HOMEPATH + "\\Local Settings\\Application Data\\Research In Motion\\" + file;
- if (fs.existsSync(p)) {
- return p;
- }
-
- // Try Windows Vista and Windows 7 location
- p = process.env.HOMEDRIVE + process.env.HOMEPATH + "\\AppData\\Local\\Research In Motion\\" + file;
- if (fs.existsSync(p)) {
- return p;
- }
- } else if (os.type().toLowerCase().indexOf("darwin") >= 0) {
- // Try Mac OS location
- p = process.env.HOME + "/Library/Research In Motion/" + file;
- if (fs.existsSync(p)) {
- return p;
- }
- } else if (os.type().toLowerCase().indexOf("linux") >= 0) {
- // Try Linux location
- p = process.env.HOME + "/.rim/" + file;
- if (fs.existsSync(p)) {
- return p;
- }
- }
-}
-
function execSigner(session, target, callback) {
var script = path.join(process.env.CORDOVA_BBTOOLS, "blackberry-signer"),
signer,
@@ -92,15 +56,15 @@ function execSigner(session, target, callback) {
_self = {
getKeyStorePath : function () {
// Todo: decide where to put sigtool.p12 which is genereated and used in WebWorks SDK for Tablet OS
- return getDefaultPath(AUTHOR_P12);
+ return signingUtils.getKeyStorePath();
},
getCskPath : function () {
- return getDefaultPath(CSK);
+ return signingUtils.getCskPath();
},
getDbPath : function () {
- return getDefaultPath(DB);
+ return signingUtils.getDbPath();
},
execSigner: execSigner
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/95c45403/blackberry10/bin/templates/project/cordova/lib/signing-utils.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/templates/project/cordova/lib/signing-utils.js b/blackberry10/bin/templates/project/cordova/lib/signing-utils.js
new file mode 100644
index 0000000..86b5bac
--- /dev/null
+++ b/blackberry10/bin/templates/project/cordova/lib/signing-utils.js
@@ -0,0 +1,64 @@
+var fs = require('fs'),
+ path = require('path'),
+ os = require('os'),
+ childProcess = require('child_process'),
+ AUTHOR_P12 = "author.p12",
+ BBIDTOKEN = "bbidtoken.csk",
+ CSK = "barsigner.csk",
+ DB = "barsigner.db",
+ _self;
+
+function getDefaultPath(file) {
+ // The default location where signing key files are stored will vary based on the OS:
+ // Windows XP: %HOMEPATH%\Local Settings\Application Data\Research In Motion
+ // Windows Vista and Windows 7: %HOMEPATH%\AppData\Local\Research In Motion
+ // Mac OS: ~/Library/Research In Motion
+ // UNIX or Linux: ~/.rim
+ var p = "";
+ if (os.type().toLowerCase().indexOf("windows") >= 0) {
+ // Try Windows XP location
+ p = process.env.HOMEDRIVE + process.env.HOMEPATH + "\\Local Settings\\Application Data\\Research In Motion\\" + file;
+ if (fs.existsSync(p)) {
+ return p;
+ }
+
+ // Try Windows Vista and Windows 7 location
+ p = process.env.HOMEDRIVE + process.env.HOMEPATH + "\\AppData\\Local\\Research In Motion\\" + file;
+ if (fs.existsSync(p)) {
+ return p;
+ }
+ } else if (os.type().toLowerCase().indexOf("darwin") >= 0) {
+ // Try Mac OS location
+ p = process.env.HOME + "/Library/Research In Motion/" + file;
+ if (fs.existsSync(p)) {
+ return p;
+ }
+ } else if (os.type().toLowerCase().indexOf("linux") >= 0) {
+ // Try Linux location
+ p = process.env.HOME + "/.rim/" + file;
+ if (fs.existsSync(p)) {
+ return p;
+ }
+ }
+}
+
+_self = {
+ getKeyStorePath : function () {
+ // Todo: decide where to put sigtool.p12 which is genereated and used in WebWorks SDK for Tablet OS
+ return getDefaultPath(AUTHOR_P12);
+ },
+
+ getKeyStorePathBBID: function () {
+ return getDefaultPath(BBIDTOKEN);
+ },
+
+ getCskPath : function () {
+ return getDefaultPath(CSK);
+ },
+
+ getDbPath : function () {
+ return getDefaultPath(DB);
+ }
+};
+
+module.exports = _self;
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/95c45403/blackberry10/bin/test/cordova/unit/spec/lib/signing-helper.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/cordova/unit/spec/lib/signing-helper.js b/blackberry10/bin/test/cordova/unit/spec/lib/signing-helper.js
index db4fc7d..8618f21 100644
--- a/blackberry10/bin/test/cordova/unit/spec/lib/signing-helper.js
+++ b/blackberry10/bin/test/cordova/unit/spec/lib/signing-helper.js
@@ -36,338 +36,6 @@ var testData = require('./test-data'),
describe("signing-helper", function () {
- describe("on windows", function () {
-
- beforeEach(function () {
-
- /* Preserve the value of the HOMEPATH and HOMEDRIVE environment
- * variables if they are defined. If they are not defined, mark
- * variable for deletion after the test.*/
- if (typeof process.env.HOMEPATH === 'undefined') {
- properties.homepath = "delete";
- } else {
- properties.homepath = process.env.HOMEPATH;
- }
-
- if (typeof process.env.HOMEDRIVE === 'undefined') {
- properties.homedrive = "delete";
- } else {
- properties.homedrive = process.env.HOMEDRIVE;
- }
-
- spyOn(os, "type").andReturn("windows");
- });
-
- afterEach(function () {
-
- /* Restore the value of the HOMEPATH and HOMEDRIVE environment
- * variables if they are defined. If they are not defined, delete
- * the property if it was defined in the test.*/
- if (typeof process.env.HOMEPATH === 'string') {
- if (properties.homepath === 'delete') {
- delete process.env.HOMEPATH;
- } else {
- process.env.HOMEPATH = properties.homepath;
- }
- }
-
- if (typeof process.env.HOMEDRIVE === 'string') {
- if (properties.homedrive === 'delete') {
- delete process.env.HOMEDRIVE;
- } else {
- process.env.HOMEDRIVE = properties.homedrive;
- }
- }
- });
-
- it("can find keys in Local Settings", function () {
-
- spyOn(fs, "existsSync").andCallFake(function (path) {
- return path.indexOf("\\Local Settings") !== -1;
- });
-
- var result = signingHelper.getKeyStorePath();
- expect(result).toContain("\\Local Settings");
- });
-
- it("can find barsigner.csk in Local Settings", function () {
-
- spyOn(fs, "existsSync").andCallFake(function (path) {
- return path.indexOf("\\Local Settings") !== -1;
- });
-
- var result = signingHelper.getCskPath();
- expect(result).toContain("\\Local Settings");
- });
-
- it("can find barsigner.db in Local Settings", function () {
-
- spyOn(fs, "existsSync").andCallFake(function (path) {
- return path.indexOf("\\Local Settings") !== -1;
- });
-
- var result = signingHelper.getDbPath();
- expect(result).toContain("\\Local Settings");
- });
-
- it("can find keys in AppData", function () {
-
- spyOn(fs, "existsSync").andCallFake(function (path) {
- return path.indexOf("\\AppData") !== -1;
- });
-
- var result = signingHelper.getKeyStorePath();
- expect(result).toContain("\\AppData");
- });
-
- it("can find barsigner.csk in AppData", function () {
-
- spyOn(fs, "existsSync").andCallFake(function (path) {
- return path.indexOf("\\AppData") !== -1;
- });
-
- var result = signingHelper.getCskPath();
- expect(result).toContain("\\AppData");
- });
-
- it("can find barsigner.db in AppData", function () {
-
- spyOn(fs, "existsSync").andCallFake(function (path) {
- return path.indexOf("\\AppData") !== -1;
- });
-
- var result = signingHelper.getDbPath();
- expect(result).toContain("\\AppData");
- });
-
- it("can find keys in home path", function () {
- process.env.HOMEPATH = "\\Users\\user";
- process.env.HOMEDRIVE = "C:";
-
- spyOn(fs, "existsSync").andCallFake(function (p) {
- return p.indexOf("\\Users\\user") !== -1;
- });
-
- var result = signingHelper.getKeyStorePath();
- expect(result).toContain("\\Users\\user");
- });
-
- it("can find keys on C drive", function () {
-
- process.env.HOMEPATH = "\\Users\\user";
- process.env.HOMEDRIVE = "C:";
-
- spyOn(fs, "existsSync").andCallFake(function (p) {
- return p.indexOf("C:") !== -1;
- });
-
- var result = signingHelper.getKeyStorePath();
- expect(result).toContain("C:");
- });
-
- it("can find keys on a drive other than C", function () {
- process.env.HOMEPATH = "\\Users\\user";
- process.env.HOMEDRIVE = "D:";
-
- spyOn(fs, "existsSync").andCallFake(function (path) {
- return path.indexOf("D:") !== -1;
- });
-
- var result = signingHelper.getKeyStorePath();
- expect(result).toContain("D:");
- });
-
- it("can find barsigner.csk on a drive other than C", function () {
- process.env.HOMEPATH = "\\Users\\user";
- process.env.HOMEDRIVE = "D:";
-
- spyOn(fs, "existsSync").andCallFake(function (path) {
- return path.indexOf("D:") !== -1;
- });
-
- var result = signingHelper.getCskPath();
- expect(result).toContain("D:");
- });
-
- it("can find barsigner.db on a drive other than C", function () {
- process.env.HOMEPATH = "\\Users\\user";
- process.env.HOMEDRIVE = "D:";
-
- spyOn(fs, "existsSync").andCallFake(function (path) {
- return path.indexOf("D:") !== -1;
- });
-
- var result = signingHelper.getDbPath();
- expect(result).toContain("D:");
- });
-
- it("can find keys in Local Settings on the correct drive", function () {
- process.env.HOMEPATH = "\\Users\\user";
- process.env.HOMEDRIVE = "C:";
-
- spyOn(fs, "existsSync").andCallFake(function (path) {
- return path.indexOf("C:") !== -1 &&
- path.indexOf("\\Local Settings") !== -1;
- });
-
- var result = signingHelper.getKeyStorePath();
- expect(result).toContain("C:");
- expect(result).toContain("\\Local Settings");
- });
-
- it("can find barsigner.csk in Local Settings on the correct drive", function () {
- process.env.HOMEPATH = "\\Users\\user";
- process.env.HOMEDRIVE = "D:";
-
- spyOn(fs, "existsSync").andCallFake(function (path) {
- return path.indexOf("D:") !== -1 &&
- path.indexOf("\\Local Settings") !== -1;
- });
-
- var result = signingHelper.getCskPath();
- expect(result).toContain("D:");
- expect(result).toContain("\\Local Settings");
- });
-
- it("can find barsigner.db in Local Settings on the correct drive", function () {
- process.env.HOMEPATH = "\\Users\\user";
- process.env.HOMEDRIVE = "D:";
-
- spyOn(fs, "existsSync").andCallFake(function (path) {
- return path.indexOf("D:") !== -1 &&
- path.indexOf("\\Local Settings") !== -1;
- });
-
- var result = signingHelper.getDbPath();
- expect(result).toContain("D:");
- expect(result).toContain("\\Local Settings");
- });
-
- it("can find keys in AppData on the correct drive", function () {
- process.env.HOMEPATH = "\\Users\\user";
- process.env.HOMEDRIVE = "C:";
-
- spyOn(fs, "existsSync").andCallFake(function (path) {
- return path.indexOf("C:") !== -1 &&
- path.indexOf("\\AppData") !== -1;
- });
-
- var result = signingHelper.getKeyStorePath();
- expect(result).toContain("C:");
- expect(result).toContain("\\AppData");
- });
-
- it("can find barsigner.csk in AppData on the correct drive", function () {
- process.env.HOMEPATH = "\\Users\\user";
- process.env.HOMEDRIVE = "D:";
-
- spyOn(fs, "existsSync").andCallFake(function (path) {
- return path.indexOf("D:") !== -1 &&
- path.indexOf("\\AppData") !== -1;
- });
-
- var result = signingHelper.getCskPath();
- expect(result).toContain("D:");
- expect(result).toContain("\\AppData");
- });
-
- it("can find barsigner.db in AppData on the correct drive", function () {
- process.env.HOMEPATH = "\\Users\\user";
- process.env.HOMEDRIVE = "D:";
-
- spyOn(fs, "existsSync").andCallFake(function (path) {
- return path.indexOf("D:") !== -1 &&
- path.indexOf("\\AppData") !== -1;
- });
-
- var result = signingHelper.getDbPath();
- expect(result).toContain("D:");
- expect(result).toContain("\\AppData");
- });
-
- it("returns undefined when keys cannot be found", function () {
- spyOn(fs, "existsSync").andReturn(false);
-
- var result = signingHelper.getKeyStorePath();
- expect(result).toBeUndefined();
- });
-
- it("returns undefined when barsigner.csk cannot be found", function () {
- spyOn(fs, "existsSync").andReturn(false);
-
- var result = signingHelper.getCskPath();
- expect(result).toBeUndefined();
- });
-
- it("returns undefined when barsigner.db cannot be found", function () {
- spyOn(fs, "existsSync").andReturn(false);
-
- var result = signingHelper.getDbPath();
- expect(result).toBeUndefined();
- });
- });
-
- describe("on mac", function () {
-
- beforeEach(function () {
- spyOn(os, "type").andReturn("darwin");
- });
-
- it("can find keys in the Library folder", function () {
-
- spyOn(fs, "existsSync").andCallFake(function (path) {
- return path.indexOf("/Library/Research In Motion/") !== -1;
- });
-
- var result = signingHelper.getKeyStorePath();
- expect(result).toContain("/Library/Research In Motion/");
- });
-
- it("can find barsigner.csk in the Library folder", function () {
-
- spyOn(fs, "existsSync").andCallFake(function (path) {
- return path.indexOf("/Library/Research In Motion/") !== -1;
- });
-
- var result = signingHelper.getCskPath();
- expect(result).toContain("/Library/Research In Motion/");
- });
-
- it("can find barsigner.db in the Library folder", function () {
-
- spyOn(fs, "existsSync").andCallFake(function (path) {
- return path.indexOf("/Library/Research In Motion/") !== -1;
- });
-
- var result = signingHelper.getDbPath();
- expect(result).toContain("/Library/Research In Motion/");
- });
-
- it("returns undefined when keys cannot be found", function () {
-
- spyOn(fs, "existsSync").andReturn(false);
-
- var result = signingHelper.getKeyStorePath();
- expect(result).toBeUndefined();
- });
-
- it("returns undefined when barsigner.csk cannot be found", function () {
-
- spyOn(fs, "existsSync").andReturn(false);
-
- var result = signingHelper.getCskPath();
- expect(result).toBeUndefined();
- });
-
- it("returns undefined when barsigner.db cannot be found", function () {
-
- spyOn(fs, "existsSync").andReturn(false);
-
- var result = signingHelper.getDbPath();
- expect(result).toBeUndefined();
- });
- });
-
describe("Exec blackberry-signer", function () {
var stdoutOn = jasmine.createSpy("stdout on"),
stderrOn = jasmine.createSpy("stderr on");
http://git-wip-us.apache.org/repos/asf/cordova-blackberry/blob/95c45403/blackberry10/bin/test/cordova/unit/spec/lib/signing-utils.js
----------------------------------------------------------------------
diff --git a/blackberry10/bin/test/cordova/unit/spec/lib/signing-utils.js b/blackberry10/bin/test/cordova/unit/spec/lib/signing-utils.js
new file mode 100644
index 0000000..698746d
--- /dev/null
+++ b/blackberry10/bin/test/cordova/unit/spec/lib/signing-utils.js
@@ -0,0 +1,419 @@
+var testData = require('./test-data'),
+ signingUtils = require(testData.libPath + '/signing-utils'),
+ localize = require(testData.libPath + '/localize'),
+ pkgrUtils = require(testData.libPath + "/packager-utils"),
+ conf = require(testData.libPath + "/conf"),
+ path = require('path'),
+ fs = require('fs'),
+ os = require('os'),
+ childProcess = require("child_process"),
+ properties = {
+ homepath: "",
+ homedrive: ""
+ },
+ session;
+
+describe("signing-utils", function () {
+
+ describe("on windows", function () {
+
+ beforeEach(function () {
+
+ /* Preserve the value of the HOMEPATH and HOMEDRIVE environment
+ * variables if they are defined. If they are not defined, mark
+ * variable for deletion after the test.*/
+ if (typeof process.env.HOMEPATH === 'undefined') {
+ properties.homepath = "delete";
+ } else {
+ properties.homepath = process.env.HOMEPATH;
+ }
+
+ if (typeof process.env.HOMEDRIVE === 'undefined') {
+ properties.homedrive = "delete";
+ } else {
+ properties.homedrive = process.env.HOMEDRIVE;
+ }
+
+ spyOn(os, "type").andReturn("windows");
+ });
+
+ afterEach(function () {
+
+ /* Restore the value of the HOMEPATH and HOMEDRIVE environment
+ * variables if they are defined. If they are not defined, delete
+ * the property if it was defined in the test.*/
+ if (typeof process.env.HOMEPATH === 'string') {
+ if (properties.homepath === 'delete') {
+ delete process.env.HOMEPATH;
+ } else {
+ process.env.HOMEPATH = properties.homepath;
+ }
+ }
+
+ if (typeof process.env.HOMEDRIVE === 'string') {
+ if (properties.homedrive === 'delete') {
+ delete process.env.HOMEDRIVE;
+ } else {
+ process.env.HOMEDRIVE = properties.homedrive;
+ }
+ }
+ });
+
+ it("can find keys in Local Settings", function () {
+
+ spyOn(fs, "existsSync").andCallFake(function (path) {
+ return path.indexOf("\\Local Settings") !== -1;
+ });
+
+ var result = signingUtils.getKeyStorePath();
+ expect(result).toContain("\\Local Settings");
+ });
+
+ it("can find bbidtoken.csk in Local Settings", function () {
+
+ spyOn(fs, "existsSync").andCallFake(function (path) {
+ return path.indexOf("\\Local Settings") !== -1;
+ });
+
+ var result = signingUtils.getKeyStorePathBBID();
+ expect(result).toContain("\\Local Settings");
+ });
+
+ it("can find barsigner.csk in Local Settings", function () {
+
+ spyOn(fs, "existsSync").andCallFake(function (path) {
+ return path.indexOf("\\Local Settings") !== -1;
+ });
+
+ var result = signingUtils.getCskPath();
+ expect(result).toContain("\\Local Settings");
+ });
+
+ it("can find barsigner.db in Local Settings", function () {
+
+ spyOn(fs, "existsSync").andCallFake(function (path) {
+ return path.indexOf("\\Local Settings") !== -1;
+ });
+
+ var result = signingUtils.getDbPath();
+ expect(result).toContain("\\Local Settings");
+ });
+
+ it("can find keys in AppData", function () {
+
+ spyOn(fs, "existsSync").andCallFake(function (path) {
+ return path.indexOf("\\AppData") !== -1;
+ });
+
+ var result = signingUtils.getKeyStorePath();
+ expect(result).toContain("\\AppData");
+ });
+
+ it("can find bbidtoken.csk in AppData", function () {
+
+ spyOn(fs, "existsSync").andCallFake(function (path) {
+ return path.indexOf("\\AppData") !== -1;
+ });
+
+ var result = signingUtils.getKeyStorePathBBID();
+ expect(result).toContain("\\AppData");
+ });
+
+ it("can find barsigner.csk in AppData", function () {
+
+ spyOn(fs, "existsSync").andCallFake(function (path) {
+ return path.indexOf("\\AppData") !== -1;
+ });
+
+ var result = signingUtils.getCskPath();
+ expect(result).toContain("\\AppData");
+ });
+
+ it("can find barsigner.db in AppData", function () {
+
+ spyOn(fs, "existsSync").andCallFake(function (path) {
+ return path.indexOf("\\AppData") !== -1;
+ });
+
+ var result = signingUtils.getDbPath();
+ expect(result).toContain("\\AppData");
+ });
+
+ it("can find keys in home path", function () {
+ process.env.HOMEPATH = "\\Users\\user";
+ process.env.HOMEDRIVE = "C:";
+
+ spyOn(fs, "existsSync").andCallFake(function (p) {
+ return p.indexOf("\\Users\\user") !== -1;
+ });
+
+ var result = signingUtils.getKeyStorePath();
+ expect(result).toContain("\\Users\\user");
+ });
+
+ it("can find keys on C drive", function () {
+
+ process.env.HOMEPATH = "\\Users\\user";
+ process.env.HOMEDRIVE = "C:";
+
+ spyOn(fs, "existsSync").andCallFake(function (p) {
+ return p.indexOf("C:") !== -1;
+ });
+
+ var result = signingUtils.getKeyStorePath();
+ expect(result).toContain("C:");
+ });
+
+ it("can find keys on a drive other than C", function () {
+ process.env.HOMEPATH = "\\Users\\user";
+ process.env.HOMEDRIVE = "D:";
+
+ spyOn(fs, "existsSync").andCallFake(function (path) {
+ return path.indexOf("D:") !== -1;
+ });
+
+ var result = signingUtils.getKeyStorePath();
+ expect(result).toContain("D:");
+ });
+
+ it("can find bbidtoken.csk on a drive other than C", function() {
+ process.env.HOMEPATH = "\\Users\\user";
+ process.env.HOMEDRIVE = "D:";
+
+ spyOn(fs, "existsSync").andCallFake(function (path) {
+ return path.indexOf("D:") !== -1;
+ });
+
+ var result = signingUtils.getKeyStorePathBBID();
+ expect(result).toContain("D:");
+ });
+
+ it("can find barsigner.csk on a drive other than C", function () {
+ process.env.HOMEPATH = "\\Users\\user";
+ process.env.HOMEDRIVE = "D:";
+
+ spyOn(fs, "existsSync").andCallFake(function (path) {
+ return path.indexOf("D:") !== -1;
+ });
+
+ var result = signingUtils.getCskPath();
+ expect(result).toContain("D:");
+ });
+
+ it("can find barsigner.db on a drive other than C", function () {
+ process.env.HOMEPATH = "\\Users\\user";
+ process.env.HOMEDRIVE = "D:";
+
+ spyOn(fs, "existsSync").andCallFake(function (path) {
+ return path.indexOf("D:") !== -1;
+ });
+
+ var result = signingUtils.getDbPath();
+ expect(result).toContain("D:");
+ });
+
+ it("can find keys in Local Settings on the correct drive", function () {
+ process.env.HOMEPATH = "\\Users\\user";
+ process.env.HOMEDRIVE = "C:";
+
+ spyOn(fs, "existsSync").andCallFake(function (path) {
+ return path.indexOf("C:") !== -1 &&
+ path.indexOf("\\Local Settings") !== -1;
+ });
+
+ var result = signingUtils.getKeyStorePath();
+ expect(result).toContain("C:");
+ expect(result).toContain("\\Local Settings");
+ });
+
+ it("can find bbidtoken.csk in Local Settings on the correct drive", function () {
+ process.env.HOMEPATH = "\\Users\\user";
+ process.env.HOMEDRIVE = "C:";
+
+ spyOn(fs, "existsSync").andCallFake(function (path) {
+ return path.indexOf("C:") !== -1 &&
+ path.indexOf("\\Local Settings") !== -1;
+ });
+
+ var result = signingUtils.getKeyStorePathBBID();
+ expect(result).toContain("C:");
+ expect(result).toContain("\\Local Settings");
+ });
+
+ it("can find barsigner.csk in Local Settings on the correct drive", function () {
+ process.env.HOMEPATH = "\\Users\\user";
+ process.env.HOMEDRIVE = "D:";
+
+ spyOn(fs, "existsSync").andCallFake(function (path) {
+ return path.indexOf("D:") !== -1 &&
+ path.indexOf("\\Local Settings") !== -1;
+ });
+
+ var result = signingUtils.getCskPath();
+ expect(result).toContain("D:");
+ expect(result).toContain("\\Local Settings");
+ });
+
+ it("can find barsigner.db in Local Settings on the correct drive", function () {
+ process.env.HOMEPATH = "\\Users\\user";
+ process.env.HOMEDRIVE = "D:";
+
+ spyOn(fs, "existsSync").andCallFake(function (path) {
+ return path.indexOf("D:") !== -1 &&
+ path.indexOf("\\Local Settings") !== -1;
+ });
+
+ var result = signingUtils.getDbPath();
+ expect(result).toContain("D:");
+ expect(result).toContain("\\Local Settings");
+ });
+
+ it("can find keys in AppData on the correct drive", function () {
+ process.env.HOMEPATH = "\\Users\\user";
+ process.env.HOMEDRIVE = "C:";
+
+ spyOn(fs, "existsSync").andCallFake(function (path) {
+ return path.indexOf("C:") !== -1 &&
+ path.indexOf("\\AppData") !== -1;
+ });
+
+ var result = signingUtils.getKeyStorePath();
+ expect(result).toContain("C:");
+ expect(result).toContain("\\AppData");
+ });
+
+ it("can find bbidtoken.csk in AppData on the correct drive", function () {
+ process.env.HOMEPATH = "\\Users\\user";
+ process.env.HOMEDRIVE = "C:";
+
+ spyOn(fs, "existsSync").andCallFake(function (path) {
+ return path.indexOf("C:") !== -1 &&
+ path.indexOf("\\AppData") !== -1;
+ });
+
+ var result = signingUtils.getKeyStorePathBBID();
+ expect(result).toContain("C:");
+ expect(result).toContain("\\AppData");
+ });
+
+ it("can find barsigner.csk in AppData on the correct drive", function () {
+ process.env.HOMEPATH = "\\Users\\user";
+ process.env.HOMEDRIVE = "D:";
+
+ spyOn(fs, "existsSync").andCallFake(function (path) {
+ return path.indexOf("D:") !== -1 &&
+ path.indexOf("\\AppData") !== -1;
+ });
+
+ var result = signingUtils.getCskPath();
+ expect(result).toContain("D:");
+ expect(result).toContain("\\AppData");
+ });
+
+ it("can find barsigner.db in AppData on the correct drive", function () {
+ process.env.HOMEPATH = "\\Users\\user";
+ process.env.HOMEDRIVE = "D:";
+
+ spyOn(fs, "existsSync").andCallFake(function (path) {
+ return path.indexOf("D:") !== -1 &&
+ path.indexOf("\\AppData") !== -1;
+ });
+
+ var result = signingUtils.getDbPath();
+ expect(result).toContain("D:");
+ expect(result).toContain("\\AppData");
+ });
+
+ it("returns undefined when keys cannot be found", function () {
+ spyOn(fs, "existsSync").andReturn(false);
+
+ var result = signingUtils.getKeyStorePath();
+ expect(result).toBeUndefined();
+ });
+
+ it("returns undefined when barsigner.csk cannot be found", function () {
+ spyOn(fs, "existsSync").andReturn(false);
+
+ var result = signingUtils.getCskPath();
+ expect(result).toBeUndefined();
+ });
+
+ it("returns undefined when barsigner.db cannot be found", function () {
+ spyOn(fs, "existsSync").andReturn(false);
+
+ var result = signingUtils.getDbPath();
+ expect(result).toBeUndefined();
+ });
+ });
+
+ describe("on mac", function () {
+
+ beforeEach(function () {
+ spyOn(os, "type").andReturn("darwin");
+ });
+
+ it("can find keys in the Library folder", function () {
+
+ spyOn(fs, "existsSync").andCallFake(function (path) {
+ return path.indexOf("/Library/Research In Motion/") !== -1;
+ });
+
+ var result = signingUtils.getKeyStorePath();
+ expect(result).toContain("/Library/Research In Motion/");
+ });
+
+ it("can find bbidtoken.csk in the Library folder", function () {
+
+ spyOn(fs, "existsSync").andCallFake(function (path) {
+ return path.indexOf("/Library/Research In Motion/") !== -1;
+ });
+
+ var result = signingUtils.getKeyStorePathBBID();
+ expect(result).toContain("/Library/Research In Motion/");
+ });
+
+ it("can find barsigner.csk in the Library folder", function () {
+
+ spyOn(fs, "existsSync").andCallFake(function (path) {
+ return path.indexOf("/Library/Research In Motion/") !== -1;
+ });
+
+ var result = signingUtils.getCskPath();
+ expect(result).toContain("/Library/Research In Motion/");
+ });
+
+ it("can find barsigner.db in the Library folder", function () {
+
+ spyOn(fs, "existsSync").andCallFake(function (path) {
+ return path.indexOf("/Library/Research In Motion/") !== -1;
+ });
+
+ var result = signingUtils.getDbPath();
+ expect(result).toContain("/Library/Research In Motion/");
+ });
+
+ it("returns undefined when keys cannot be found", function () {
+
+ spyOn(fs, "existsSync").andReturn(false);
+
+ var result = signingUtils.getKeyStorePath();
+ expect(result).toBeUndefined();
+ });
+
+ it("returns undefined when barsigner.csk cannot be found", function () {
+
+ spyOn(fs, "existsSync").andReturn(false);
+
+ var result = signingUtils.getCskPath();
+ expect(result).toBeUndefined();
+ });
+
+ it("returns undefined when barsigner.db cannot be found", function () {
+
+ spyOn(fs, "existsSync").andReturn(false);
+
+ var result = signingUtils.getDbPath();
+ expect(result).toBeUndefined();
+ });
+ });
+});