rubyntlm 0.5.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -3
- data/.rspec +2 -2
- data/.travis.yml +10 -11
- data/CHANGELOG.md +5 -5
- data/Gemfile +3 -3
- data/LICENSE +19 -19
- data/Rakefile +22 -22
- data/lib/net/ntlm.rb +266 -263
- data/lib/net/ntlm/blob.rb +28 -28
- data/lib/net/ntlm/channel_binding.rb +65 -0
- data/lib/net/ntlm/client.rb +65 -65
- data/lib/net/ntlm/client/session.rb +237 -223
- data/lib/net/ntlm/encode_util.rb +49 -49
- data/lib/net/ntlm/exceptions.rb +14 -0
- data/lib/net/ntlm/field.rb +34 -34
- data/lib/net/ntlm/field_set.rb +129 -129
- data/lib/net/ntlm/int16_le.rb +25 -25
- data/lib/net/ntlm/int32_le.rb +24 -24
- data/lib/net/ntlm/int64_le.rb +25 -25
- data/lib/net/ntlm/message.rb +129 -129
- data/lib/net/ntlm/message/type0.rb +16 -16
- data/lib/net/ntlm/message/type1.rb +18 -18
- data/lib/net/ntlm/message/type2.rb +102 -102
- data/lib/net/ntlm/message/type3.rb +131 -131
- data/lib/net/ntlm/security_buffer.rb +47 -47
- data/lib/net/ntlm/string.rb +34 -34
- data/lib/net/ntlm/target_info.rb +89 -0
- data/lib/net/ntlm/version.rb +11 -11
- data/rubyntlm.gemspec +28 -28
- data/spec/lib/net/ntlm/blob_spec.rb +16 -16
- data/spec/lib/net/ntlm/channel_binding_spec.rb +17 -0
- data/spec/lib/net/ntlm/client/session_spec.rb +68 -68
- data/spec/lib/net/ntlm/client_spec.rb +64 -64
- data/spec/lib/net/ntlm/encode_util_spec.rb +16 -16
- data/spec/lib/net/ntlm/field_set_spec.rb +33 -33
- data/spec/lib/net/ntlm/field_spec.rb +34 -34
- data/spec/lib/net/ntlm/int16_le_spec.rb +17 -17
- data/spec/lib/net/ntlm/int32_le_spec.rb +18 -18
- data/spec/lib/net/ntlm/int64_le_spec.rb +18 -18
- data/spec/lib/net/ntlm/message/type0_spec.rb +20 -20
- data/spec/lib/net/ntlm/message/type1_spec.rb +131 -131
- data/spec/lib/net/ntlm/message/type2_spec.rb +132 -132
- data/spec/lib/net/ntlm/message/type3_spec.rb +225 -225
- data/spec/lib/net/ntlm/message_spec.rb +16 -16
- data/spec/lib/net/ntlm/security_buffer_spec.rb +64 -64
- data/spec/lib/net/ntlm/string_spec.rb +72 -72
- data/spec/lib/net/ntlm/target_info_spec.rb +76 -0
- data/spec/lib/net/ntlm/version_spec.rb +27 -27
- data/spec/lib/net/ntlm_spec.rb +127 -127
- data/spec/spec_helper.rb +22 -22
- data/spec/support/certificates/sha_256_hash.pem +19 -0
- data/spec/support/shared/examples/net/ntlm/field_shared.rb +25 -25
- data/spec/support/shared/examples/net/ntlm/fieldset_shared.rb +239 -239
- data/spec/support/shared/examples/net/ntlm/int_shared.rb +43 -43
- data/spec/support/shared/examples/net/ntlm/message_shared.rb +35 -35
- metadata +12 -3
data/spec/spec_helper.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
require 'pathname'
|
3
|
-
|
4
|
-
SimpleCov.start do
|
5
|
-
add_filter '/spec/'
|
6
|
-
add_filter '/config/'
|
7
|
-
add_filter '/vendor/'
|
8
|
-
end if ENV["COVERAGE"]
|
9
|
-
|
10
|
-
require 'rspec'
|
11
|
-
require 'net/ntlm'
|
12
|
-
|
13
|
-
# add project lib directory to load path
|
14
|
-
spec_pathname = Pathname.new(__FILE__).dirname
|
15
|
-
root_pathname = spec_pathname.join('..').expand_path
|
16
|
-
# Requires supporting ruby files with custom matchers and macros, etc,
|
17
|
-
# in spec/support/ and its subdirectories.
|
18
|
-
support_glob = root_pathname.join('spec', 'support', '**', '*.rb')
|
19
|
-
|
20
|
-
Dir.glob(support_glob) do |path|
|
21
|
-
require path
|
22
|
-
end
|
1
|
+
require 'simplecov'
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
SimpleCov.start do
|
5
|
+
add_filter '/spec/'
|
6
|
+
add_filter '/config/'
|
7
|
+
add_filter '/vendor/'
|
8
|
+
end if ENV["COVERAGE"]
|
9
|
+
|
10
|
+
require 'rspec'
|
11
|
+
require 'net/ntlm'
|
12
|
+
|
13
|
+
# add project lib directory to load path
|
14
|
+
spec_pathname = Pathname.new(__FILE__).dirname
|
15
|
+
root_pathname = spec_pathname.join('..').expand_path
|
16
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
17
|
+
# in spec/support/ and its subdirectories.
|
18
|
+
support_glob = root_pathname.join('spec', 'support', '**', '*.rb')
|
19
|
+
|
20
|
+
Dir.glob(support_glob) do |path|
|
21
|
+
require path
|
22
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIDKjCCAhKgAwIBAgIQV0qwsk2MCoxI2Do7IQ6eQzANBgkqhkiG9w0BAQsFADAa
|
3
|
+
MRgwFgYDVQQDDA8xOTIuMTY4LjEzNy4xNjEwHhcNMTYwMTI3MjIyMzA5WhcNMTcw
|
4
|
+
MTI3MjI0MzA5WjAaMRgwFgYDVQQDDA8xOTIuMTY4LjEzNy4xNjEwggEiMA0GCSqG
|
5
|
+
SIb3DQEBAQUAA4IBDwAwggEKAoIBAQC+bGWZQFYjF+bV1WJ1L/MGVNmJR89aJ44Z
|
6
|
+
rKI/IXKFdbn5wjQPWng/DcaHR6xtMXQkc22boe58GK/uzl84ofbRa6qtboa5djdZ
|
7
|
+
9CGsd4Yf6CnVz4mhKSi+BnLi80ydhIRByxoX5bGcCSW6dixR5XiNMaMKzhCjQ+of
|
8
|
+
TU+PBNt7doXB7p0mO4AZz42v4rorRiPNasETj6wlKhFKCMvPLePTwphCgCQsLvgG
|
9
|
+
NQKtFD7TXvrZwplPSeCPhnzd1vHoZMisMn8ZVQ5dAfSEGGkPkOLO0htbUbdaNMoU
|
10
|
+
DPyo7Bu62Q/dqqo1MNbMYM5Ilw8mxe4drOs9UupH0eMovFhVMO0LAgMBAAGjbDBq
|
11
|
+
MA4GA1UdDwEB/wQEAwIFoDAdBgNVHSUEFjAUBggrBgEFBQcDAgYIKwYBBQUHAwEw
|
12
|
+
GgYDVR0RBBMwEYIPMTkyLjE2OC4xMzcuMTYxMB0GA1UdDgQWBBSLuqyHonSmdm8m
|
13
|
+
9R+z2obO/X3/+TANBgkqhkiG9w0BAQsFAAOCAQEAH4pDGBclTHrwF+Bkbfj81ibK
|
14
|
+
E2SJSHbdhSx6YCsR28jXUOESfaik5ZPPMXscJqVc1FPpsU9clPFnGiAf0Kt48gsR
|
15
|
+
twfrRSGgJRv1ZgQyJ4dEQkXbQf2+8uY25Rv4kkFDSvPrE6E9o9Jf9bjqefUYski1
|
16
|
+
YoYdWzgrh/2qoNhnM34wizZgE1bWYbWA9MlUuWH9q/OBEx9uP/K53SXOR7DRzYcY
|
17
|
+
Kg1Z7hV86nvc0WutjEadgdtvJ7eUlg8vAWZqWo5SIdp69l0OEWUlHiaRsPImS5Hd
|
18
|
+
pX3W8n0wHCxBSntDww7U3SHg6DrYf72taBIQW7xFf63S37yLP4CNss68GqPdyQ==
|
19
|
+
-----END CERTIFICATE-----
|
@@ -1,25 +1,25 @@
|
|
1
|
-
shared_examples_for 'a field' do | value, active|
|
2
|
-
|
3
|
-
subject do
|
4
|
-
described_class.new({
|
5
|
-
:value => value,
|
6
|
-
:active => active
|
7
|
-
})
|
8
|
-
end
|
9
|
-
|
10
|
-
it { should respond_to :active }
|
11
|
-
it { should respond_to :value }
|
12
|
-
it { should respond_to :size }
|
13
|
-
it { should respond_to :parse }
|
14
|
-
it { should respond_to :serialize }
|
15
|
-
|
16
|
-
|
17
|
-
it 'should set the value from initialize options' do
|
18
|
-
expect(subject.value).to eq(value)
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should set active from initialize options' do
|
22
|
-
expect(subject.active).to eq(active)
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
1
|
+
shared_examples_for 'a field' do | value, active|
|
2
|
+
|
3
|
+
subject do
|
4
|
+
described_class.new({
|
5
|
+
:value => value,
|
6
|
+
:active => active
|
7
|
+
})
|
8
|
+
end
|
9
|
+
|
10
|
+
it { should respond_to :active }
|
11
|
+
it { should respond_to :value }
|
12
|
+
it { should respond_to :size }
|
13
|
+
it { should respond_to :parse }
|
14
|
+
it { should respond_to :serialize }
|
15
|
+
|
16
|
+
|
17
|
+
it 'should set the value from initialize options' do
|
18
|
+
expect(subject.value).to eq(value)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should set active from initialize options' do
|
22
|
+
expect(subject.active).to eq(active)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -1,239 +1,239 @@
|
|
1
|
-
shared_examples_for 'a fieldset' do |fields|
|
2
|
-
|
3
|
-
subject(:fieldset_class) do
|
4
|
-
Class.new(described_class)
|
5
|
-
end
|
6
|
-
|
7
|
-
context 'the class' do
|
8
|
-
it { should respond_to :string }
|
9
|
-
it { should respond_to :int16LE }
|
10
|
-
it { should respond_to :int32LE }
|
11
|
-
it { should respond_to :int64LE }
|
12
|
-
it { should respond_to :security_buffer }
|
13
|
-
it { should respond_to :prototypes }
|
14
|
-
it { should respond_to :names }
|
15
|
-
it { should respond_to :types }
|
16
|
-
it { should respond_to :opts }
|
17
|
-
|
18
|
-
context 'adding a String Field' do
|
19
|
-
before(:each) do
|
20
|
-
fieldset_class.string(:test_string, { :value => 'Test'})
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'should set the prototypes correctly' do
|
24
|
-
expect(fieldset_class.prototypes).to include([:test_string, Net::NTLM::String, {:value=>"Test"}])
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'should set the names correctly' do
|
28
|
-
expect(fieldset_class.names).to include(:test_string)
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'should set the types correctly' do
|
32
|
-
expect(fieldset_class.types).to include(Net::NTLM::String)
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'should set the opts correctly' do
|
36
|
-
expect(fieldset_class.opts).to include({:value => 'Test'})
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'when creating an instance' do
|
40
|
-
let(:fieldset_object) do
|
41
|
-
fieldset_class.new
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'should have the new accessor' do
|
45
|
-
expect(fieldset_object).to respond_to(:test_string)
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'should have the correct default value' do
|
49
|
-
expect(fieldset_object.test_string).to eq('Test')
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context 'adding a Int16LE Field' do
|
55
|
-
before(:each) do
|
56
|
-
fieldset_class.int16LE(:test_int, { :value => 15})
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'should set the prototypes correctly' do
|
60
|
-
expect(fieldset_class.prototypes).to include([:test_int, Net::NTLM::Int16LE, {:value=>15}])
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'should set the names correctly' do
|
64
|
-
expect(fieldset_class.names).to include(:test_int)
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'should set the types correctly' do
|
68
|
-
expect(fieldset_class.types).to include(Net::NTLM::Int16LE)
|
69
|
-
end
|
70
|
-
|
71
|
-
it 'should set the opts correctly' do
|
72
|
-
expect(fieldset_class.opts).to include({:value => 15})
|
73
|
-
end
|
74
|
-
|
75
|
-
context 'when creating an instance' do
|
76
|
-
let(:fieldset_object) do
|
77
|
-
fieldset_class.new
|
78
|
-
end
|
79
|
-
|
80
|
-
it 'should have the new accessor' do
|
81
|
-
expect(fieldset_object).to respond_to(:test_int)
|
82
|
-
end
|
83
|
-
|
84
|
-
it 'should have the correct default value' do
|
85
|
-
expect(fieldset_object.test_int).to eq(15)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
context 'adding a Int32LE Field' do
|
91
|
-
before(:each) do
|
92
|
-
fieldset_class.int32LE(:test_int, { :value => 15})
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'should set the prototypes correctly' do
|
96
|
-
expect(fieldset_class.prototypes).to include([:test_int, Net::NTLM::Int32LE, {:value=>15}])
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'should set the names correctly' do
|
100
|
-
expect(fieldset_class.names).to include(:test_int)
|
101
|
-
end
|
102
|
-
|
103
|
-
it 'should set the types correctly' do
|
104
|
-
expect(fieldset_class.types).to include(Net::NTLM::Int32LE)
|
105
|
-
end
|
106
|
-
|
107
|
-
it 'should set the opts correctly' do
|
108
|
-
expect(fieldset_class.opts).to include({:value => 15})
|
109
|
-
end
|
110
|
-
|
111
|
-
context 'when creating an instance' do
|
112
|
-
let(:fieldset_object) do
|
113
|
-
fieldset_class.new
|
114
|
-
end
|
115
|
-
|
116
|
-
it 'should have the new accessor' do
|
117
|
-
expect(fieldset_object).to respond_to(:test_int)
|
118
|
-
end
|
119
|
-
|
120
|
-
it 'should have the correct default value' do
|
121
|
-
expect(fieldset_object.test_int).to eq(15)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
context 'adding a Int64LE Field' do
|
127
|
-
before(:each) do
|
128
|
-
fieldset_class.int64LE(:test_int, { :value => 15})
|
129
|
-
end
|
130
|
-
|
131
|
-
it 'should set the prototypes correctly' do
|
132
|
-
expect(fieldset_class.prototypes).to include([:test_int, Net::NTLM::Int64LE, {:value=>15}])
|
133
|
-
end
|
134
|
-
|
135
|
-
it 'should set the names correctly' do
|
136
|
-
expect(fieldset_class.names).to include(:test_int)
|
137
|
-
end
|
138
|
-
|
139
|
-
it 'should set the types correctly' do
|
140
|
-
expect(fieldset_class.types).to include(Net::NTLM::Int64LE)
|
141
|
-
end
|
142
|
-
|
143
|
-
it 'should set the opts correctly' do
|
144
|
-
expect(fieldset_class.opts).to include({:value => 15})
|
145
|
-
end
|
146
|
-
|
147
|
-
context 'when creating an instance' do
|
148
|
-
let(:fieldset_object) do
|
149
|
-
fieldset_class.new
|
150
|
-
end
|
151
|
-
|
152
|
-
it 'should have the new accessor' do
|
153
|
-
expect(fieldset_object).to respond_to(:test_int)
|
154
|
-
end
|
155
|
-
|
156
|
-
it 'should have the correct default value' do
|
157
|
-
expect(fieldset_object.test_int).to eq(15)
|
158
|
-
end
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
context 'adding a SecurityBuffer Field' do
|
163
|
-
before(:each) do
|
164
|
-
fieldset_class.security_buffer(:test_buffer, { :value => 15})
|
165
|
-
end
|
166
|
-
|
167
|
-
it 'should set the prototypes correctly' do
|
168
|
-
expect(fieldset_class.prototypes).to include([:test_buffer, Net::NTLM::SecurityBuffer, {:value=>15}])
|
169
|
-
end
|
170
|
-
|
171
|
-
it 'should set the names correctly' do
|
172
|
-
expect(fieldset_class.names).to include(:test_buffer)
|
173
|
-
end
|
174
|
-
|
175
|
-
it 'should set the types correctly' do
|
176
|
-
expect(fieldset_class.types).to include(Net::NTLM::SecurityBuffer)
|
177
|
-
end
|
178
|
-
|
179
|
-
it 'should set the opts correctly' do
|
180
|
-
expect(fieldset_class.opts).to include({:value => 15})
|
181
|
-
end
|
182
|
-
|
183
|
-
context 'when creating an instance' do
|
184
|
-
let(:fieldset_object) do
|
185
|
-
fieldset_class.new
|
186
|
-
end
|
187
|
-
|
188
|
-
it 'should have the new accessor' do
|
189
|
-
expect(fieldset_object).to respond_to :test_buffer
|
190
|
-
end
|
191
|
-
|
192
|
-
it 'should have the correct default value' do
|
193
|
-
expect(fieldset_object.test_buffer).to eq(15)
|
194
|
-
end
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
end
|
199
|
-
|
200
|
-
context 'an instance' do
|
201
|
-
|
202
|
-
subject(:fieldset_object) do
|
203
|
-
# FieldSet Base Class and Message Base Class
|
204
|
-
# have no fields by default and thus cannot be initialized
|
205
|
-
# currently. Clumsy workaround for now.
|
206
|
-
if described_class.names.empty?
|
207
|
-
described_class.string(:test_string, { :value => 'Test', :active => true, :size => 4})
|
208
|
-
end
|
209
|
-
described_class.new
|
210
|
-
end
|
211
|
-
|
212
|
-
it { should respond_to :serialize }
|
213
|
-
it { should respond_to :parse }
|
214
|
-
it { should respond_to :size }
|
215
|
-
it { should respond_to :enable }
|
216
|
-
it { should respond_to :disable }
|
217
|
-
|
218
|
-
context 'fields' do
|
219
|
-
fields.each do |field|
|
220
|
-
it { should respond_to field[:name] }
|
221
|
-
|
222
|
-
context "#{field[:name]}" do
|
223
|
-
it "should be a #{field[:class].to_s}" do
|
224
|
-
expect(fieldset_object[field[:name]].class).to eq(field[:class])
|
225
|
-
end
|
226
|
-
|
227
|
-
it "should have a default value of #{field[:value]}" do
|
228
|
-
expect(fieldset_object[field[:name]].value).to eq(field[:value])
|
229
|
-
end
|
230
|
-
|
231
|
-
it "should have active set to #{field[:active]}" do
|
232
|
-
expect(fieldset_object[field[:name]].active).to eq(field[:active])
|
233
|
-
end
|
234
|
-
end
|
235
|
-
end
|
236
|
-
end
|
237
|
-
|
238
|
-
end
|
239
|
-
end
|
1
|
+
shared_examples_for 'a fieldset' do |fields|
|
2
|
+
|
3
|
+
subject(:fieldset_class) do
|
4
|
+
Class.new(described_class)
|
5
|
+
end
|
6
|
+
|
7
|
+
context 'the class' do
|
8
|
+
it { should respond_to :string }
|
9
|
+
it { should respond_to :int16LE }
|
10
|
+
it { should respond_to :int32LE }
|
11
|
+
it { should respond_to :int64LE }
|
12
|
+
it { should respond_to :security_buffer }
|
13
|
+
it { should respond_to :prototypes }
|
14
|
+
it { should respond_to :names }
|
15
|
+
it { should respond_to :types }
|
16
|
+
it { should respond_to :opts }
|
17
|
+
|
18
|
+
context 'adding a String Field' do
|
19
|
+
before(:each) do
|
20
|
+
fieldset_class.string(:test_string, { :value => 'Test'})
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should set the prototypes correctly' do
|
24
|
+
expect(fieldset_class.prototypes).to include([:test_string, Net::NTLM::String, {:value=>"Test"}])
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should set the names correctly' do
|
28
|
+
expect(fieldset_class.names).to include(:test_string)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should set the types correctly' do
|
32
|
+
expect(fieldset_class.types).to include(Net::NTLM::String)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should set the opts correctly' do
|
36
|
+
expect(fieldset_class.opts).to include({:value => 'Test'})
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'when creating an instance' do
|
40
|
+
let(:fieldset_object) do
|
41
|
+
fieldset_class.new
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should have the new accessor' do
|
45
|
+
expect(fieldset_object).to respond_to(:test_string)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'should have the correct default value' do
|
49
|
+
expect(fieldset_object.test_string).to eq('Test')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'adding a Int16LE Field' do
|
55
|
+
before(:each) do
|
56
|
+
fieldset_class.int16LE(:test_int, { :value => 15})
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should set the prototypes correctly' do
|
60
|
+
expect(fieldset_class.prototypes).to include([:test_int, Net::NTLM::Int16LE, {:value=>15}])
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should set the names correctly' do
|
64
|
+
expect(fieldset_class.names).to include(:test_int)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should set the types correctly' do
|
68
|
+
expect(fieldset_class.types).to include(Net::NTLM::Int16LE)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should set the opts correctly' do
|
72
|
+
expect(fieldset_class.opts).to include({:value => 15})
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'when creating an instance' do
|
76
|
+
let(:fieldset_object) do
|
77
|
+
fieldset_class.new
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should have the new accessor' do
|
81
|
+
expect(fieldset_object).to respond_to(:test_int)
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should have the correct default value' do
|
85
|
+
expect(fieldset_object.test_int).to eq(15)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context 'adding a Int32LE Field' do
|
91
|
+
before(:each) do
|
92
|
+
fieldset_class.int32LE(:test_int, { :value => 15})
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'should set the prototypes correctly' do
|
96
|
+
expect(fieldset_class.prototypes).to include([:test_int, Net::NTLM::Int32LE, {:value=>15}])
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'should set the names correctly' do
|
100
|
+
expect(fieldset_class.names).to include(:test_int)
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'should set the types correctly' do
|
104
|
+
expect(fieldset_class.types).to include(Net::NTLM::Int32LE)
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'should set the opts correctly' do
|
108
|
+
expect(fieldset_class.opts).to include({:value => 15})
|
109
|
+
end
|
110
|
+
|
111
|
+
context 'when creating an instance' do
|
112
|
+
let(:fieldset_object) do
|
113
|
+
fieldset_class.new
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'should have the new accessor' do
|
117
|
+
expect(fieldset_object).to respond_to(:test_int)
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'should have the correct default value' do
|
121
|
+
expect(fieldset_object.test_int).to eq(15)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
context 'adding a Int64LE Field' do
|
127
|
+
before(:each) do
|
128
|
+
fieldset_class.int64LE(:test_int, { :value => 15})
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'should set the prototypes correctly' do
|
132
|
+
expect(fieldset_class.prototypes).to include([:test_int, Net::NTLM::Int64LE, {:value=>15}])
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'should set the names correctly' do
|
136
|
+
expect(fieldset_class.names).to include(:test_int)
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'should set the types correctly' do
|
140
|
+
expect(fieldset_class.types).to include(Net::NTLM::Int64LE)
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'should set the opts correctly' do
|
144
|
+
expect(fieldset_class.opts).to include({:value => 15})
|
145
|
+
end
|
146
|
+
|
147
|
+
context 'when creating an instance' do
|
148
|
+
let(:fieldset_object) do
|
149
|
+
fieldset_class.new
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'should have the new accessor' do
|
153
|
+
expect(fieldset_object).to respond_to(:test_int)
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'should have the correct default value' do
|
157
|
+
expect(fieldset_object.test_int).to eq(15)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
context 'adding a SecurityBuffer Field' do
|
163
|
+
before(:each) do
|
164
|
+
fieldset_class.security_buffer(:test_buffer, { :value => 15})
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'should set the prototypes correctly' do
|
168
|
+
expect(fieldset_class.prototypes).to include([:test_buffer, Net::NTLM::SecurityBuffer, {:value=>15}])
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'should set the names correctly' do
|
172
|
+
expect(fieldset_class.names).to include(:test_buffer)
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'should set the types correctly' do
|
176
|
+
expect(fieldset_class.types).to include(Net::NTLM::SecurityBuffer)
|
177
|
+
end
|
178
|
+
|
179
|
+
it 'should set the opts correctly' do
|
180
|
+
expect(fieldset_class.opts).to include({:value => 15})
|
181
|
+
end
|
182
|
+
|
183
|
+
context 'when creating an instance' do
|
184
|
+
let(:fieldset_object) do
|
185
|
+
fieldset_class.new
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'should have the new accessor' do
|
189
|
+
expect(fieldset_object).to respond_to :test_buffer
|
190
|
+
end
|
191
|
+
|
192
|
+
it 'should have the correct default value' do
|
193
|
+
expect(fieldset_object.test_buffer).to eq(15)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|
199
|
+
|
200
|
+
context 'an instance' do
|
201
|
+
|
202
|
+
subject(:fieldset_object) do
|
203
|
+
# FieldSet Base Class and Message Base Class
|
204
|
+
# have no fields by default and thus cannot be initialized
|
205
|
+
# currently. Clumsy workaround for now.
|
206
|
+
if described_class.names.empty?
|
207
|
+
described_class.string(:test_string, { :value => 'Test', :active => true, :size => 4})
|
208
|
+
end
|
209
|
+
described_class.new
|
210
|
+
end
|
211
|
+
|
212
|
+
it { should respond_to :serialize }
|
213
|
+
it { should respond_to :parse }
|
214
|
+
it { should respond_to :size }
|
215
|
+
it { should respond_to :enable }
|
216
|
+
it { should respond_to :disable }
|
217
|
+
|
218
|
+
context 'fields' do
|
219
|
+
fields.each do |field|
|
220
|
+
it { should respond_to field[:name] }
|
221
|
+
|
222
|
+
context "#{field[:name]}" do
|
223
|
+
it "should be a #{field[:class].to_s}" do
|
224
|
+
expect(fieldset_object[field[:name]].class).to eq(field[:class])
|
225
|
+
end
|
226
|
+
|
227
|
+
it "should have a default value of #{field[:value]}" do
|
228
|
+
expect(fieldset_object[field[:name]].value).to eq(field[:value])
|
229
|
+
end
|
230
|
+
|
231
|
+
it "should have active set to #{field[:active]}" do
|
232
|
+
expect(fieldset_object[field[:name]].active).to eq(field[:active])
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
end
|
239
|
+
end
|