rubyntlm 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -3
  3. data/.rspec +2 -2
  4. data/.travis.yml +13 -12
  5. data/CHANGELOG.md +118 -6
  6. data/Gemfile +3 -3
  7. data/LICENSE +19 -19
  8. data/Rakefile +25 -22
  9. data/lib/net/ntlm.rb +266 -266
  10. data/lib/net/ntlm/blob.rb +28 -28
  11. data/lib/net/ntlm/channel_binding.rb +65 -65
  12. data/lib/net/ntlm/client.rb +65 -65
  13. data/lib/net/ntlm/client/session.rb +237 -237
  14. data/lib/net/ntlm/encode_util.rb +48 -48
  15. data/lib/net/ntlm/exceptions.rb +14 -14
  16. data/lib/net/ntlm/field.rb +34 -34
  17. data/lib/net/ntlm/field_set.rb +129 -129
  18. data/lib/net/ntlm/int16_le.rb +25 -25
  19. data/lib/net/ntlm/int32_le.rb +24 -24
  20. data/lib/net/ntlm/int64_le.rb +25 -25
  21. data/lib/net/ntlm/message.rb +129 -129
  22. data/lib/net/ntlm/message/type0.rb +16 -16
  23. data/lib/net/ntlm/message/type1.rb +18 -18
  24. data/lib/net/ntlm/message/type2.rb +102 -102
  25. data/lib/net/ntlm/message/type3.rb +131 -131
  26. data/lib/net/ntlm/security_buffer.rb +47 -47
  27. data/lib/net/ntlm/string.rb +34 -34
  28. data/lib/net/ntlm/target_info.rb +89 -89
  29. data/lib/net/ntlm/version.rb +11 -11
  30. data/rubyntlm.gemspec +29 -28
  31. data/spec/lib/net/ntlm/blob_spec.rb +16 -16
  32. data/spec/lib/net/ntlm/channel_binding_spec.rb +17 -17
  33. data/spec/lib/net/ntlm/client/session_spec.rb +68 -68
  34. data/spec/lib/net/ntlm/client_spec.rb +64 -64
  35. data/spec/lib/net/ntlm/encode_util_spec.rb +16 -16
  36. data/spec/lib/net/ntlm/field_set_spec.rb +33 -33
  37. data/spec/lib/net/ntlm/field_spec.rb +34 -34
  38. data/spec/lib/net/ntlm/int16_le_spec.rb +17 -17
  39. data/spec/lib/net/ntlm/int32_le_spec.rb +18 -18
  40. data/spec/lib/net/ntlm/int64_le_spec.rb +18 -18
  41. data/spec/lib/net/ntlm/message/type0_spec.rb +20 -20
  42. data/spec/lib/net/ntlm/message/type1_spec.rb +131 -131
  43. data/spec/lib/net/ntlm/message/type2_spec.rb +132 -132
  44. data/spec/lib/net/ntlm/message/type3_spec.rb +225 -225
  45. data/spec/lib/net/ntlm/message_spec.rb +16 -16
  46. data/spec/lib/net/ntlm/security_buffer_spec.rb +64 -64
  47. data/spec/lib/net/ntlm/string_spec.rb +72 -72
  48. data/spec/lib/net/ntlm/target_info_spec.rb +76 -76
  49. data/spec/lib/net/ntlm/version_spec.rb +27 -27
  50. data/spec/lib/net/ntlm_spec.rb +127 -127
  51. data/spec/spec_helper.rb +22 -22
  52. data/spec/support/certificates/sha_256_hash.pem +19 -19
  53. data/spec/support/shared/examples/net/ntlm/field_shared.rb +25 -25
  54. data/spec/support/shared/examples/net/ntlm/fieldset_shared.rb +239 -239
  55. data/spec/support/shared/examples/net/ntlm/int_shared.rb +43 -43
  56. data/spec/support/shared/examples/net/ntlm/message_shared.rb +35 -35
  57. metadata +17 -3
