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 | |
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')
-rw-r--r-- | spec/RestfulSpecRunner.html | 5 | ||||
-rw-r--r-- | spec/restful/login.js | 22 |
2 files changed, 13 insertions, 14 deletions
diff --git a/spec/RestfulSpecRunner.html b/spec/RestfulSpecRunner.html index 2b34e5d..a9d708b 100644 --- a/spec/RestfulSpecRunner.html +++ b/spec/RestfulSpecRunner.html @@ -27,7 +27,7 @@ <!-- include spec files here... --> <script type="text/javascript" src="specHelper.js"></script> <script type="text/javascript" src="restful/signup.js"></script> - <!-- <script type="text/javascript" src="restful/login.js"></script> --> + <script type="text/javascript" src="restful/login.js"></script> <script type="text/javascript" src="restful/session.js"></script> <script type="text/javascript"> @@ -67,9 +67,6 @@ <table> <tr><td>Username:</td><td><input type="text" id="srp_username" value="testuser" /></td></tr> <tr><td>Password:</td><td><input type="password" id="srp_password" value="password"/></td></tr> - <input type="hidden" id="srp_url" value=""/> - <input type="hidden" id="srp_forward" value="#logged_in"/> - <input type="hidden" id="srp_server" value="django"/> </table> <input type="submit"/> </form> 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(); }); }); |