ruby_smb 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data/.gitignore +21 -0
  4. data/.rspec +3 -0
  5. data/.simplecov +42 -0
  6. data/.travis.yml +5 -0
  7. data/.yardopts +1 -0
  8. data/CONTRIBUTING.md +119 -0
  9. data/Gemfile +13 -0
  10. data/LICENSE.txt +18 -0
  11. data/README.md +64 -0
  12. data/Rakefile +22 -0
  13. data/examples/authenticate.rb +30 -0
  14. data/examples/negotiate.rb +25 -0
  15. data/lib/ruby_smb/client/authentication.rb +236 -0
  16. data/lib/ruby_smb/client/negotiation.rb +126 -0
  17. data/lib/ruby_smb/client/signing.rb +48 -0
  18. data/lib/ruby_smb/client.rb +164 -0
  19. data/lib/ruby_smb/dispatcher/base.rb +18 -0
  20. data/lib/ruby_smb/dispatcher/socket.rb +53 -0
  21. data/lib/ruby_smb/dispatcher.rb +4 -0
  22. data/lib/ruby_smb/error.rb +17 -0
  23. data/lib/ruby_smb/field/file_time.rb +62 -0
  24. data/lib/ruby_smb/field/nt_status.rb +16 -0
  25. data/lib/ruby_smb/field/stringz16.rb +55 -0
  26. data/lib/ruby_smb/field.rb +7 -0
  27. data/lib/ruby_smb/generic_packet.rb +179 -0
  28. data/lib/ruby_smb/gss.rb +109 -0
  29. data/lib/ruby_smb/smb1/andx_block.rb +13 -0
  30. data/lib/ruby_smb/smb1/bit_field/capabilities.rb +39 -0
  31. data/lib/ruby_smb/smb1/bit_field/header_flags.rb +19 -0
  32. data/lib/ruby_smb/smb1/bit_field/header_flags2.rb +27 -0
  33. data/lib/ruby_smb/smb1/bit_field/security_mode.rb +16 -0
  34. data/lib/ruby_smb/smb1/bit_field.rb +10 -0
  35. data/lib/ruby_smb/smb1/commands.rb +9 -0
  36. data/lib/ruby_smb/smb1/data_block.rb +42 -0
  37. data/lib/ruby_smb/smb1/dialect.rb +11 -0
  38. data/lib/ruby_smb/smb1/packet/error_packet.rb +14 -0
  39. data/lib/ruby_smb/smb1/packet/negotiate_request.rb +52 -0
  40. data/lib/ruby_smb/smb1/packet/negotiate_response.rb +46 -0
  41. data/lib/ruby_smb/smb1/packet/negotiate_response_extended.rb +47 -0
  42. data/lib/ruby_smb/smb1/packet/session_setup_request.rb +71 -0
  43. data/lib/ruby_smb/smb1/packet/session_setup_response.rb +48 -0
  44. data/lib/ruby_smb/smb1/packet.rb +12 -0
  45. data/lib/ruby_smb/smb1/parameter_block.rb +42 -0
  46. data/lib/ruby_smb/smb1/smb_header.rb +21 -0
  47. data/lib/ruby_smb/smb1.rb +16 -0
  48. data/lib/ruby_smb/smb2/bit_field/session_flags.rb +17 -0
  49. data/lib/ruby_smb/smb2/bit_field/smb2_capabailities.rb +23 -0
  50. data/lib/ruby_smb/smb2/bit_field/smb2_header_flags.rb +23 -0
  51. data/lib/ruby_smb/smb2/bit_field/smb2_security_mode.rb +15 -0
  52. data/lib/ruby_smb/smb2/bit_field/smb2_security_mode_single.rb +14 -0
  53. data/lib/ruby_smb/smb2/bit_field.rb +11 -0
  54. data/lib/ruby_smb/smb2/commands.rb +25 -0
  55. data/lib/ruby_smb/smb2/packet/negotiate_request.rb +50 -0
  56. data/lib/ruby_smb/smb2/packet/negotiate_response.rb +33 -0
  57. data/lib/ruby_smb/smb2/packet/session_setup_request.rb +53 -0
  58. data/lib/ruby_smb/smb2/packet/session_setup_response.rb +38 -0
  59. data/lib/ruby_smb/smb2/packet.rb +10 -0
  60. data/lib/ruby_smb/smb2/smb2_header.rb +22 -0
  61. data/lib/ruby_smb/smb2.rb +12 -0
  62. data/lib/ruby_smb/version.rb +3 -0
  63. data/lib/ruby_smb.rb +22 -0
  64. data/ruby_smb.gemspec +38 -0
  65. data/spec/lib/ruby_smb/client_spec.rb +638 -0
  66. data/spec/lib/ruby_smb/dispatcher/dispatcher_base_spec.rb +22 -0
  67. data/spec/lib/ruby_smb/dispatcher/socket_spec.rb +60 -0
  68. data/spec/lib/ruby_smb/field/file_time_spec.rb +59 -0
  69. data/spec/lib/ruby_smb/field/nt_status_spec.rb +19 -0
  70. data/spec/lib/ruby_smb/field/stringz16_spec.rb +50 -0
  71. data/spec/lib/ruby_smb/generic_packet_spec.rb +58 -0
  72. data/spec/lib/ruby_smb/smb1/andx_block_spec.rb +41 -0
  73. data/spec/lib/ruby_smb/smb1/bit_field/capabilities_spec.rb +245 -0
  74. data/spec/lib/ruby_smb/smb1/bit_field/header_flags2_spec.rb +146 -0
  75. data/spec/lib/ruby_smb/smb1/bit_field/header_flags_spec.rb +102 -0
  76. data/spec/lib/ruby_smb/smb1/bit_field/security_mode_spec.rb +44 -0
  77. data/spec/lib/ruby_smb/smb1/data_block_spec.rb +26 -0
  78. data/spec/lib/ruby_smb/smb1/dialect_spec.rb +26 -0
  79. data/spec/lib/ruby_smb/smb1/packet/error_packet_spec.rb +39 -0
  80. data/spec/lib/ruby_smb/smb1/packet/negotiate_request_spec.rb +77 -0
  81. data/spec/lib/ruby_smb/smb1/packet/negotiate_response_extended_spec.rb +149 -0
  82. data/spec/lib/ruby_smb/smb1/packet/negotiate_response_spec.rb +150 -0
  83. data/spec/lib/ruby_smb/smb1/packet/session_setup_request_spec.rb +100 -0
  84. data/spec/lib/ruby_smb/smb1/packet/session_setup_response_spec.rb +72 -0
  85. data/spec/lib/ruby_smb/smb1/parameter_block_spec.rb +26 -0
  86. data/spec/lib/ruby_smb/smb1/smb_header_spec.rb +96 -0
  87. data/spec/lib/ruby_smb/smb2/bit_field/header_flags_spec.rb +81 -0
  88. data/spec/lib/ruby_smb/smb2/bit_field/session_flags_spec.rb +28 -0
  89. data/spec/lib/ruby_smb/smb2/bit_field/smb2_capabilities_spec.rb +72 -0
  90. data/spec/lib/ruby_smb/smb2/bit_field/smb_secruity_mode_spec.rb +22 -0
  91. data/spec/lib/ruby_smb/smb2/packet/negotiate_request_spec.rb +122 -0
  92. data/spec/lib/ruby_smb/smb2/packet/negotiate_response_spec.rb +147 -0
  93. data/spec/lib/ruby_smb/smb2/packet/session_setup_request_spec.rb +79 -0
  94. data/spec/lib/ruby_smb/smb2/packet/session_setup_response_spec.rb +54 -0
  95. data/spec/lib/ruby_smb/smb2/smb2_header_spec.rb +127 -0
  96. data/spec/lib/ruby_smb_spec.rb +2 -0
  97. data/spec/spec_helper.rb +100 -0
  98. data/spec/support/mock_socket_dispatcher.rb +8 -0
  99. data/spec/support/shared/examples/bit_field_single_flag.rb +14 -0
  100. data.tar.gz.sig +0 -0
  101. metadata +384 -0
  102. metadata.gz.sig +0 -0