@@ -1,127 +1,127 @@
1
- require "spec_helper"
2
-
3
- describe Net::NTLM do
4
- let(:passwd) {"SecREt01"}
5
- let(:user) {"user"}
6
- let(:domain) {"DOMAIN"}
7
- let(:challenge) {["0123456789abcdef"].pack("H*")}
8
- let(:client_ch) {["ffffff0011223344"].pack("H*")}
9
- let(:timestamp) {1055844000}
10
- let(:trgt_info) {[
11
- "02000c0044004f004d00410049004e00" +
12
- "01000c00530045005200560045005200" +
13
- "0400140064006f006d00610069006e00" +
14
- "2e0063006f006d000300220073006500" +
15
- "72007600650072002e0064006f006d00" +
16
- "610069006e002e0063006f006d000000" +
17
- "0000"
18
- ].pack("H*")}
19
- let(:padded_pwd) { passwd.upcase.ljust(14, "\0")}
20
- let(:keys) { Net::NTLM.gen_keys(padded_pwd)}
21
-
22
- it 'should convert a value to 64-bit LE Integer' do
23
- expect(Net::NTLM.pack_int64le(42)).to eq("\x2A\x00\x00\x00\x00\x00\x00\x00")
24
- end
25
-
26
- it 'should split a string into an array of slices, 7 chars or less' do
27
- expect(Net::NTLM.split7("HelloWorld!")).to eq([ 'HelloWo', 'rld!'])
28
- end
29
-
30
- it 'should generate DES keys from the supplied string' do
31
- first_key = ["52a2516b252a5161"].pack('H*')
32
- second_key = ["3180010101010101"].pack('H*')
33
- expect(Net::NTLM.gen_keys(padded_pwd)).to eq([first_key, second_key])
34
- end
35
-
36
- it 'should encrypt the string with DES for each key supplied' do
37
- first_crypt = ["ff3750bcc2b22412"].pack('H*')
38
- second_crypt = ["c2265b23734e0dac"].pack('H*')
39
- expect(Net::NTLM::apply_des(Net::NTLM::LM_MAGIC, keys)).to eq([first_crypt, second_crypt])
40
- end
41
-
42
- it 'should generate an lm_hash' do
43
- expect(Net::NTLM::lm_hash(passwd)).to eq(["ff3750bcc2b22412c2265b23734e0dac"].pack("H*"))
44
- end
45
-
46
- it 'should generate an ntlm_hash' do
47
- expect(Net::NTLM::ntlm_hash(passwd)).to eq(["cd06ca7c7e10c99b1d33b7485a2ed808"].pack("H*"))
48
- end
49
-
50
- it 'should generate an ntlmv2_hash' do
51
- expect(Net::NTLM::ntlmv2_hash(user, passwd, domain)).to eq(["04b8e0ba74289cc540826bab1dee63ae"].pack("H*"))
52
- end
53
-
54
- context 'when a user passes an NTLM hash for pass-the-hash' do
55
- let(:passwd) { Net::NTLM::EncodeUtil.encode_utf16le('ff3750bcc2b22412c2265b23734e0dac:cd06ca7c7e10c99b1d33b7485a2ed808') }
56
-
57
- it 'should return the correct ntlmv2 hash' do
58
- expect(Net::NTLM::ntlmv2_hash(user, passwd, domain)).to eq(["04b8e0ba74289cc540826bab1dee63ae"].pack("H*"))
59
- end
60
- end
61
-
62
- it 'should generate an lm_response' do
63
- expect(Net::NTLM::lm_response(
64
- {
65
- :lm_hash => Net::NTLM::lm_hash(passwd),
66
- :challenge => challenge
67
- }
68
- )).to eq(["c337cd5cbd44fc9782a667af6d427c6de67c20c2d3e77c56"].pack("H*"))
69
- end
70
-
71
- it 'should generate an ntlm_response' do
72
- ntlm_hash = Net::NTLM::ntlm_hash(passwd)
73
- expect(Net::NTLM::ntlm_response(
74
- {
75
- :ntlm_hash => ntlm_hash,
76
- :challenge => challenge
77
- }
78
- )).to eq(["25a98c1c31e81847466b29b2df4680f39958fb8c213a9cc6"].pack("H*"))
79
- end
80
-
81
- it 'should generate a lvm2_response' do
82
- expect(Net::NTLM::lmv2_response(
83
- {
84
- :ntlmv2_hash => Net::NTLM::ntlmv2_hash(user, passwd, domain),
85
- :challenge => challenge
86
- },
87
- { :client_challenge => client_ch }
88
- )).to eq(["d6e6152ea25d03b7c6ba6629c2d6aaf0ffffff0011223344"].pack("H*"))
89
- end
90
-
91
- it 'should generate a ntlmv2_response' do
92
- expect(Net::NTLM::ntlmv2_response(
93
- {
94
- :ntlmv2_hash => Net::NTLM::ntlmv2_hash(user, passwd, domain),
95
- :challenge => challenge,
96
- :target_info => trgt_info
97
- },
98
- {
99
- :timestamp => timestamp,
100
- :client_challenge => client_ch
101
- }
102
- )).to eq([
103
- "cbabbca713eb795d04c97abc01ee4983" +
104
- "01010000000000000090d336b734c301" +
105
- "ffffff00112233440000000002000c00" +
106
- "44004f004d00410049004e0001000c00" +
107
- "53004500520056004500520004001400" +
108
- "64006f006d00610069006e002e006300" +
109
- "6f006d00030022007300650072007600" +
110
- "650072002e0064006f006d0061006900" +
111
- "6e002e0063006f006d00000000000000" +
112
- "0000"
113
- ].pack("H*"))
114
- end
115
-
116
- it 'should generate a ntlm2_session' do
117
- session = Net::NTLM::ntlm2_session(
118
- {
119
- :ntlm_hash => Net::NTLM::ntlm_hash(passwd),
120
- :challenge => challenge
121
- },
122
- { :client_challenge => client_ch }
123
- )
124
- expect(session[0]).to eq(["ffffff001122334400000000000000000000000000000000"].pack("H*"))
125
- expect(session[1]).to eq(["10d550832d12b2ccb79d5ad1f4eed3df82aca4c3681dd455"].pack("H*"))
126
- end
127
- end
1
+ require "spec_helper"
2
+
3
+ describe Net::NTLM do
4
+ let(:passwd) {"SecREt01"}
5
+ let(:user) {"user"}
6
+ let(:domain) {"DOMAIN"}
7
+ let(:challenge) {["0123456789abcdef"].pack("H*")}
8
+ let(:client_ch) {["ffffff0011223344"].pack("H*")}
9
+ let(:timestamp) {1055844000}
10
+ let(:trgt_info) {[
11
+ "02000c0044004f004d00410049004e00" +
12
+ "01000c00530045005200560045005200" +
13
+ "0400140064006f006d00610069006e00" +
14
+ "2e0063006f006d000300220073006500" +
15
+ "72007600650072002e0064006f006d00" +
16
+ "610069006e002e0063006f006d000000" +
17
+ "0000"
18
+ ].pack("H*")}
19
+ let(:padded_pwd) { passwd.upcase.ljust(14, "\0")}
20
+ let(:keys) { Net::NTLM.gen_keys(padded_pwd)}
21
+
22
+ it 'should convert a value to 64-bit LE Integer' do
23
+ expect(Net::NTLM.pack_int64le(42)).to eq("\x2A\x00\x00\x00\x00\x00\x00\x00")
24
+ end
25
+
26
+ it 'should split a string into an array of slices, 7 chars or less' do
27
+ expect(Net::NTLM.split7("HelloWorld!")).to eq([ 'HelloWo', 'rld!'])
28
+ end
29
+
30
+ it 'should generate DES keys from the supplied string' do
31
+ first_key = ["52a2516b252a5161"].pack('H*')
32
+ second_key = ["3180010101010101"].pack('H*')
33
+ expect(Net::NTLM.gen_keys(padded_pwd)).to eq([first_key, second_key])
34
+ end
35
+
36
+ it 'should encrypt the string with DES for each key supplied' do
37
+ first_crypt = ["ff3750bcc2b22412"].pack('H*')
38
+ second_crypt = ["c2265b23734e0dac"].pack('H*')
39
+ expect(Net::NTLM::apply_des(Net::NTLM::LM_MAGIC, keys)).to eq([first_crypt, second_crypt])
40
+ end
41
+
42
+ it 'should generate an lm_hash' do
43
+ expect(Net::NTLM::lm_hash(passwd)).to eq(["ff3750bcc2b22412c2265b23734e0dac"].pack("H*"))
44
+ end
45
+
46
+ it 'should generate an ntlm_hash' do
47
+ expect(Net::NTLM::ntlm_hash(passwd)).to eq(["cd06ca7c7e10c99b1d33b7485a2ed808"].pack("H*"))
48
+ end
49
+
50
+ it 'should generate an ntlmv2_hash' do
51
+ expect(Net::NTLM::ntlmv2_hash(user, passwd, domain)).to eq(["04b8e0ba74289cc540826bab1dee63ae"].pack("H*"))
52
+ end
53
+
54
+ context 'when a user passes an NTLM hash for pass-the-hash' do
55
+ let(:passwd) { Net::NTLM::EncodeUtil.encode_utf16le('ff3750bcc2b22412c2265b23734e0dac:cd06ca7c7e10c99b1d33b7485a2ed808') }
56
+
57
+ it 'should return the correct ntlmv2 hash' do
58
+ expect(Net::NTLM::ntlmv2_hash(user, passwd, domain)).to eq(["04b8e0ba74289cc540826bab1dee63ae"].pack("H*"))
59
+ end
60
+ end
61
+
62
+ it 'should generate an lm_response' do
63
+ expect(Net::NTLM::lm_response(
64
+ {
65
+ :lm_hash => Net::NTLM::lm_hash(passwd),
66
+ :challenge => challenge
67
+ }
68
+ )).to eq(["c337cd5cbd44fc9782a667af6d427c6de67c20c2d3e77c56"].pack("H*"))
69
+ end
70
+
71
+ it 'should generate an ntlm_response' do
72
+ ntlm_hash = Net::NTLM::ntlm_hash(passwd)
73
+ expect(Net::NTLM::ntlm_response(
74
+ {
75
+ :ntlm_hash => ntlm_hash,
76
+ :challenge => challenge
77
+ }
78
+ )).to eq(["25a98c1c31e81847466b29b2df4680f39958fb8c213a9cc6"].pack("H*"))
79
+ end
80
+
81
+ it 'should generate a lvm2_response' do
82
+ expect(Net::NTLM::lmv2_response(
83
+ {
84
+ :ntlmv2_hash => Net::NTLM::ntlmv2_hash(user, passwd, domain),
85
+ :challenge => challenge
86
+ },
87
+ { :client_challenge => client_ch }
88
+ )).to eq(["d6e6152ea25d03b7c6ba6629c2d6aaf0ffffff0011223344"].pack("H*"))
89
+ end
90
+
91
+ it 'should generate a ntlmv2_response' do
92
+ expect(Net::NTLM::ntlmv2_response(
93
+ {
94
+ :ntlmv2_hash => Net::NTLM::ntlmv2_hash(user, passwd, domain),
95
+ :challenge => challenge,
96
+ :target_info => trgt_info
97
+ },
98
+ {
99
+ :timestamp => timestamp,
100
+ :client_challenge => client_ch
101
+ }
102
+ )).to eq([
103
+ "cbabbca713eb795d04c97abc01ee4983" +
104
+ "01010000000000000090d336b734c301" +
105
+ "ffffff00112233440000000002000c00" +
106
+ "44004f004d00410049004e0001000c00" +
107
+ "53004500520056004500520004001400" +
108
+ "64006f006d00610069006e002e006300" +
109
+ "6f006d00030022007300650072007600" +
110
+ "650072002e0064006f006d0061006900" +
111
+ "6e002e0063006f006d00000000000000" +
112
+ "0000"
113
+ ].pack("H*"))
114
+ end
115
+
116
+ it 'should generate a ntlm2_session' do
117
+ session = Net::NTLM::ntlm2_session(
118
+ {
119
+ :ntlm_hash => Net::NTLM::ntlm_hash(passwd),
120
+ :challenge => challenge
121
+ },
122
+ { :client_challenge => client_ch }
123
+ )
124
+ expect(session[0]).to eq(["ffffff001122334400000000000000000000000000000000"].pack("H*"))
125
+ expect(session[1]).to eq(["10d550832d12b2ccb79d5ad1f4eed3df82aca4c3681dd455"].pack("H*"))
126
+ end
127
+ end
@@ -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
@@ -1,19 +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
+ -----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