From 7791caac4f3dc8f9b2fcca394ad9ce0cd12b6996 Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 2 Oct 2012 14:29:20 +0200 Subject: fixed restful signup test --- spec/restful/signup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/restful') diff --git a/spec/restful/signup.js b/spec/restful/signup.js index b1ed7e8..e214508 100644 --- a/spec/restful/signup.js +++ b/spec/restful/signup.js @@ -16,7 +16,7 @@ describe("Signup", function() { it("identifies after successful registration (INTEGRATION)", function(){ var callback = sinon.spy(); this.srp.identify = callback; - this.srp.getSalt = function() {return "5d3055e0acd3ddcfc15"}; + this.srp.session.getSalt = function() {return "5d3055e0acd3ddcfc15"}; this.srp.register(); this.expectRequest('users', "user[login]=user&user[password_salt]=5d3055e0acd3ddcfc15&user[password_verifier]=adcd57b4a4a05c2e205b0b7b30014d9ff635d8d8db2f502f08e9b9c132800c44") this.respondJSON({password_salt: "5d3055e0acd3ddcfc15", login: "user", ok: "true"}); -- cgit v1.2.3 From 1c0454cbb1c0b8d75a3c192ff588365ef8bc19d0 Mon Sep 17 00:00:00 2001 From: Azul Date: Fri, 12 Oct 2012 18:52:53 +0200 Subject: got signup to work in accordance with py srp --- spec/restful/signup.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'spec/restful') diff --git a/spec/restful/signup.js b/spec/restful/signup.js index e214508..bc20b14 100644 --- a/spec/restful/signup.js +++ b/spec/restful/signup.js @@ -13,13 +13,17 @@ describe("Signup", function() { expect(typeof this.srp.register).toBe('function'); }); + it("calculates the right x", function(){ + expect(this.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 "5d3055e0acd3ddcfc15"}; + this.srp.session.getSalt = function() {return "4c78c3f8"}; this.srp.register(); - this.expectRequest('users', "user[login]=user&user[password_salt]=5d3055e0acd3ddcfc15&user[password_verifier]=adcd57b4a4a05c2e205b0b7b30014d9ff635d8d8db2f502f08e9b9c132800c44") - this.respondJSON({password_salt: "5d3055e0acd3ddcfc15", login: "user", ok: "true"}); + this.expectRequest('users', "user[login]=testuser&user[password_salt]=4c78c3f8&user[password_verifier]=474c26aa42d11f20544a00f7bf9711c4b5cf7aab95ed448df82b95521b96668e7480b16efce81c861870302560ddf6604c67df54f1d04b99d5bb9d0f02c6051ada5dc9d594f0d4314e12f876cfca3dcd99fc9c98c2e6a5e04298b11061fb8549a22cde0564e91514080df79bca1c38c682214d65d590f66b3719f954b078b83c") + this.respondJSON({password_salt: "4c78c3f8", login: "testuser", ok: "true"}); expect(callback).toHaveBeenCalled(); }); -- cgit v1.2.3 From 6caf581e26c989ec5e2154aa60d6526ff956e381 Mon Sep 17 00:00:00 2001 From: Azul Date: Sun, 14 Oct 2012 15:30:51 +0200 Subject: got SRP v6a test setup and basic rest flow to work * still need to fix the algo for auth * Also need to get the http verbs right --- spec/restful/login.js | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'spec/restful') diff --git a/spec/restful/login.js b/spec/restful/login.js index 729f902..8da6cfd 100644 --- a/spec/restful/login.js +++ b/spec/restful/login.js @@ -6,21 +6,27 @@ describe("Login", function() { }); describe("(INTEGRATION)", function (){ + // these need to be the same as in the spec runner: + var login = "testuser"; + var password = "password"; // a valid auth attempt for the user / password given in the spec runner: - var a = 'af141ae6'; - var B = '887005895b1f5528b4e4dfdce914f73e763b96d3c901d2f41d8b8cd26255a75'; - var salt = '5d3055e0acd3ddcfc15'; - var M = 'be6d7db2186d5f6a2c55788479b6eaf75229a7ca0d9e7dc1f886f1970a0e8065' - var M2 = '2547cf26318519090f506ab73a68995a2626b1c948e6f603ef9e1b0b78bf0f7b'; - var A, callback; + var a = 'a5cccf937ea1bf72df5cf8099442552f5664da6780a75436d5a59bc77a8a9993'; + var A = 'e67d222244564ccd2e37471f226b999a4e987f3d494c7d80e0d36169efd6c6c6d857a96924c25fc165e5e9b0212a31c30701ec376dc32e36be00bbcd6d2104789d368af984e26fc094374f90ee5746478f14cec45c7e131a3cbce15fe79e98894213dac4e63c3f73f644fe25aa8707bc58859dfd1b36972e4e34169db2622899'; + // just for the sake of having a complete set of test vars: + var b = '6aa5c88d1877af9907ccefad31083e1102a7121dc04706f681f66c8680fb7f05'; + var B = 'd56a80aaafdf9f70598b5d1184f122f326a333fafd37ab76d6f7fba4a9c4ee59545be056335150bd64f04880bc8e76949469379fe9de17cf6f36f3ee11713d05f63050486bc73c545163169999ff01b55c0ca4e90d8856a6e3d3a6ffc70b70d993a5308a37a5c2399874344e083e72b3c9afa083d312dfe9096ea9a65023f135'; + var salt = '628365a0'; + var M = '640e51d5ac5461591c31811221261f0e0eae7c08ce43c85e9556adbd94ed8c26'; + var M2 = '49e48f8ac8c4da0e8a7374f73eeedbee2266e123d23fc1be1568523fc9c24b1e'; + var A_, callback; beforeEach(function() { this.srp = new SRP(jqueryRest()); - A = this.srp.calculateAndSetA(a); specHelper.setupFakeXHR.apply(this); + A_ = this.srp.session.calculateAndSetA(a) this.srp.success = sinon.spy(); }); @@ -28,23 +34,16 @@ describe("Login", function() { this.xhr.restore(); }); - it("works with XML responses", function(){ - this.srp.identify(); - - this.expectRequest('handshake/', 'I=user&A='+A); - this.respondXML(""); - this.expectRequest('authenticate/', 'M='+M); - this.respondXML(""+M2+""); - - expect(this.srp.success).toHaveBeenCalled(); + it("starts with the right A", function(){ + expect(A_).toBe(A); }); it("works with JSON responses", function(){ this.srp.identify(); - this.expectRequest('handshake/', 'I=user&A='+A); + this.expectRequest('sessions', 'login=' +login+ '&A=' +A, 'POST'); this.respondJSON({s: salt, B: B}); - this.expectRequest('authenticate/', 'M='+M); + this.expectRequest('sessions/'+login, 'client_auth='+M); this.respondJSON({M: M2}); expect(this.srp.success).toHaveBeenCalled(); @@ -54,7 +53,7 @@ describe("Login", function() { this.srp.error_message = sinon.spy(); this.srp.identify(); - this.expectRequest('handshake/', 'I=user&A='+A); + this.expectRequest('sessions', 'login=' +login+ '&A=' +A, 'POST'); this.respondJSON({s: salt, B: 0}); // aborting if B=0 expect(this.requests).toEqual([]); -- cgit v1.2.3 From 2263abad65b92ef26c8e67097bbcfeb6988ab8fd Mon Sep 17 00:00:00 2001 From: Azul Date: Sun, 14 Oct 2012 16:24:10 +0200 Subject: calculating the right M and M2! still missing some error handling, this in Django specs and the right http verbs --- spec/restful/login.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'spec/restful') diff --git a/spec/restful/login.js b/spec/restful/login.js index 8da6cfd..3bf9dda 100644 --- a/spec/restful/login.js +++ b/spec/restful/login.js @@ -16,6 +16,7 @@ describe("Login", function() { var b = '6aa5c88d1877af9907ccefad31083e1102a7121dc04706f681f66c8680fb7f05'; var B = 'd56a80aaafdf9f70598b5d1184f122f326a333fafd37ab76d6f7fba4a9c4ee59545be056335150bd64f04880bc8e76949469379fe9de17cf6f36f3ee11713d05f63050486bc73c545163169999ff01b55c0ca4e90d8856a6e3d3a6ffc70b70d993a5308a37a5c2399874344e083e72b3c9afa083d312dfe9096ea9a65023f135'; var salt = '628365a0'; + var K = 'db6ec0bdab81742315861a828323ff492721bdcd114077a4124bc425e4bf328b'; var M = '640e51d5ac5461591c31811221261f0e0eae7c08ce43c85e9556adbd94ed8c26'; var M2 = '49e48f8ac8c4da0e8a7374f73eeedbee2266e123d23fc1be1568523fc9c24b1e'; var A_, callback; @@ -38,6 +39,11 @@ describe("Login", function() { expect(A_).toBe(A); }); + it("calculates the right key", function(){ + this.srp.session.calculations(salt, B); + expect(this.srp.session.key()).toBe(K); + }); + it("works with JSON responses", function(){ this.srp.identify(); @@ -63,4 +69,3 @@ describe("Login", function() { }); - -- cgit v1.2.3 From 09a6d9eb8d0467f311bbae3d6fe2d923244edb21 Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 15 Oct 2012 11:10:35 +0200 Subject: all rest tests passing, using proper verbs --- spec/restful/login.js | 6 +++--- spec/restful/signup.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'spec/restful') diff --git a/spec/restful/login.js b/spec/restful/login.js index 3bf9dda..0f6aa4f 100644 --- a/spec/restful/login.js +++ b/spec/restful/login.js @@ -49,21 +49,21 @@ describe("Login", function() { this.expectRequest('sessions', 'login=' +login+ '&A=' +A, 'POST'); this.respondJSON({s: salt, B: B}); - this.expectRequest('sessions/'+login, 'client_auth='+M); + this.expectRequest('sessions/'+login, 'client_auth='+M, 'PUT'); this.respondJSON({M: M2}); expect(this.srp.success).toHaveBeenCalled(); }); it("rejects B = 0", function(){ - this.srp.error_message = sinon.spy(); + this.srp.error = sinon.spy(); this.srp.identify(); this.expectRequest('sessions', 'login=' +login+ '&A=' +A, 'POST'); this.respondJSON({s: salt, B: 0}); // aborting if B=0 expect(this.requests).toEqual([]); - expect(this.srp.error_message).toHaveBeenCalled(); + expect(this.srp.error).toHaveBeenCalled(); }); }); diff --git a/spec/restful/signup.js b/spec/restful/signup.js index bc20b14..7b66dd7 100644 --- a/spec/restful/signup.js +++ b/spec/restful/signup.js @@ -22,7 +22,7 @@ describe("Signup", function() { this.srp.identify = callback; this.srp.session.getSalt = function() {return "4c78c3f8"}; this.srp.register(); - this.expectRequest('users', "user[login]=testuser&user[password_salt]=4c78c3f8&user[password_verifier]=474c26aa42d11f20544a00f7bf9711c4b5cf7aab95ed448df82b95521b96668e7480b16efce81c861870302560ddf6604c67df54f1d04b99d5bb9d0f02c6051ada5dc9d594f0d4314e12f876cfca3dcd99fc9c98c2e6a5e04298b11061fb8549a22cde0564e91514080df79bca1c38c682214d65d590f66b3719f954b078b83c") + this.expectRequest('users', "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