diff options
author | Azul <azul@riseup.net> | 2012-11-09 15:04:48 +0100 |
---|---|---|
committer | Azul <azul@riseup.net> | 2012-11-09 15:04:48 +0100 |
commit | efac662cdf31bc4b61ffb97b8c398e22a86c364b (patch) | |
tree | 9425985dd194b5026151a0935d98e50e010c4d22 /spec/restful/login.js | |
parent | 3bf101bc1ef3b5a58fe2f1e2a2e7a681f6de6c09 (diff) | |
parent | 23350b54ec2723e1b2e333626567c9fe9d1e2644 (diff) |
Merge branch 'master' into feature-updated_json_api
Diffstat (limited to 'spec/restful/login.js')
-rw-r--r-- | spec/restful/login.js | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/spec/restful/login.js b/spec/restful/login.js index 0f6aa4f..9c43c00 100644 --- a/spec/restful/login.js +++ b/spec/restful/login.js @@ -5,7 +5,7 @@ describe("Login", function() { expect(typeof srp.identify).toBe('function'); }); - describe("(INTEGRATION)", function (){ + describe("(Compatibility with py-srp)", function (){ // these need to be the same as in the spec runner: var login = "testuser"; var password = "password"; @@ -19,6 +19,7 @@ describe("Login", function() { var K = 'db6ec0bdab81742315861a828323ff492721bdcd114077a4124bc425e4bf328b'; var M = '640e51d5ac5461591c31811221261f0e0eae7c08ce43c85e9556adbd94ed8c26'; var M2 = '49e48f8ac8c4da0e8a7374f73eeedbee2266e123d23fc1be1568523fc9c24b1e'; + var V = '6f5fb78184161f4191babaf1a700ff70e4d261054d002466d05f2ec2b45fc8807dbd7ce25dc3c882331eb8bf72a22caf2868e3438477be7ab151d3281d00aa1a9fc5cb6a725abd99e11882f77d52b56b83f95c0ba0b8fbbf4ee1fbb445c35adb5d1aaa48ba761c4a4417f6bb821fb61956c919e47740b316b960653303fe7190'; var A_, callback; @@ -28,42 +29,48 @@ describe("Login", function() { specHelper.setupFakeXHR.apply(this); A_ = this.srp.session.calculateAndSetA(a) - this.srp.success = sinon.spy(); }); afterEach(function() { this.xhr.restore(); }); - it("starts with the right A", function(){ + it("calculates the same A", function(){ expect(A_).toBe(A); }); - it("calculates the right key", function(){ + it("calculates the same verifier", function(){ + expect(this.srp.session.getV().toString(16)).toBe(V); + }); + + it("calculates the same key", function(){ this.srp.session.calculations(salt, B); expect(this.srp.session.key()).toBe(K); }); it("works with JSON responses", function(){ - this.srp.identify(); + var success = sinon.spy(); + this.srp.identify(success); this.expectRequest('sessions', 'login=' +login+ '&A=' +A, 'POST'); - this.respondJSON({s: salt, B: B}); + this.respondJSON({salt: salt, B: B}); this.expectRequest('sessions/'+login, 'client_auth='+M, 'PUT'); - this.respondJSON({M: M2}); + this.respondJSON({M2: M2}); - expect(this.srp.success).toHaveBeenCalled(); + expect(success).toHaveBeenCalled(); }); it("rejects B = 0", function(){ - this.srp.error = sinon.spy(); - this.srp.identify(); + var success = sinon.spy(); + var error = sinon.spy(); + this.srp.identify(success, error); this.expectRequest('sessions', 'login=' +login+ '&A=' +A, 'POST'); - this.respondJSON({s: salt, B: 0}); + this.respondJSON({salt: salt, B: 0}); // aborting if B=0 expect(this.requests).toEqual([]); - expect(this.srp.error).toHaveBeenCalled(); + expect(error).toHaveBeenCalled(); + expect(success).not.toHaveBeenCalled(); }); }); |