diff options
author | Azul <azul@riseup.net> | 2012-10-17 12:06:37 +0200 |
---|---|---|
committer | Azul <azul@riseup.net> | 2012-10-17 12:06:37 +0200 |
commit | 5a0ceeb1ca0055719a9b8977a799362163955766 (patch) | |
tree | 797bf5fe2dab2fea3b9b0ddb4c6c04be6d33e2e9 /spec/restful | |
parent | d21474a0290edab1c765741d484335d83f50be75 (diff) |
hand success and error messages to identify by default
also cleaned up some other parts that were not needed anymore
Diffstat (limited to 'spec/restful')
-rw-r--r-- | spec/restful/login.js | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/spec/restful/login.js b/spec/restful/login.js index 1bc6108..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"; @@ -29,46 +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("starts with the right verifier", function(){ + it("calculates the same verifier", function(){ expect(this.srp.session.getV().toString(16)).toBe(V); }); - it("calculates the right key", function(){ + 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({salt: salt, B: B}); this.expectRequest('sessions/'+login, 'client_auth='+M, 'PUT'); 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({salt: salt, B: 0}); // aborting if B=0 expect(this.requests).toEqual([]); - expect(this.srp.error).toHaveBeenCalled(); + expect(error).toHaveBeenCalled(); + expect(success).not.toHaveBeenCalled(); }); }); |