From 09a7a8c0fb28ff49fac64f282aa136f8a2c20dfe Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 18 Jun 2012 12:34:11 +0200 Subject: initial commit - testing srp auth * This is lacking a few steps. We confirm the secret is the same but no key is generated from it and it is transfered over the wire in clear. * this was inspired by https://gist.github.com/790048 * seperated util, client, server and test code --- test/auth_test.rb | 25 +++++++++++++++++++++++++ test/test_helper.rb | 3 +++ 2 files changed, 28 insertions(+) create mode 100644 test/auth_test.rb create mode 100644 test/test_helper.rb (limited to 'test') diff --git a/test/auth_test.rb b/test/auth_test.rb new file mode 100644 index 0000000..e6c4017 --- /dev/null +++ b/test/auth_test.rb @@ -0,0 +1,25 @@ +require File.expand_path(File.dirname(__FILE__) + '/test_helper') + +class AuthTest < Test::Unit::TestCase + + def setup + @username = 'user' + @password = 'opensasemi' + @client = SRP::Client.new(@username, @password) + @server = SRP::Server.new(@client.salt, @client.verifier) + end + + def test_successful_auth + assert @client.authenticate(@server, @username, @password) + end + + def test_wrong_password + assert !@client.authenticate(@server, @username, "password") + end + + def test_wrong_username + assert !@client.authenticate(@server, "username", @password) + end +end + + diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000..68d3acf --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,3 @@ +require "rubygems" +require 'test/unit' +require File.expand_path(File.dirname(__FILE__) + '/../lib/srp.rb') -- cgit v1.2.3