From 2e365cba5263ec50f10fb074c054ef19adb8f7b0 Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 19 Nov 2012 17:36:49 +0100 Subject: first step at cleaning up the srp --- spec/signup_spec.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'spec/signup_spec.js') diff --git a/spec/signup_spec.js b/spec/signup_spec.js index e4d70df..fcb5930 100644 --- a/spec/signup_spec.js +++ b/spec/signup_spec.js @@ -29,4 +29,26 @@ describe("Signup", function() { }); +describe("Signup with srp var", function() { + + beforeEach(function() { + specHelper.setupFakeXHR.apply(this); + }); + + afterEach(function() { + this.xhr.restore(); + }); + + it("identifies after successful registration (INTEGRATION)", function(){ + var callback = sinon.spy(); + srp.signedUp = callback; + srp.session = new SRP().session + srp.session.getSalt = function() {return "4c78c3f8"}; + srp.signup(); + this.expectRequest('users.json', "user[login]=testuser&user[password_salt]=4c78c3f8&user[password_verifier]=474c26aa42d11f20544a00f7bf9711c4b5cf7aab95ed448df82b95521b96668e7480b16efce81c861870302560ddf6604c67df54f1d04b99d5bb9d0f02c6051ada5dc9d594f0d4314e12f876cfca3dcd99fc9c98c2e6a5e04298b11061fb8549a22cde0564e91514080df79bca1c38c682214d65d590f66b3719f954b078b83c", 'POST') + this.respondJSON({password_salt: "4c78c3f8", login: "testuser", ok: "true"}); + expect(callback).toHaveBeenCalled(); + }); + +}); -- cgit v1.2.3 From a41d7f306aa1dbcae17643cc9c3b457632ee8909 Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 19 Nov 2012 17:49:18 +0100 Subject: removed the SRP class - using just a plain srp object now --- spec/signup_spec.js | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) (limited to 'spec/signup_spec.js') diff --git a/spec/signup_spec.js b/spec/signup_spec.js index fcb5930..41af179 100644 --- a/spec/signup_spec.js +++ b/spec/signup_spec.js @@ -1,38 +1,19 @@ -describe("Signup", function() { - - beforeEach(function() { - this.srp = new SRP(jqueryRest()); - specHelper.setupFakeXHR.apply(this); - }); - - afterEach(function() { - this.xhr.restore(); - }); - - it("has a register function", function() { - expect(typeof this.srp.register).toBe('function'); +describe("Loading SRP", function() { + it("provides a signup function", function() { + expect(typeof srp.signup).toBe('function'); }); - it("calculates the right x", function(){ - expect(this.srp.session.calcX("7686acb8").toString(16)).toBe('84d6bb567ddf584b1d8c8728289644d45dbfbb02deedd05c0f64db96740f0398'); + it("provides session which calculates the right x", function(){ + srp.session = new srp.Session(); + expect(srp.session.calcX("7686acb8").toString(16)).toBe('84d6bb567ddf584b1d8c8728289644d45dbfbb02deedd05c0f64db96740f0398'); }); - - it("identifies after successful registration (INTEGRATION)", function(){ - var callback = sinon.spy(); - this.srp.identify = callback; - this.srp.session.getSalt = function() {return "4c78c3f8"}; - this.srp.register(); - this.expectRequest('users.json', "user[login]=testuser&user[password_salt]=4c78c3f8&user[password_verifier]=474c26aa42d11f20544a00f7bf9711c4b5cf7aab95ed448df82b95521b96668e7480b16efce81c861870302560ddf6604c67df54f1d04b99d5bb9d0f02c6051ada5dc9d594f0d4314e12f876cfca3dcd99fc9c98c2e6a5e04298b11061fb8549a22cde0564e91514080df79bca1c38c682214d65d590f66b3719f954b078b83c", 'POST') - this.respondJSON({password_salt: "4c78c3f8", login: "testuser", ok: "true"}); - expect(callback).toHaveBeenCalled(); - }); - }); describe("Signup with srp var", function() { beforeEach(function() { specHelper.setupFakeXHR.apply(this); + srp.session = new srp.Session(); }); afterEach(function() { @@ -42,7 +23,6 @@ describe("Signup with srp var", function() { it("identifies after successful registration (INTEGRATION)", function(){ var callback = sinon.spy(); srp.signedUp = callback; - srp.session = new SRP().session srp.session.getSalt = function() {return "4c78c3f8"}; srp.signup(); this.expectRequest('users.json', "user[login]=testuser&user[password_salt]=4c78c3f8&user[password_verifier]=474c26aa42d11f20544a00f7bf9711c4b5cf7aab95ed448df82b95521b96668e7480b16efce81c861870302560ddf6604c67df54f1d04b99d5bb9d0f02c6051ada5dc9d594f0d4314e12f876cfca3dcd99fc9c98c2e6a5e04298b11061fb8549a22cde0564e91514080df79bca1c38c682214d65d590f66b3719f954b078b83c", 'POST') -- cgit v1.2.3