@@ -0,0 +1,147 @@
1
+ RSpec.describe RubySMB::SMB2::Packet::NegotiateResponse do
2
+ subject(:packet) { described_class.new }
3
+
4
+ it { is_expected.to respond_to :smb2_header }
5
+ it { is_expected.to respond_to :structure_size }
6
+ it { is_expected.to respond_to :security_mode }
7
+ it { is_expected.to respond_to :dialect_revision }
8
+ it { is_expected.to respond_to :negotiate_context_count }
9
+ it { is_expected.to respond_to :server_guid }
10
+ it { is_expected.to respond_to :capabilities }
11
+ it { is_expected.to respond_to :max_transact_size }
12
+ it { is_expected.to respond_to :max_read_size }
13
+ it { is_expected.to respond_to :max_write_size }
14
+ it { is_expected.to respond_to :system_time }
15
+ it { is_expected.to respond_to :server_start_time }
16
+ it { is_expected.to respond_to :security_buffer_offset }
17
+ it { is_expected.to respond_to :security_buffer_length }
18
+ it { is_expected.to respond_to :negotiate_context_offset }
19
+ it { is_expected.to respond_to :security_buffer }
20
+
21
+ it 'is little endian' do
22
+ expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
23
+ end
24
+
25
+ describe '#smb2_header' do
26
+ subject(:header) { packet.smb2_header }
27
+
28
+ it 'is a standard SMB Header' do
29
+ expect(header).to be_a RubySMB::SMB2::SMB2Header
30
+ end
31
+
32
+ it 'should have the command set to SMB_COM_NEGOTIATE' do
33
+ expect(header.command).to eq RubySMB::SMB2::Commands::NEGOTIATE
34
+ end
35
+
36
+ it 'should have the response flag set' do
37
+ expect(header.flags.reply).to eq 1
38
+ end
39
+ end
40
+
41
+ describe '#structure_size' do
42
+ it 'should be a 16-bit unsigned integer' do
43
+ expect(packet.structure_size).to be_a BinData::Uint16le
44
+ end
45
+
46
+ it 'should have a default value of 65 as per the SMB2 spec' do
47
+ expect(packet.structure_size).to eq 65
48
+ end
49
+ end
50
+
51
+ describe '#security_mode' do
52
+ it 'should be a SMB2 Security Mode BitField' do
53
+ expect(packet.security_mode).to be_a RubySMB::SMB2::BitField::Smb2SecurityMode
54
+ end
55
+ end
56
+
57
+ describe '#dialect_revision' do
58
+ it 'is a 16-bit unsigned integer' do
59
+ expect(packet.dialect_revision).to be_a BinData::Uint16le
60
+ end
61
+ end
62
+
63
+ describe '#negotiate_context_count' do
64
+ it 'is a 16-bit unsigned integer' do
65
+ expect(packet.negotiate_context_count).to be_a BinData::Uint16le
66
+ end
67
+
68
+ it 'has a default value of 0' do
69
+ expect(packet.negotiate_context_count).to eq 0
70
+ end
71
+ end
72
+
73
+ describe '#server_guid' do
74
+ it 'should be a binary string' do
75
+ expect(packet.server_guid).to be_a BinData::String
76
+ end
77
+
78
+ it 'should be 16-bytes' do
79
+ expect(packet.server_guid.do_num_bytes).to eq 16
80
+ end
81
+ end
82
+
83
+ describe '#capabailities' do
84
+ it 'should be a SMB2 Capabilities BitField' do
85
+ expect(packet.capabilities).to be_a RubySMB::SMB2::BitField::Smb2Capabilities
86
+ end
87
+ end
88
+
89
+ describe '#max_transact_size' do
90
+ it 'is a 32-bit unsigned integer' do
91
+ expect(packet.max_transact_size).to be_a BinData::Uint32le
92
+ end
93
+ end
94
+
95
+ describe '#max_read_size' do
96
+ it 'is a 32-bit unsigned integer' do
97
+ expect(packet.max_read_size).to be_a BinData::Uint32le
98
+ end
99
+ end
100
+
101
+ describe '#max_write_size' do
102
+ it 'is a 32-bit unsigned integer' do
103
+ expect(packet.max_write_size).to be_a BinData::Uint32le
104
+ end
105
+ end
106
+
107
+ describe '#system_time' do
108
+ it 'should be a Filetime field' do
109
+ expect(packet.system_time).to be_a RubySMB::Field::FileTime
110
+ end
111
+ end
112
+
113
+ describe '#server_start_time' do
114
+ it 'should be a Filetime field' do
115
+ expect(packet.server_start_time).to be_a RubySMB::Field::FileTime
116
+ end
117
+ end
118
+
119
+ describe '#security_buffer_offset' do
120
+ it 'is a 16-bit unsigned integer' do
121
+ expect(packet.security_buffer_offset).to be_a BinData::Uint16le
122
+ end
123
+ end
124
+
125
+ describe '#security_buffer_length' do
126
+ it 'is a 16-bit unsigned integer' do
127
+ expect(packet.security_buffer_length).to be_a BinData::Uint16le
128
+ end
129
+
130
+ it 'should be the length of the security_buffer field' do
131
+ packet.security_buffer = 'foobar'
132
+ expect(packet.security_buffer_length).to eq 6
133
+ end
134
+ end
135
+
136
+ describe '#negotiate_context_offset' do
137
+ it 'is a 32-bit unsigned integer' do
138
+ expect(packet.negotiate_context_offset).to be_a BinData::Uint32le
139
+ end
140
+ end
141
+
142
+ describe '#security_buffer' do
143
+ it 'should be a binary string' do
144
+ expect(packet.security_buffer).to be_a BinData::String
145
+ end
146
+ end
147
+ end
@@ -0,0 +1,79 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RubySMB::SMB2::Packet::SessionSetupRequest do
4
+
5
+ subject(:packet) { described_class.new }
6
+
7
+ it { is_expected.to respond_to :smb2_header }
8
+ it { is_expected.to respond_to :structure_size }
9
+ it { is_expected.to respond_to :flags }
10
+ it { is_expected.to respond_to :security_mode }
11
+ it { is_expected.to respond_to :capabilities }
12
+ it { is_expected.to respond_to :channel }
13
+ it { is_expected.to respond_to :security_buffer_offset }
14
+ it { is_expected.to respond_to :security_buffer_length }
15
+ it { is_expected.to respond_to :previous_session_id }
16
+ it { is_expected.to respond_to :buffer }
17
+
18
+ it 'is little endian' do
19
+ expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
20
+ end
21
+
22
+ describe '#smb2_header' do
23
+ subject(:header) { packet.smb2_header }
24
+
25
+ it 'is a standard SMB Header' do
26
+ expect(header).to be_a RubySMB::SMB2::SMB2Header
27
+ end
28
+
29
+ it 'should have the command set to SMB_COM_NEGOTIATE' do
30
+ expect(header.command).to eq RubySMB::SMB2::Commands::SESSION_SETUP
31
+ end
32
+
33
+ it 'should not have the response flag set' do
34
+ expect(header.flags.reply).to eq 0
35
+ end
36
+ end
37
+
38
+ describe '#set_type1_blob' do
39
+ let(:fake_message) { "foo" }
40
+
41
+ it 'calls the #gss_type1 method to create a blob' do
42
+ expect(RubySMB::Gss).to receive(:gss_type1).with(fake_message).and_return(fake_message)
43
+ packet.set_type1_blob(fake_message)
44
+ end
45
+
46
+ it 'sets the security blob to the result from the GSS call' do
47
+ expect(RubySMB::Gss).to receive(:gss_type1).with(fake_message).and_return(fake_message)
48
+ packet.set_type1_blob(fake_message)
49
+ expect(packet.buffer).to eq fake_message
50
+ end
51
+
52
+ it 'sets the security_blob_length field automatically' do
53
+ expect(RubySMB::Gss).to receive(:gss_type1).with(fake_message).and_return(fake_message)
54
+ packet.set_type1_blob(fake_message)
55
+ expect(packet.security_buffer_length).to eq fake_message.length
56
+ end
57
+ end
58
+
59
+ describe '#set_type3_blob' do
60
+ let(:fake_message) { "foo" }
61
+
62
+ it 'calls the #gss_type3 method to create a blob' do
63
+ expect(RubySMB::Gss).to receive(:gss_type3).with(fake_message).and_return(fake_message)
64
+ packet.set_type3_blob(fake_message)
65
+ end
66
+
67
+ it 'sets the security blob to the result from the GSS call' do
68
+ expect(RubySMB::Gss).to receive(:gss_type3).with(fake_message).and_return(fake_message)
69
+ packet.set_type3_blob(fake_message)
70
+ expect(packet.buffer).to eq fake_message
71
+ end
72
+
73
+ it 'sets the security_blob_length field automatically' do
74
+ expect(RubySMB::Gss).to receive(:gss_type3).with(fake_message).and_return(fake_message)
75
+ packet.set_type3_blob(fake_message)
76
+ expect(packet.security_buffer_length).to eq fake_message.length
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RubySMB::SMB2::Packet::SessionSetupResponse do
4
+
5
+ subject(:packet) { described_class.new }
6
+
7
+ it { is_expected.to respond_to :smb2_header }
8
+ it { is_expected.to respond_to :structure_size }
9
+ it { is_expected.to respond_to :session_flags }
10
+ it { is_expected.to respond_to :security_buffer_offset }
11
+ it { is_expected.to respond_to :security_buffer_length }
12
+ it { is_expected.to respond_to :buffer }
13
+
14
+ it 'is little endian' do
15
+ expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
16
+ end
17
+
18
+ describe '#smb2_header' do
19
+ subject(:header) { packet.smb2_header }
20
+
21
+ it 'is a standard SMB Header' do
22
+ expect(header).to be_a RubySMB::SMB2::SMB2Header
23
+ end
24
+
25
+ it 'should have the command set to SMB_COM_NEGOTIATE' do
26
+ expect(header.command).to eq RubySMB::SMB2::Commands::SESSION_SETUP
27
+ end
28
+
29
+ it 'should have the response flag set' do
30
+ expect(header.flags.reply).to eq 1
31
+ end
32
+ end
33
+
34
+ describe '#set_type2_blob' do
35
+ let(:fake_message) { "foo" }
36
+
37
+ it 'calls the #gss_type2 method to create a blob' do
38
+ expect(RubySMB::Gss).to receive(:gss_type2).with(fake_message).and_return(fake_message)
39
+ packet.set_type2_blob(fake_message)
40
+ end
41
+
42
+ it 'sets the security blob to the result from the GSS call' do
43
+ expect(RubySMB::Gss).to receive(:gss_type2).with(fake_message).and_return(fake_message)
44
+ packet.set_type2_blob(fake_message)
45
+ expect(packet.buffer).to eq fake_message
46
+ end
47
+
48
+ it 'sets the security_blob_length field automatically' do
49
+ expect(RubySMB::Gss).to receive(:gss_type2).with(fake_message).and_return(fake_message)
50
+ packet.set_type2_blob(fake_message)
51
+ expect(packet.security_buffer_length).to eq fake_message.length
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,127 @@
1
+ RSpec.describe RubySMB::SMB2::SMB2Header do
2
+ subject(:header) { described_class.new }
3
+
4
+ it { is_expected.to respond_to :protocol }
5
+ it { is_expected.to respond_to :structure_size }
6
+ it { is_expected.to respond_to :credit_charge }
7
+ it { is_expected.to respond_to :nt_status }
8
+ it { is_expected.to respond_to :command }
9
+ it { is_expected.to respond_to :credits }
10
+ it { is_expected.to respond_to :flags }
11
+ it { is_expected.to respond_to :next_command }
12
+ it { is_expected.to respond_to :message_id }
13
+ it { is_expected.to respond_to :process_id }
14
+ it { is_expected.to respond_to :tree_id }
15
+ it { is_expected.to respond_to :session_id }
16
+ it { is_expected.to respond_to :signature }
17
+
18
+ it 'is little endian' do
19
+ expect(described_class.fields.instance_variable_get(:@hints)[:endian]).to eq :little
20
+ end
21
+
22
+ describe '#protocol' do
23
+ it 'is a 32-bit field' do
24
+ expect(header.protocol).to be_a BinData::Bit32
25
+ end
26
+
27
+ it 'has a default value of the SMB2 ID' do
28
+ expect(header.protocol).to eq RubySMB::SMB2::SMB2_PROTOCOL_ID
29
+ end
30
+ end
31
+
32
+ describe '#structure_size' do
33
+ it 'is a 16-bit unsigned integer' do
34
+ expect(header.structure_size).to be_a BinData::Uint16le
35
+ end
36
+
37
+ it 'has a default value of 64 as per the SMB2 spec' do
38
+ expect(header.structure_size).to eq 64
39
+ end
40
+ end
41
+
42
+ describe '#credit_charge' do
43
+ it 'is a 16-bit unsigned integer' do
44
+ expect(header.credit_charge).to be_a BinData::Uint16le
45
+ end
46
+
47
+ it 'has a default value of 0' do
48
+ expect(header.credit_charge).to eq 0
49
+ end
50
+ end
51
+
52
+ describe '#nt_status' do
53
+ it 'is a NTStatus field' do
54
+ expect(header.nt_status).to be_a RubySMB::Field::NtStatus
55
+ end
56
+
57
+ it 'has a default value of 0' do
58
+ expect(header.nt_status).to eq 0
59
+ end
60
+ end
61
+
62
+ describe '#command' do
63
+ it 'is a 16-bit unsigned integer' do
64
+ expect(header.command).to be_a BinData::Uint16le
65
+ end
66
+ end
67
+
68
+ describe '#credits' do
69
+ it 'is a 16-bit unsigned integer' do
70
+ expect(header.credits).to be_a BinData::Uint16le
71
+ end
72
+ end
73
+
74
+ describe '#flags' do
75
+ it 'is an smb2_header_flags field' do
76
+ expect(header.flags).to be_a RubySMB::SMB2::BitField::Smb2HeaderFlags
77
+ end
78
+ end
79
+
80
+ describe '#next_command' do
81
+ it 'is a 32-bit unsigned integer' do
82
+ expect(header.next_command).to be_a BinData::Uint32le
83
+ end
84
+
85
+ it 'has a default value of 0' do
86
+ expect(header.next_command).to eq 0
87
+ end
88
+ end
89
+
90
+ describe '#message_id' do
91
+ it 'is a 64-bit unsigned integer' do
92
+ expect(header.message_id).to be_a BinData::Uint64le
93
+ end
94
+ end
95
+
96
+ describe '#process_id' do
97
+ it 'is a 32-bit unsigned integer' do
98
+ expect(header.process_id).to be_a BinData::Uint32le
99
+ end
100
+
101
+ it 'has a default value of 0x0000feff' do
102
+ expect(header.process_id).to eq 0x0000feff
103
+ end
104
+ end
105
+
106
+ describe '#tree_id' do
107
+ it 'is a 32-bit unsigned integer' do
108
+ expect(header.tree_id).to be_a BinData::Uint32le
109
+ end
110
+ end
111
+
112
+ describe '#session_id' do
113
+ it 'is a 64-bit unsigned integer' do
114
+ expect(header.session_id).to be_a BinData::Uint64le
115
+ end
116
+ end
117
+
118
+ describe '#signature' do
119
+ it 'is a binary string' do
120
+ expect(header.signature).to be_a BinData::String
121
+ end
122
+
123
+ it 'is 16 bytes' do
124
+ expect(header.signature.do_num_bytes).to eq 16
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,2 @@
1
+ RSpec.describe RubySMB do
2
+ end
@@ -0,0 +1,100 @@
1
+ require 'simplecov'
2
+
3
+ SimpleCov.start do
4
+ add_filter "/spec/"
5
+ end
6
+
7
+ require 'coveralls'
8
+ require 'ruby_smb'
9
+
10
+ if ENV['TRAVIS'] == 'true'
11
+ # don't generate local report as it is inaccessible on travis-ci, which is
12
+ # why coveralls is being used.
13
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
14
+ else
15
+ SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
16
+ end
17
+
18
+ Dir['./spec/support/**/*.rb'].sort.each { |f| require f }
19
+
20
+ # This file was generated by the `rspec --init` command. Conventionally, all
21
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
22
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
23
+ # this file to always be loaded, without a need to explicitly require it in any
24
+ # files.
25
+ #
26
+ # Given that it is always loaded, you are encouraged to keep this file as
27
+ # light-weight as possible. Requiring heavyweight dependencies from this file
28
+ # will add to the boot time of your test suite on EVERY test run, even for an
29
+ # individual file that may not need all of that loaded. Instead, consider making
30
+ # a separate helper file that requires the additional dependencies and performs
31
+ # the additional setup, and require it from the spec files that actually need
32
+ # it.
33
+ #
34
+ # The `.rspec` file also contains a few flags that are not defaults but that
35
+ # users commonly want.
36
+ #
37
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
38
+ RSpec.configure do |config|
39
+ # rspec-expectations config goes here. You can use an alternate
40
+ # assertion/expectation library such as wrong or the stdlib/minitest
41
+ # assertions if you prefer.
42
+ config.expect_with :rspec do |expectations|
43
+ expectations.syntax = :expect
44
+ end
45
+
46
+ # rspec-mocks config goes here. You can use an alternate test double
47
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
48
+ config.mock_with :rspec do |mocks|
49
+ # Prevents you from mocking or stubbing a method that does not exist on
50
+ # a real object. This is generally recommended, and will default to
51
+ # `true` in RSpec 4.
52
+ mocks.verify_partial_doubles = true
53
+ mocks.syntax = :expect
54
+ end
55
+
56
+ # These two settings work together to allow you to limit a spec run
57
+ # to individual examples or groups you care about by tagging them with
58
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
59
+ # get run.
60
+ config.filter_run :focus
61
+ config.run_all_when_everything_filtered = true
62
+
63
+ # Limits the available syntax to the non-monkey patched syntax that is
64
+ # recommended. For more details, see:
65
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
66
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
67
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
68
+ config.disable_monkey_patching!
69
+
70
+ # This setting enables warnings. It's recommended, but in some cases may
71
+ # be too noisy due to issues in dependencies.
72
+ config.warnings = false
73
+
74
+ # Many RSpec users commonly either run the entire suite or an individual
75
+ # file, and it's useful to allow more verbose output when running an
76
+ # individual spec file.
77
+ if config.files_to_run.one?
78
+ # Use the documentation formatter for detailed output,
79
+ # unless a formatter has already been configured
80
+ # (e.g. via a command-line flag).
81
+ config.default_formatter = 'doc'
82
+
83
+ # RSpec filters the backtrace by default so as not to be so noisy.
84
+ # This causes the full backtrace to be printed when running a single
85
+ # spec file (e.g. to troubleshoot a particular spec failure).
86
+ config.full_backtrace = true
87
+ end
88
+
89
+ # Run specs in random order to surface order dependencies. If you find an
90
+ # order dependency and want to debug it, you can fix the order by providing
91
+ # the seed, which is printed after each run.
92
+ # --seed 1234
93
+ config.order = :random
94
+
95
+ # Seed global randomization in this process using the `--seed` CLI option.
96
+ # Setting this allows you to use `--seed` to deterministically reproduce
97
+ # test failures related to randomization by passing the same `--seed` value
98
+ # as the one that triggered the failure.
99
+ Kernel.srand config.seed
100
+ end
@@ -0,0 +1,8 @@
1
+ require 'ruby_smb/dispatcher'
2
+ class MockSocketDispatcher < RubySMB::Dispatcher::Base
3
+ def recv_packet
4
+ ''
5
+ end
6
+
7
+ def send_packet(packet); end
8
+ end
@@ -0,0 +1,14 @@
1
+ RSpec.shared_examples 'bit field with one flag set' do |flag, pack, value|
2
+ it "has a value of #{value} when only #{flag} is set" do
3
+ subject.field_names.each do |sub_field|
4
+ if sub_field == flag
5
+ subject.send(sub_field.to_s.concat('=').to_sym, 1)
6
+ else
7
+ subject.send(sub_field.to_s.concat('=').to_sym, 0)
8
+ end
9
+ end
10
+ field_val = subject.to_binary_s
11
+ field_val = field_val.unpack(pack).first
12
+ expect(field_val).to eq value
13
+ end
14
+ end
data.tar.gz.sig ADDED
Binary file