blob: 431168323264133816b4ff4774c16e0853bd15aa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
require File.expand_path(File.dirname(__FILE__) + '/test_helper')
class User
include SRP::Authentication
attr_accessor :salt, :verifier
def initialize(salt, verifier)
@salt = salt
@verifier = verifier
end
def handshake(login, aa)
@session = initialize_auth(aa)
return @session.bb
end
def validate(m)
authenticate(m, @session)
end
end
class AuthTest < Test::Unit::TestCase
def setup
@username = 'user'
@password = 'opensesami'
@client = SRP::Client.new(@username, @password)
@server = User.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, "wrong password")
end
def test_wrong_username
assert !@client.authenticate(@server, "wrong username", @password)
end
end
|