rkerberos 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,123 @@
1
+ ########################################################################
2
+ # test_policy.rb
3
+ #
4
+ # Tests for the Kerberos::Kadm5::Policy class.
5
+ ########################################################################
6
+ require 'rubygems'
7
+ gem 'test-unit'
8
+
9
+ require 'test/unit'
10
+ require 'rkerberos'
11
+
12
+ class TC_Kadm5_Policy < Test::Unit::TestCase
13
+ def setup
14
+ @policy = Kerberos::Kadm5::Policy.new(:name => 'test', :max_life => 10000)
15
+ end
16
+
17
+ test 'policy name basic functionality' do
18
+ assert_respond_to(@policy, :policy)
19
+ end
20
+
21
+ test 'policy name alias' do
22
+ assert_respond_to(@policy, :name)
23
+ assert_alias_method(@policy, :name, :policy)
24
+ end
25
+
26
+ test 'policy name must be a string' do
27
+ assert_raise(TypeError){ Kerberos::Kadm5::Policy.new(:name => 1) }
28
+ end
29
+
30
+ test 'policy name must be present' do
31
+ assert_raise(ArgumentError){ Kerberos::Kadm5::Policy.new(:max_life => 10000) }
32
+ end
33
+
34
+ test 'min_life basic functionality' do
35
+ assert_respond_to(@policy, :min_life)
36
+ assert_nothing_raised{ @policy.min_life }
37
+ end
38
+
39
+ test 'min_life must be a number if not nil' do
40
+ assert_raise(TypeError){
41
+ Kerberos::Kadm5::Policy.new(:name => 'test', :min_life => 'test')
42
+ }
43
+ end
44
+
45
+ test 'max_life basic functionality' do
46
+ assert_respond_to(@policy, :max_life)
47
+ assert_nothing_raised{ @policy.max_life }
48
+ end
49
+
50
+ test 'max_life must be a number if not nil' do
51
+ assert_raise(TypeError){
52
+ Kerberos::Kadm5::Policy.new(:name => 'test', :max_life => 'test')
53
+ }
54
+ end
55
+
56
+ test 'min_length basic functionality' do
57
+ assert_respond_to(@policy, :min_length)
58
+ assert_nothing_raised{ @policy.min_length }
59
+ end
60
+
61
+ test 'min_length must be a number if not nil' do
62
+ assert_raise(TypeError){
63
+ Kerberos::Kadm5::Policy.new(:name => 'test', :min_length => 'test')
64
+ }
65
+ end
66
+
67
+ test 'min_classes basic functionality' do
68
+ assert_respond_to(@policy, :min_classes)
69
+ assert_nothing_raised{ @policy.min_classes }
70
+ end
71
+
72
+ test 'min_classes must be a number if not nil' do
73
+ assert_raise(TypeError){
74
+ Kerberos::Kadm5::Policy.new(:name => 'test', :min_classes => 'test')
75
+ }
76
+ end
77
+
78
+ test 'history_num basic functionality' do
79
+ assert_respond_to(@policy, :history_num)
80
+ assert_nothing_raised{ @policy.history_num }
81
+ end
82
+
83
+ test 'history_num must be a number if not nil' do
84
+ assert_raise(TypeError){
85
+ Kerberos::Kadm5::Policy.new(:name => 'test', :history_num => 'test')
86
+ }
87
+ end
88
+
89
+ test 'instance variables are set as expected from the constructor' do
90
+ @policy = Kerberos::Kadm5::Policy.new(
91
+ :name => 'test',
92
+ :min_life => 8888,
93
+ :max_life => 9999,
94
+ :min_length => 5,
95
+ :min_classes => 2,
96
+ :history_num => 7
97
+ )
98
+
99
+ assert_equal('test', @policy.name)
100
+ assert_equal(8888, @policy.min_life)
101
+ assert_equal(9999, @policy.max_life)
102
+ assert_equal(5, @policy.min_length)
103
+ assert_equal(2, @policy.min_classes)
104
+ assert_equal(7, @policy.history_num)
105
+ end
106
+
107
+ test 'constructor requires one argument' do
108
+ assert_raise(ArgumentError){ Kerberos::Kadm5::Policy.new }
109
+ assert_raise(ArgumentError){ Kerberos::Kadm5::Policy.new('foo', 'bar') }
110
+ end
111
+
112
+ test 'constructor requires a hash argument' do
113
+ assert_raise(TypeError){ Kerberos::Kadm5::Policy.new('test') }
114
+ end
115
+
116
+ test 'constructor raises an error if the hash is empty' do
117
+ assert_raise(ArgumentError){ Kerberos::Kadm5::Policy.new({}) }
118
+ end
119
+
120
+ def teardown
121
+ @policy = nil
122
+ end
123
+ end
@@ -0,0 +1,134 @@
1
+ ########################################################################
2
+ # test_principal.rb
3
+ #
4
+ # Test suite for the Kerberos::Krb5::Principal class.
5
+ ########################################################################
6
+ require 'rubygems'
7
+ gem 'test-unit'
8
+
9
+ require 'open3'
10
+ require 'test/unit'
11
+ require 'rkerberos'
12
+
13
+ class TC_Krb5_Principal < Test::Unit::TestCase
14
+ def setup
15
+ @name = 'Jon'
16
+ @princ = Kerberos::Krb5::Principal.new(@name)
17
+ end
18
+
19
+ test "argument to constructor must be a string" do
20
+ assert_raise(TypeError){ Kerberos::Krb5::Principal.new(1) }
21
+ assert_raise(TypeError){ Kerberos::Krb5::Principal.new(true) }
22
+ end
23
+
24
+ test "name basic functionality" do
25
+ assert_respond_to(@princ, :name)
26
+ assert_nothing_raised{ @princ.name }
27
+ end
28
+
29
+ test "name returns expected results" do
30
+ assert_equal('Jon', @princ.name)
31
+ end
32
+
33
+ test "expire_time basic functionality" do
34
+ assert_respond_to(@princ, :expire_time)
35
+ assert_nothing_raised{ @princ.expire_time }
36
+ end
37
+
38
+ test "last_password_change basic functionality" do
39
+ assert_respond_to(@princ, :last_password_change)
40
+ assert_nothing_raised{ @princ.last_password_change }
41
+ end
42
+
43
+ test "password_expiration basic functionality" do
44
+ assert_respond_to(@princ, :password_expiration)
45
+ assert_nothing_raised{ @princ.password_expiration }
46
+ end
47
+
48
+ test "max_life basic functionality" do
49
+ assert_respond_to(@princ, :max_life)
50
+ assert_nothing_raised{ @princ.max_life }
51
+ end
52
+
53
+ test "mod_name basic functionality" do
54
+ assert_respond_to(@princ, :mod_name)
55
+ assert_nothing_raised{ @princ.mod_name }
56
+ end
57
+
58
+ test "mod_date basic functionality" do
59
+ assert_respond_to(@princ, :mod_date)
60
+ assert_nothing_raised{ @princ.mod_date }
61
+ end
62
+
63
+ test "attributes basic functionality" do
64
+ assert_respond_to(@princ, :attributes)
65
+ assert_nothing_raised{ @princ.attributes }
66
+ end
67
+
68
+ test "kvno basic functionality" do
69
+ assert_respond_to(@princ, :kvno)
70
+ assert_nothing_raised{ @princ.kvno }
71
+ end
72
+
73
+ test "policy basic functionality" do
74
+ assert_respond_to(@princ, :policy)
75
+ assert_nothing_raised{ @princ.policy }
76
+ end
77
+
78
+ test "max_renewable_life basic functionality" do
79
+ assert_respond_to(@princ, :max_renewable_life)
80
+ assert_nothing_raised{ @princ.max_renewable_life }
81
+ end
82
+
83
+ test "last_success basic functionality" do
84
+ assert_respond_to(@princ, :last_success)
85
+ assert_nothing_raised{ @princ.last_success }
86
+ end
87
+
88
+ test "last_failed basic functionality" do
89
+ assert_respond_to(@princ, :last_failed)
90
+ assert_nothing_raised{ @princ.last_failed }
91
+ end
92
+
93
+ test "fail_auth_count basic functionality" do
94
+ assert_respond_to(@princ, :fail_auth_count)
95
+ assert_nothing_raised{ @princ.fail_auth_count }
96
+ end
97
+
98
+ test "constructor accepts a name" do
99
+ assert_nothing_raised{ Kerberos::Krb5::Principal.new('delete_me') }
100
+ end
101
+
102
+ test "passing a name to the constructor sets the instance variable" do
103
+ assert_nothing_raised{ @princ = Kerberos::Krb5::Principal.new('delete_me') }
104
+ assert_equal('delete_me', @princ.name)
105
+ end
106
+
107
+ test "get realm basic functionality" do
108
+ assert_respond_to(@princ, :realm)
109
+ assert_nothing_raised{ @princ.realm }
110
+ assert_kind_of(String, @princ.realm)
111
+ end
112
+
113
+ test "set realm basic functionality" do
114
+ assert_respond_to(@princ, :realm=)
115
+ end
116
+
117
+ test "set realm works as expected" do
118
+ assert_nothing_raised{ @princ.realm = "TEST.REALM" }
119
+ assert_equal("TEST.REALM", @princ.realm)
120
+ end
121
+
122
+ test "equality basic functionality" do
123
+ assert_respond_to(@princ, :==)
124
+ end
125
+
126
+ test "equality works as expected" do
127
+ assert_true(@princ == @princ)
128
+ assert_false(@princ == Kerberos::Krb5::Principal.new('other'))
129
+ end
130
+
131
+ def teardown
132
+ @princ = nil
133
+ end
134
+ end
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rkerberos
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Daniel Berger
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-04-28 00:00:00 -06:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rake-compiler
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: test-unit
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 11
44
+ segments:
45
+ - 2
46
+ - 1
47
+ - 0
48
+ version: 2.1.0
49
+ type: :development
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: dbi-dbrc
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 31
60
+ segments:
61
+ - 1
62
+ - 1
63
+ - 6
64
+ version: 1.1.6
65
+ type: :development
66
+ version_requirements: *id003
67
+ description: " The rkerberos library is an interface for the Kerberos 5 network\n authentication protocol. It wraps the Kerberos C API.\n"
68
+ email: djberg96@gmail.com
69
+ executables: []
70
+
71
+ extensions:
72
+ - ext/rkerberos/extconf.rb
73
+ extra_rdoc_files:
74
+ - README
75
+ - CHANGES
76
+ - MANIFEST
77
+ - ext/rkerberos/principal.c
78
+ - ext/rkerberos/rkerberos.c
79
+ - ext/rkerberos/kadm5.c
80
+ - ext/rkerberos/keytab_entry.c
81
+ - ext/rkerberos/context.c
82
+ - ext/rkerberos/keytab.c
83
+ - ext/rkerberos/ccache.c
84
+ - ext/rkerberos/policy.c
85
+ - ext/rkerberos/config.c
86
+ files:
87
+ - Rakefile
88
+ - README
89
+ - rkerberos.gemspec
90
+ - CHANGES
91
+ - test/test_principal.rb
92
+ - test/test_credentials_cache.rb
93
+ - test/test_config.rb
94
+ - test/test_krb5.rb
95
+ - test/test_context.rb
96
+ - test/test_krb5_keytab.rb
97
+ - test/test_kadm5.rb
98
+ - test/test_keytab_entry.rb
99
+ - test/test_policy.rb
100
+ - MANIFEST
101
+ - ext/rkerberos/extconf.rb
102
+ - ext/rkerberos/principal.c
103
+ - ext/rkerberos/rkerberos.c
104
+ - ext/rkerberos/kadm5.c
105
+ - ext/rkerberos/keytab_entry.c
106
+ - ext/rkerberos/context.c
107
+ - ext/rkerberos/keytab.c
108
+ - ext/rkerberos/ccache.c
109
+ - ext/rkerberos/policy.c
110
+ - ext/rkerberos/rkerberos.h
111
+ - ext/rkerberos/config.c
112
+ has_rdoc: true
113
+ homepage: http://github.com/djberg96/rkerberos
114
+ licenses:
115
+ - Artistic 2.0
116
+ post_install_message:
117
+ rdoc_options: []
118
+
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ hash: 3
127
+ segments:
128
+ - 0
129
+ version: "0"
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ none: false
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ hash: 3
136
+ segments:
137
+ - 0
138
+ version: "0"
139
+ requirements: []
140
+
141
+ rubyforge_project: rkerberos
142
+ rubygems_version: 1.6.2
143
+ signing_key:
144
+ specification_version: 3
145
+ summary: A Ruby interface for the the Kerberos library
146
+ test_files:
147
+ - test/test_principal.rb
148
+ - test/test_credentials_cache.rb
149
+ - test/test_config.rb
150
+ - test/test_krb5.rb
151
+ - test/test_context.rb
152
+ - test/test_krb5_keytab.rb
153
+ - test/test_kadm5.rb
154
+ - test/test_keytab_entry.rb
155
+ - test/test_policy.rb