rkerberos 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.md +15 -0
- data/EXAMPLES.md +1015 -0
- data/MANIFEST.md +17 -12
- data/README.md +5 -5
- data/ext/rkerberos/ccache.c +101 -26
- data/ext/rkerberos/config.c +53 -7
- data/ext/rkerberos/context.c +70 -7
- data/ext/rkerberos/kadm5.c +280 -87
- data/ext/rkerberos/keytab.c +210 -64
- data/ext/rkerberos/policy.c +25 -23
- data/ext/rkerberos/principal.c +108 -10
- data/ext/rkerberos/rkerberos.c +229 -28
- data/ext/rkerberos/rkerberos.h +8 -0
- data/rkerberos.gemspec +10 -7
- data/spec/config_spec.rb +33 -0
- data/spec/context_spec.rb +51 -0
- data/spec/credentials_cache_spec.rb +79 -26
- data/spec/kadm5_spec.rb +278 -5
- data/spec/krb5_keytab_spec.rb +224 -20
- data/spec/krb5_spec.rb +131 -20
- data/spec/policy_spec.rb +4 -0
- data/spec/principal_spec.rb +90 -10
- metadata +9 -8
data/spec/principal_spec.rb
CHANGED
|
@@ -5,20 +5,51 @@ require 'rkerberos'
|
|
|
5
5
|
|
|
6
6
|
RSpec.describe Kerberos::Krb5::Principal do
|
|
7
7
|
let(:name) { 'Jon' }
|
|
8
|
-
subject(:princ) { described_class.new(name) }
|
|
8
|
+
subject(:princ) { described_class.new(name: name) }
|
|
9
9
|
|
|
10
10
|
describe 'constructor' do
|
|
11
|
-
it 'requires a string
|
|
12
|
-
expect { described_class.new(1) }.to raise_error(TypeError)
|
|
13
|
-
expect { described_class.new(true) }.to raise_error(TypeError)
|
|
11
|
+
it 'requires name to be a string' do
|
|
12
|
+
expect { described_class.new(name: 1) }.to raise_error(TypeError)
|
|
13
|
+
expect { described_class.new(name: true) }.to raise_error(TypeError)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
it 'accepts
|
|
17
|
-
expect{ described_class.new
|
|
16
|
+
it 'accepts no arguments' do
|
|
17
|
+
expect{ described_class.new }.not_to raise_error
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
it 'works as expected with
|
|
21
|
-
expect(described_class.new
|
|
20
|
+
it 'works as expected with no name argument' do
|
|
21
|
+
expect(described_class.new.principal).to be_nil
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'rejects positional arguments' do
|
|
25
|
+
expect { described_class.new('Jon') }.to raise_error(ArgumentError)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'accepts a context keyword argument' do
|
|
29
|
+
ctx = Kerberos::Krb5::Context.new
|
|
30
|
+
expect { described_class.new(name: 'Jon', context: ctx) }.not_to raise_error
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'rejects positional option hashes and unknown keywords' do
|
|
34
|
+
expect { described_class.new({name: 'Jon'}) }.to raise_error(ArgumentError)
|
|
35
|
+
expect { described_class.new(unknown: true) }.to raise_error(ArgumentError, /unknown keyword/)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'uses the same realm when a context is provided' do
|
|
39
|
+
ctx = Kerberos::Krb5::Context.new
|
|
40
|
+
p1 = described_class.new(name: 'Jon')
|
|
41
|
+
p2 = described_class.new(name: 'Jon', context: ctx)
|
|
42
|
+
expect(p2.realm).to eq(p1.realm)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'raises TypeError for non-Context context argument' do
|
|
46
|
+
expect { described_class.new(name: 'Jon', context: "bad") }.to raise_error(TypeError)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'raises error for a closed context' do
|
|
50
|
+
ctx = Kerberos::Krb5::Context.new
|
|
51
|
+
ctx.close
|
|
52
|
+
expect { described_class.new(name: 'Jon', context: ctx) }.to raise_error(Kerberos::Krb5::Exception)
|
|
22
53
|
end
|
|
23
54
|
end
|
|
24
55
|
|
|
@@ -27,8 +58,8 @@ RSpec.describe Kerberos::Krb5::Principal do
|
|
|
27
58
|
expect(subject.realm).to eq('EXAMPLE.COM')
|
|
28
59
|
end
|
|
29
60
|
|
|
30
|
-
it 'raises an error if
|
|
31
|
-
expect{ described_class.new
|
|
61
|
+
it 'raises an error if no name was provided' do
|
|
62
|
+
expect{ described_class.new.realm }.to raise_error(Kerberos::Krb5::Exception, /no principal/)
|
|
32
63
|
end
|
|
33
64
|
end
|
|
34
65
|
|
|
@@ -83,4 +114,53 @@ RSpec.describe Kerberos::Krb5::Principal do
|
|
|
83
114
|
expect { princ.mod_date }.not_to raise_error
|
|
84
115
|
end
|
|
85
116
|
end
|
|
117
|
+
|
|
118
|
+
describe '#principal_type' do
|
|
119
|
+
it 'returns an integer for a named principal' do
|
|
120
|
+
p = described_class.new(name: 'user@EXAMPLE.COM')
|
|
121
|
+
expect(p.principal_type).to be_a(Integer)
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it 'returns KRB5_NT_PRINCIPAL (1) for a simple name' do
|
|
125
|
+
p = described_class.new(name: 'user@EXAMPLE.COM')
|
|
126
|
+
expect(p.principal_type).to eq(1)
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it 'raises an error when no principal has been established' do
|
|
130
|
+
p = described_class.new
|
|
131
|
+
expect { p.principal_type }.to raise_error(Kerberos::Krb5::Exception, /no principal/)
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
describe '#components' do
|
|
136
|
+
it 'responds to components' do
|
|
137
|
+
expect(princ).to respond_to(:components)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it 'returns an array of strings' do
|
|
141
|
+
result = princ.components
|
|
142
|
+
expect(result).to be_a(Array)
|
|
143
|
+
result.each { |c| expect(c).to be_a(String) }
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
it 'returns one component for a simple principal' do
|
|
147
|
+
p = described_class.new(name: 'user@EXAMPLE.COM')
|
|
148
|
+
expect(p.components).to eq(['user'])
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
it 'returns multiple components for a compound principal' do
|
|
152
|
+
p = described_class.new(name: 'admin/instance@EXAMPLE.COM')
|
|
153
|
+
expect(p.components).to eq(['admin', 'instance'])
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
it 'returns three components for a three-part principal' do
|
|
157
|
+
p = described_class.new(name: 'a/b/c@EXAMPLE.COM')
|
|
158
|
+
expect(p.components).to eq(['a', 'b', 'c'])
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
it 'raises an error when no principal has been established' do
|
|
162
|
+
p = described_class.new
|
|
163
|
+
expect { p.components }.to raise_error(Kerberos::Krb5::Exception, /no principal/)
|
|
164
|
+
end
|
|
165
|
+
end
|
|
86
166
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rkerberos
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Berger
|
|
@@ -66,6 +66,7 @@ extensions:
|
|
|
66
66
|
extra_rdoc_files: []
|
|
67
67
|
files:
|
|
68
68
|
- CHANGES.md
|
|
69
|
+
- EXAMPLES.md
|
|
69
70
|
- Gemfile
|
|
70
71
|
- LICENSE
|
|
71
72
|
- MANIFEST.md
|
|
@@ -93,17 +94,17 @@ files:
|
|
|
93
94
|
- spec/policy_spec.rb
|
|
94
95
|
- spec/principal_spec.rb
|
|
95
96
|
- spec/spec_helper.rb
|
|
96
|
-
homepage:
|
|
97
|
+
homepage: https://github.com/rkerberos/rkerberos
|
|
97
98
|
licenses:
|
|
98
99
|
- Artistic-2.0
|
|
99
100
|
metadata:
|
|
100
|
-
homepage_uri: https://github.com/rkerberos/rkerberos
|
|
101
101
|
bug_tracker_uri: https://github.com/rkerberos/rkerberos/issues
|
|
102
|
-
changelog_uri: https://github.com/rkerberos/rkerberos/blob/
|
|
102
|
+
changelog_uri: https://github.com/rkerberos/rkerberos/blob/master/CHANGES.md
|
|
103
103
|
documentation_uri: https://github.com/rkerberos/rkerberos/wiki
|
|
104
|
+
homepage_uri: https://github.com/rkerberos/rkerberos
|
|
104
105
|
source_code_uri: https://github.com/rkerberos/rkerberos
|
|
105
106
|
wiki_uri: https://github.com/rkerberos/rkerberos/wiki
|
|
106
|
-
github_repo: https://github.com/
|
|
107
|
+
github_repo: https://github.com/rkerberos/rkerberos
|
|
107
108
|
funding_uri: https://github.com/sponsors/rkerberos
|
|
108
109
|
rubygems_mfa_required: 'true'
|
|
109
110
|
rdoc_options: []
|
|
@@ -113,16 +114,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
113
114
|
requirements:
|
|
114
115
|
- - ">="
|
|
115
116
|
- !ruby/object:Gem::Version
|
|
116
|
-
version: '
|
|
117
|
+
version: '3.2'
|
|
117
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
119
|
requirements:
|
|
119
120
|
- - ">="
|
|
120
121
|
- !ruby/object:Gem::Version
|
|
121
122
|
version: '0'
|
|
122
123
|
requirements: []
|
|
123
|
-
rubygems_version: 4.0.
|
|
124
|
+
rubygems_version: 4.0.18
|
|
124
125
|
specification_version: 4
|
|
125
|
-
summary: A Ruby interface for the
|
|
126
|
+
summary: A Ruby interface for the Kerberos library
|
|
126
127
|
test_files:
|
|
127
128
|
- spec/config_spec.rb
|
|
128
129
|
- spec/context_spec.rb
|