rubyntlm 0.6.6 → 0.6.7

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.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/README.md +48 -48
  4. data/lib/net/ntlm/blob.rb +11 -10
  5. data/lib/net/ntlm/channel_binding.rb +13 -9
  6. data/lib/net/ntlm/client/session.rb +34 -141
  7. data/lib/net/ntlm/client/session_crypto.rb +126 -0
  8. data/lib/net/ntlm/client.rb +8 -9
  9. data/lib/net/ntlm/encode_util.rb +39 -38
  10. data/lib/net/ntlm/exceptions.rb +3 -0
  11. data/lib/net/ntlm/field.rb +29 -31
  12. data/lib/net/ntlm/field_set.rb +39 -18
  13. data/lib/net/ntlm/int16_le.rb +8 -8
  14. data/lib/net/ntlm/int32_le.rb +8 -7
  15. data/lib/net/ntlm/int64_le.rb +8 -7
  16. data/lib/net/ntlm/md4.rb +102 -64
  17. data/lib/net/ntlm/message/type0.rb +4 -7
  18. data/lib/net/ntlm/message/type1.rb +8 -9
  19. data/lib/net/ntlm/message/type2.rb +87 -67
  20. data/lib/net/ntlm/message/type3.rb +43 -41
  21. data/lib/net/ntlm/message.rb +116 -111
  22. data/lib/net/ntlm/rc4.rb +51 -44
  23. data/lib/net/ntlm/response.rb +112 -0
  24. data/lib/net/ntlm/security_buffer.rb +13 -15
  25. data/lib/net/ntlm/string.rb +8 -7
  26. data/lib/net/ntlm/target_info.rb +52 -44
  27. data/lib/net/ntlm/version.rb +3 -1
  28. data/lib/net/ntlm.rb +37 -125
  29. data/lib/rubyntlm.rb +3 -1
  30. metadata +5 -44
  31. data/.devcontainer/devcontainer.json +0 -22
  32. data/.github/dependabot.yml +0 -10
  33. data/.github/workflows/build.yml +0 -55
  34. data/.gitignore +0 -11
  35. data/.rspec +0 -3
  36. data/Gemfile +0 -20
  37. data/Rakefile +0 -37
  38. data/examples/http.rb +0 -86
  39. data/examples/imap.rb +0 -73
  40. data/examples/smtp.rb +0 -94
  41. data/rubyntlm.gemspec +0 -28
  42. data/spec/lib/net/ntlm/blob_spec.rb +0 -14
  43. data/spec/lib/net/ntlm/channel_binding_spec.rb +0 -15
  44. data/spec/lib/net/ntlm/client/session_spec.rb +0 -85
  45. data/spec/lib/net/ntlm/client_spec.rb +0 -62
  46. data/spec/lib/net/ntlm/encode_util_spec.rb +0 -14
  47. data/spec/lib/net/ntlm/field_set_spec.rb +0 -31
  48. data/spec/lib/net/ntlm/field_spec.rb +0 -32
  49. data/spec/lib/net/ntlm/int16_le_spec.rb +0 -16
  50. data/spec/lib/net/ntlm/int32_le_spec.rb +0 -17
  51. data/spec/lib/net/ntlm/int64_le_spec.rb +0 -17
  52. data/spec/lib/net/ntlm/md4_spec.rb +0 -16
  53. data/spec/lib/net/ntlm/message/type0_spec.rb +0 -19
  54. data/spec/lib/net/ntlm/message/type1_spec.rb +0 -129
  55. data/spec/lib/net/ntlm/message/type2_spec.rb +0 -131
  56. data/spec/lib/net/ntlm/message/type3_spec.rb +0 -336
  57. data/spec/lib/net/ntlm/message_spec.rb +0 -15
  58. data/spec/lib/net/ntlm/security_buffer_spec.rb +0 -62
  59. data/spec/lib/net/ntlm/string_spec.rb +0 -70
  60. data/spec/lib/net/ntlm/target_info_spec.rb +0 -74
  61. data/spec/lib/net/ntlm/version_spec.rb +0 -26
  62. data/spec/lib/net/ntlm_spec.rb +0 -133
  63. data/spec/spec_helper.rb +0 -51
  64. data/spec/support/certificates/sha_256_hash.pem +0 -19
  65. data/spec/support/shared/examples/net/ntlm/field_shared.rb +0 -25
  66. data/spec/support/shared/examples/net/ntlm/fieldset_shared.rb +0 -239
  67. data/spec/support/shared/examples/net/ntlm/int_shared.rb +0 -43
  68. data/spec/support/shared/examples/net/ntlm/message_shared.rb +0 -35
