rrba 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env ruby
2
+ # TestUser -- rrba -- 01-11-2004 -- hwyss@ywesee.com
3
+
4
+ $: << File.expand_path('../lib', File.dirname(__FILE__))
5
+
6
+ require 'test/unit'
7
+ require 'rrba/user'
8
+ require 'fileutils'
9
+ require 'openssl'
10
+
11
+ module RRBA
12
+ class TestUser < Test::Unit::TestCase
13
+ def setup
14
+ @user = User.new(1)
15
+ @datadir = File.expand_path('data', File.dirname(__FILE__))
16
+ end
17
+ def test_attr_accessors
18
+ assert_respond_to(@user, :name)
19
+ assert_respond_to(@user, :name=)
20
+ assert_respond_to(@user, :email)
21
+ assert_respond_to(@user, :email=)
22
+ assert_respond_to(@user, :public_key)
23
+ assert_respond_to(@user, :public_key=)
24
+ end
25
+ def test_authenticate__failure
26
+ realkey = OpenSSL::PKey::DSA.generate(8)
27
+ fakekey = OpenSSL::PKey::DSA.generate(8)
28
+ @user.public_key = realkey.public_key
29
+ challenge = 'challenge'
30
+ signature = fakekey.syssign(challenge)
31
+ assert_equal(false, @user.authenticate(challenge, signature))
32
+ end
33
+ def test_authenticate__success
34
+ realkey = OpenSSL::PKey::DSA.generate(8)
35
+ @user.public_key = realkey.public_key
36
+ challenge = 'challenge'
37
+ signature = realkey.syssign(challenge)
38
+ assert_equal(true, @user.authenticate(challenge, signature))
39
+ end
40
+ def test__public_key_writer__public_key
41
+ key = OpenSSL::PKey::DSA.new(8)
42
+ @user.public_key = key.public_key
43
+ assert_instance_of(OpenSSL::PKey::DSA, @user.public_key)
44
+ assert(@user.public_key.public?)
45
+ assert_equal(false, @user.public_key.private?)
46
+ assert(@user.public_key.sysverify('test', key.syssign('test')),
47
+ "could not verify signature")
48
+ end
49
+ def test__public_key_writer__private_key
50
+ key = OpenSSL::PKey::DSA.new(8)
51
+ @user.public_key = key
52
+ assert_instance_of(OpenSSL::PKey::DSA, @user.public_key)
53
+ assert(@user.public_key.public?)
54
+ assert_equal(false, @user.public_key.private?,
55
+ "stored a private key!")
56
+ assert(@user.public_key.sysverify('test', key.syssign('test')),
57
+ "could not verify signature")
58
+ end
59
+ def test_new_session
60
+ assert_raises(NotImplementedError) { @user.new_session }
61
+ end
62
+ end
63
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rrba
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Masaomi Hatakeyama, Zeno R.R. Davatz
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-02-21 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: hoe
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 41
30
+ segments:
31
+ - 2
32
+ - 9
33
+ - 1
34
+ version: 2.9.1
35
+ type: :development
36
+ version_requirements: *id001
37
+ description: Ruby Role-Based Authentication
38
+ email:
39
+ - mhatakeyama@ywesee.com, zdavatz@ywesee.com
40
+ executables: []
41
+
42
+ extensions: []
43
+
44
+ extra_rdoc_files:
45
+ - History.txt
46
+ - Manifest.txt
47
+ - README.txt
48
+ files:
49
+ - History.txt
50
+ - LICENSE
51
+ - Manifest.txt
52
+ - README.txt
53
+ - Rakefile
54
+ - install.rb
55
+ - lib/rrba.rb
56
+ - lib/rrba/error.rb
57
+ - lib/rrba/server.rb
58
+ - lib/rrba/user.rb
59
+ - test/mock.rb
60
+ - test/stub/odba.rb
61
+ - test/suite.rb
62
+ - test/test_server.rb
63
+ - test/test_user.rb
64
+ - .gemtest
65
+ has_rdoc: true
66
+ homepage: http://scm.ywesee.com/?p=rrba/.git;a=summary
67
+ licenses: []
68
+
69
+ post_install_message:
70
+ rdoc_options:
71
+ - --main
72
+ - README.txt
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ hash: 3
81
+ segments:
82
+ - 0
83
+ version: "0"
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ hash: 3
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ requirements: []
94
+
95
+ rubyforge_project: rrba
96
+ rubygems_version: 1.4.2
97
+ signing_key:
98
+ specification_version: 3
99
+ summary: Ruby Role-Based Authentication
100
+ test_files:
101
+ - test/test_server.rb
102
+ - test/test_user.rb