diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/account_spec.js | 31 | ||||
-rw-r--r-- | spec/runner.html | 2 | ||||
-rw-r--r-- | spec/session_spec.js | 14 | ||||
-rw-r--r-- | spec/signup_spec.js | 2 |
4 files changed, 41 insertions, 8 deletions
diff --git a/spec/account_spec.js b/spec/account_spec.js new file mode 100644 index 0000000..4110778 --- /dev/null +++ b/spec/account_spec.js @@ -0,0 +1,31 @@ +describe("Account", function() { + describe("without seeded values", function(){ + beforeEach(function() { + account = new srp.Account(); + }); + + it("fetches the password from the password field", function(){ + expect(account.password()).toBe("password"); + }); + + it("fetches the login from the login field", function(){ + expect(account.login()).toBe("testuser"); + }); + + }); + + describe("with seeded values", function(){ + beforeEach(function() { + account = new srp.Account("login", "secret"); + }); + + it("uses the seeded password", function(){ + expect(account.password()).toBe("secret"); + }); + + it("uses the seeded login", function(){ + expect(account.login()).toBe("login"); + }); + + }); +}); diff --git a/spec/runner.html b/spec/runner.html index 3a458df..d0a5d5d 100644 --- a/spec/runner.html +++ b/spec/runner.html @@ -23,6 +23,7 @@ <script type="text/javascript" src="../lib/jsbn2.js"></script> <script type="text/javascript" src="../src/srp.js"></script> <script type="text/javascript" src="../src/jqueryRest.js"></script> + <script type="text/javascript" src="../src/srp_account.js"></script> <script type="text/javascript" src="../src/srp_calculate.js"></script> <script type="text/javascript" src="../src/srp_session.js"></script> @@ -30,6 +31,7 @@ <script type="text/javascript" src="helper.js"></script> <script type="text/javascript" src="signup_spec.js"></script> <script type="text/javascript" src="login_spec.js"></script> + <script type="text/javascript" src="account_spec.js"></script> <script type="text/javascript" src="calculate_spec.js"></script> <script type="text/javascript" src="session_spec.js"></script> diff --git a/spec/session_spec.js b/spec/session_spec.js index 5802283..a1378a6 100644 --- a/spec/session_spec.js +++ b/spec/session_spec.js @@ -29,19 +29,19 @@ describe("Session", function() { var session; beforeEach(function() { - session = new srp.Session(compare.username, compare.password); + account = new srp.Account(compare.username, compare.password); + session = new srp.Session(account); }); - it("has the proper username", function() { - expect(session.getI()).toBe(compare.username); - }); - - it("calculates the proper M", function() { + it("calculates the proper M (INTEGRATION)", function() { session.calculateAndSetA(compare.a); session.calculations(compare.salt, compare.bb); expect(session.getS().toString(16)).toBe(compare.s); - // failing from here on... expect(session.key()).toBe(compare.k); expect(session.getM()).toBe(compare.m); }); + + it("delegates login", function() { + expect(session.login()).toBe(compare.username); + }); }); diff --git a/spec/signup_spec.js b/spec/signup_spec.js index 4f7a65d..48a62a7 100644 --- a/spec/signup_spec.js +++ b/spec/signup_spec.js @@ -11,7 +11,7 @@ describe("Signup with srp var", function() { specHelper.setupFakeXHR.apply(this); calculate = new srp.Calculate(); calculate.randomSalt = function() {return "4c78c3f8"}; - srp.session = new srp.Session(undefined, undefined, calculate); + srp.session = new srp.Session(undefined, calculate); }); afterEach(function() { |