From 5267a127ee967b1d89df6033cc9869715e960886 Mon Sep 17 00:00:00 2001 From: Azul Date: Sat, 6 Oct 2012 19:39:48 +0200 Subject: comment out debugging lines --- users/test/integration/api/python/flow_with_srp.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'users/test') diff --git a/users/test/integration/api/python/flow_with_srp.py b/users/test/integration/api/python/flow_with_srp.py index 3bbbc71..0a11aec 100755 --- a/users/test/integration/api/python/flow_with_srp.py +++ b/users/test/integration/api/python/flow_with_srp.py @@ -16,24 +16,24 @@ def id_generator(size=6, chars=string.ascii_uppercase + string.digits): return ''.join(random.choice(chars) for x in range(size)) # using globals for a start -server = 'http://localhost:3000' +server = 'http://springbok/1/' login = id_generator() password = id_generator() + id_generator() -print ' username = "' + login + '"' -print ' password = "' + password + '"' +# print ' username = "' + login + '"' +# print ' password = "' + password + '"' # log the server communication def print_and_parse(response): # print response.request.method + ': ' + response.url # print " " + json.dumps(response.request.data) - print " -> " + response.text + # print " -> " + response.text return json.loads(response.text) def signup(session): salt, vkey = srp.create_salted_verification_key( login, password, srp.SHA256, srp.NG_1024 ) - print ' salt = "' + binascii.hexlify(salt) + '"' - print ' v = "' + binascii.hexlify(vkey) + '"' + # print ' salt = "' + binascii.hexlify(salt) + '"' + # print ' v = "' + binascii.hexlify(vkey) + '"' user_params = { 'user[login]': login, 'user[password_verifier]': binascii.hexlify(vkey), @@ -45,16 +45,16 @@ usr = srp.User( login, password, srp.SHA256, srp.NG_1024 ) def authenticate(session, login): uname, A = usr.start_authentication() - print ' aa = "' + binascii.hexlify(A) + '"' + # print ' aa = "' + binascii.hexlify(A) + '"' params = { 'login': uname, 'A': binascii.hexlify(A) } init = print_and_parse(session.post(server + '/sessions', data = params)) # print ' b = "' + init['b'] + '"' - print ' bb = "' + init['B'] + '"' + # print ' bb = "' + init['B'] + '"' M = usr.process_challenge( safe_unhexlify(init['salt']), safe_unhexlify(init['B']) ) - print ' m = "' + binascii.hexlify(M) + '"' + # print ' m = "' + binascii.hexlify(M) + '"' return session.put(server + '/sessions/' + login, data = {'client_auth': binascii.hexlify(M)}) -- cgit v1.2.3 From d776e9ea988b0bc00b24c0e0760bcfe3d95057a7 Mon Sep 17 00:00:00 2001 From: Azul Date: Sun, 7 Oct 2012 21:00:36 +0200 Subject: adding validations for valid login chars and verifier and salt being hex --- users/test/unit/user_test.rb | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) (limited to 'users/test') diff --git a/users/test/unit/user_test.rb b/users/test/unit/user_test.rb index 870d422..822ef33 100644 --- a/users/test/unit/user_test.rb +++ b/users/test/unit/user_test.rb @@ -3,37 +3,48 @@ require 'test_helper' class UserTest < ActiveSupport::TestCase include SRP::Util + setup do + @attribs = User.valid_attributes_hash + @user = User.new(@attribs) + end + test "test set of attributes should be valid" do - user = User.new(User.valid_attributes_hash) - assert user.valid? + @user.valid? + assert_equal Hash.new, @user.errors.messages + end + + test "test require hex for password_verifier" do + @user.password_verifier = "QWER" + assert !@user.valid? + end + + test "test require alphanumerical for login" do + @user.login = "qwär" + assert !@user.valid? end test "find_by_param gets User by login" do - user = User.create!(User.valid_attributes_hash) - assert_equal user, User.find_by_param(user.login) - user.destroy + @user.save + assert_equal @user, User.find_by_param(@user.login) + @user.destroy end test "to_param gives user login" do - user = User.new(User.valid_attributes_hash) - assert_equal user.login, user.to_param + assert_equal @user.login, @user.to_param end test "verifier returns number for the hex in password_verifier" do - user = User.new(User.valid_attributes_hash) - assert_equal user.password_verifier.hex, user.verifier + assert_equal @user.password_verifier.hex, @user.verifier end test "salt returns number for the hex in password_salt" do - user = User.new(User.valid_attributes_hash) - assert_equal user.password_salt.hex, user.salt + assert_equal @user.password_salt.hex, @user.salt end - test "should include SRP::Authentication" do + test "should include SRP" do client_rnd = bigrand(32).hex - user = User.new(User.valid_attributes_hash) - srp_session = user.initialize_auth(client_rnd) - assert srp_session.is_a? SRP::Authentication::Session + srp_session = @user.initialize_auth(client_rnd) + assert srp_session.is_a? SRP::Session assert_equal client_rnd, srp_session.aa end -- cgit v1.2.3 From f5aea5347601c3500bb3670971d44995c35c3c7b Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 8 Oct 2012 19:50:00 +0200 Subject: use couchrest session store in core, updated dummy path --- users/test/test_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'users/test') diff --git a/users/test/test_helper.rb b/users/test/test_helper.rb index b268c51..08d4d41 100644 --- a/users/test/test_helper.rb +++ b/users/test/test_helper.rb @@ -1,5 +1,5 @@ ENV["RAILS_ENV"] = "test" -require File.expand_path('../dummy/config/environment', __FILE__) +require File.expand_path('../../../test/dummy/config/environment', __FILE__) require 'rails/test_help' require 'mocha' -- cgit v1.2.3