@@ -1,26 +0,0 @@
1
- require File.expand_path("#{File.dirname(__FILE__)}/../../../../lib/net/ntlm/version")
2
-
3
- RSpec.describe Net::NTLM::VERSION do
4
-
5
- it 'should contain an integer value for Major Version' do
6
- expect(Net::NTLM::VERSION::MAJOR).to be_an Integer
7
- end
8
-
9
- it 'should contain an integer value for Minor Version' do
10
- expect(Net::NTLM::VERSION::MINOR).to be_an Integer
11
- end
12
-
13
- it 'should contain an integer value for Patch Version' do
14
- expect(Net::NTLM::VERSION::TINY).to be_an Integer
15
- end
16
-
17
- it 'should contain an aggregate version string' do
18
- string = [
19
- Net::NTLM::VERSION::MAJOR,
20
- Net::NTLM::VERSION::MINOR,
21
- Net::NTLM::VERSION::TINY
22
- ].join('.')
23
- expect(Net::NTLM::VERSION::STRING).to be_a String
24
- expect(Net::NTLM::VERSION::STRING).to eq(string)
25
- end
26
- end
@@ -1,133 +0,0 @@
1
- RSpec.describe Net::NTLM do
2
- let(:passwd) {"SecREt01"}
3
- let(:user) {"user"}
4
- let(:domain) {"DOMAIN"}
5
- let(:challenge) {["0123456789abcdef"].pack("H*")}
6
- let(:client_ch) {["ffffff0011223344"].pack("H*")}
7
- let(:timestamp) {1055844000}
8
- let(:trgt_info) {[
9
- "02000c0044004f004d00410049004e00" +
10
- "01000c00530045005200560045005200" +
11
- "0400140064006f006d00610069006e00" +
12
- "2e0063006f006d000300220073006500" +
13
- "72007600650072002e0064006f006d00" +
14
- "610069006e002e0063006f006d000000" +
15
- "0000"
16
- ].pack("H*")}
17
- let(:padded_pwd) { passwd.upcase.ljust(14, "\0")}
18
- let(:keys) { Net::NTLM.gen_keys(padded_pwd)}
19
-
20
- it 'should convert a value to 64-bit LE Integer' do
21
- expect(Net::NTLM.pack_int64le(42)).to eq("\x2A\x00\x00\x00\x00\x00\x00\x00")
22
- end
23
-
24
- it 'should split a string into an array of slices, 7 chars or less' do
25
- expect(Net::NTLM.split7("HelloWorld!")).to eq([ 'HelloWo', 'rld!'])
26
- end
27
-
28
- it 'should generate DES keys from the supplied string' do
29
- first_key = ["52a2516b252a5161"].pack('H*')
30
- second_key = ["3180010101010101"].pack('H*')
31
- expect(Net::NTLM.gen_keys(padded_pwd)).to eq([first_key, second_key])
32
- end
33
-
34
- it 'should encrypt the string with DES for each key supplied' do
35
- first_crypt = ["ff3750bcc2b22412"].pack('H*')
36
- second_crypt = ["c2265b23734e0dac"].pack('H*')
37
- expect(Net::NTLM::apply_des(Net::NTLM::LM_MAGIC, keys)).to eq([first_crypt, second_crypt])
38
- end
39
-
40
- it 'should generate an lm_hash' do
41
- expect(Net::NTLM::lm_hash(passwd)).to eq(["ff3750bcc2b22412c2265b23734e0dac"].pack("H*"))
42
- end
43
-
44
- it 'should generate an ntlm_hash' do
45
- expect(Net::NTLM::ntlm_hash(passwd)).to eq(["cd06ca7c7e10c99b1d33b7485a2ed808"].pack("H*"))
46
- end
47
-
48
- it 'should generate an ntlmv2_hash' do
49
- expect(Net::NTLM::ntlmv2_hash(user, passwd, domain)).to eq(["04b8e0ba74289cc540826bab1dee63ae"].pack("H*"))
50
- end
51
-
52
- context 'when a user passes an NTLM hash for pass-the-hash' do
53
- let(:passwd) { Net::NTLM::EncodeUtil.encode_utf16le('ff3750bcc2b22412c2265b23734e0dac:cd06ca7c7e10c99b1d33b7485a2ed808') }
54
-
55
- it 'should return the correct ntlmv2 hash' do
56
- expect(Net::NTLM::ntlmv2_hash(user, passwd, domain)).to eq(["04b8e0ba74289cc540826bab1dee63ae"].pack("H*"))
57
- end
58
- end
59
-
60
- context 'when the username contains non-ASCI characters' do
61
- let(:user) { 'юзер' }
62
-
63
- it 'should return the correct ntlmv2 hash' do
64
- expect(Net::NTLM::ntlmv2_hash(user, passwd, domain, { unicode: true })).to eq(["a0f4b914a37faeaee884b6b04a20faf0"].pack("H*"))
65
- end
66
- end
67
-
68
- it 'should generate an lm_response' do
69
- expect(Net::NTLM::lm_response(
70
- {
71
- :lm_hash => Net::NTLM::lm_hash(passwd),
72
- :challenge => challenge
73
- }
74
- )).to eq(["c337cd5cbd44fc9782a667af6d427c6de67c20c2d3e77c56"].pack("H*"))
75
- end
76
-
77
- it 'should generate an ntlm_response' do
78
- ntlm_hash = Net::NTLM::ntlm_hash(passwd)
79
- expect(Net::NTLM::ntlm_response(
80
- {
81
- :ntlm_hash => ntlm_hash,
82
- :challenge => challenge
83
- }
84
- )).to eq(["25a98c1c31e81847466b29b2df4680f39958fb8c213a9cc6"].pack("H*"))
85
- end
86
-
87
- it 'should generate a lvm2_response' do
88
- expect(Net::NTLM::lmv2_response(
89
- {
90
- :ntlmv2_hash => Net::NTLM::ntlmv2_hash(user, passwd, domain),
91
- :challenge => challenge
92
- },
93
- { :client_challenge => client_ch }
94
- )).to eq(["d6e6152ea25d03b7c6ba6629c2d6aaf0ffffff0011223344"].pack("H*"))
95
- end
96
-
97
- it 'should generate a ntlmv2_response' do
98
- expect(Net::NTLM::ntlmv2_response(
99
- {
100
- :ntlmv2_hash => Net::NTLM::ntlmv2_hash(user, passwd, domain),
101
- :challenge => challenge,
102
- :target_info => trgt_info
103
- },
104
- {
105
- :timestamp => timestamp,
106
- :client_challenge => client_ch
107
- }
108
- )).to eq([
109
- "cbabbca713eb795d04c97abc01ee4983" +
110
- "01010000000000000090d336b734c301" +
111
- "ffffff00112233440000000002000c00" +
112
- "44004f004d00410049004e0001000c00" +
113
- "53004500520056004500520004001400" +
114
- "64006f006d00610069006e002e006300" +
115
- "6f006d00030022007300650072007600" +
116
- "650072002e0064006f006d0061006900" +
117
- "6e002e0063006f006d00000000000000" +
118
- "0000"
119
- ].pack("H*"))
120
- end
121
-
122
- it 'should generate a ntlm2_session' do
123
- session = Net::NTLM::ntlm2_session(
124
- {
125
- :ntlm_hash => Net::NTLM::ntlm_hash(passwd),
126
- :challenge => challenge
127
- },
128
- { :client_challenge => client_ch }
129
- )
130
- expect(session[0]).to eq(["ffffff001122334400000000000000000000000000000000"].pack("H*"))
131
- expect(session[1]).to eq(["10d550832d12b2ccb79d5ad1f4eed3df82aca4c3681dd455"].pack("H*"))
132
- end
133
- end
data/spec/spec_helper.rb DELETED
@@ -1,51 +0,0 @@
1
- # Coverage must be started before the library under test is loaded, otherwise
2
- # methods defined at require time are not tracked.
3
- if ENV['COVERAGE']
4
- require 'simplecov'
5
-
6
- SimpleCov.start do
7
- add_filter '/spec/'
8
- add_filter '/vendor/'
9
- enable_coverage :branch if respond_to?(:enable_coverage)
10
- end
11
- end
12
-
13
- require 'rspec'
14
- require 'net/ntlm'
15
-
16
- # Custom matchers, shared examples and other support code.
17
- Dir[File.expand_path('support/**/*.rb', __dir__)].sort.each { |path| require path }
18
-
19
- RSpec.configure do |config|
20
- # Require `RSpec.describe` rather than a top-level `describe`, so the gem's
21
- # specs do not depend on RSpec monkey-patching Object.
22
- config.disable_monkey_patching!
23
-
24
- config.expect_with :rspec do |expectations|
25
- expectations.syntax = :expect
26
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
27
- end
28
-
29
- config.mock_with :rspec do |mocks|
30
- mocks.syntax = :expect
31
- # Fail fast when a partial double stubs a method the real object does not
32
- # have, so refactors in lib/ cannot leave specs passing against a fiction.
33
- mocks.verify_partial_doubles = true
34
- end
35
-
36
- # Shared example groups get their own metadata rather than leaking it into
37
- # the host group. This is the RSpec 4 default.
38
- config.shared_context_metadata_behavior = :apply_to_host_groups
39
-
40
- # `rspec --only-failures` and `--next-failure`.
41
- config.example_status_persistence_file_path = 'spec/examples.txt'
42
-
43
- # Tagging an example `:focus` runs just that example, without needing to pass
44
- # a line number. No effect when nothing is tagged.
45
- config.filter_run_when_matching :focus
46
-
47
- # Randomise ordering to surface accidental dependencies between examples, and
48
- # print the seed so a failure can be reproduced with `--seed`.
49
- config.order = :random
50
- Kernel.srand config.seed
51
- end
@@ -1,19 +0,0 @@
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 +0,0 @@
1
- RSpec.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 +0,0 @@
1
- RSpec.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,43 +0,0 @@
1
- RSpec.shared_examples_for 'an integer field' do |values|
2
-
3
- subject do
4
- described_class.new({
5
- :value => values[:default],
6
- :active => true
7
- })
8
- end
9
-
10
- context '#serialize' do
11
- it 'should serialize properly with an integer value' do
12
- expect(subject.serialize).to eq(values[:default_hex])
13
- end
14
-
15
- it 'should raise an Exception for a String' do
16
- subject.value = 'A'
17
- expect {subject.serialize}.to raise_error
18
- end
19
-
20
- it 'should raise an Exception for Nil' do
21
- subject.value = nil
22
- expect {subject.serialize}.to raise_error
23
- end
24
- end
25
-
26
- context '#parse' do
27
- it "should parse a raw #{values[:bits].to_s}-bit integer from a string" do
28
- expect(subject.parse(values[:alt_hex])).to eq(values[:size])
29
- expect(subject.value).to eq(values[:alt])
30
- end
31
-
32
- it "should use an offset to find the #{values[:bits].to_s}-bit integer in the string" do
33
- expect(subject.parse("Value:#{values[:alt_hex]}",6)).to eq(values[:size])
34
- expect(subject.value).to eq(values[:alt])
35
- end
36
-
37
- it 'should return 0 and not change the value if the string is not big enough' do
38
- expect(subject.parse(values[:small])).to eq(0)
39
- expect(subject.value).to eq(values[:default])
40
- end
41
- end
42
-
43
- end
@@ -1,35 +0,0 @@
1
- RSpec.shared_examples_for 'a message' do |flags|
2
-
3
- subject(:test_message) do
4
- unless described_class.names.include?(:flag)
5
- described_class.int32LE(:flag, {:value => Net::NTLM::DEFAULT_FLAGS[:TYPE1] })
6
- end
7
- described_class.new
8
- end
9
-
10
- it { should respond_to :has_flag? }
11
- it { should respond_to :set_flag }
12
- it { should respond_to :dump_flags }
13
- it { should respond_to :encode64 }
14
- it { should respond_to :decode64 }
15
- it { should respond_to :head_size }
16
- it { should respond_to :data_size }
17
- it { should respond_to :size }
18
- it { should respond_to :security_buffers }
19
- it { should respond_to :deflag }
20
- it { should respond_to :data_edge }
21
-
22
- flags.each do |flag|
23
- it "should be able to check if the #{flag} flag is set" do
24
- expect(test_message.has_flag?(flag)).to be(true)
25
- end
26
- end
27
-
28
-
29
- it 'should be able to set a new flag' do
30
- test_message.set_flag(:DOMAIN_SUPPLIED)
31
- expect(test_message.has_flag?(:DOMAIN_SUPPLIED)).to be(true)
32
- end
33
-
34
-
35
- end