mock_dns_server 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +24 -0
  5. data/README.md +127 -0
  6. data/RELEASE_NOTES.md +3 -0
  7. data/Rakefile +19 -0
  8. data/bin/show_dig_request +41 -0
  9. data/lib/mock_dns_server.rb +12 -0
  10. data/lib/mock_dns_server/action_factory.rb +84 -0
  11. data/lib/mock_dns_server/conditional_action.rb +42 -0
  12. data/lib/mock_dns_server/conditional_action_factory.rb +53 -0
  13. data/lib/mock_dns_server/conditional_actions.rb +73 -0
  14. data/lib/mock_dns_server/dnsruby_monkey_patch.rb +19 -0
  15. data/lib/mock_dns_server/history.rb +84 -0
  16. data/lib/mock_dns_server/history_inspections.rb +58 -0
  17. data/lib/mock_dns_server/ip_address_dispenser.rb +34 -0
  18. data/lib/mock_dns_server/message_builder.rb +199 -0
  19. data/lib/mock_dns_server/message_helper.rb +86 -0
  20. data/lib/mock_dns_server/message_transformer.rb +74 -0
  21. data/lib/mock_dns_server/predicate_factory.rb +108 -0
  22. data/lib/mock_dns_server/serial_history.rb +385 -0
  23. data/lib/mock_dns_server/serial_number.rb +129 -0
  24. data/lib/mock_dns_server/serial_transaction.rb +46 -0
  25. data/lib/mock_dns_server/server.rb +422 -0
  26. data/lib/mock_dns_server/server_context.rb +57 -0
  27. data/lib/mock_dns_server/server_thread.rb +13 -0
  28. data/lib/mock_dns_server/version.rb +3 -0
  29. data/mock_dns_server.gemspec +32 -0
  30. data/spec/mock_dns_server/conditions_factory_spec.rb +58 -0
  31. data/spec/mock_dns_server/history_inspections_spec.rb +84 -0
  32. data/spec/mock_dns_server/history_spec.rb +65 -0
  33. data/spec/mock_dns_server/ip_address_dispenser_spec.rb +30 -0
  34. data/spec/mock_dns_server/message_builder_spec.rb +18 -0
  35. data/spec/mock_dns_server/predicate_factory_spec.rb +147 -0
  36. data/spec/mock_dns_server/serial_history_spec.rb +385 -0
  37. data/spec/mock_dns_server/serial_number_spec.rb +119 -0
  38. data/spec/mock_dns_server/serial_transaction_spec.rb +37 -0
  39. data/spec/mock_dns_server/server_context_spec.rb +20 -0
  40. data/spec/mock_dns_server/server_spec.rb +411 -0
  41. data/spec/mock_dns_server/socket_research_spec.rb +59 -0
  42. data/spec/spec_helper.rb +44 -0
  43. data/todo.txt +0 -0
  44. metadata +212 -0
@@ -0,0 +1,59 @@
1
+ require_relative '../spec_helper'
2
+ require 'socket'
3
+
4
+ module MockDnsServer
5
+
6
+ # These tests were for research purposes only and are not related to the correct operation
7
+ # of this gem. It turns out that the results of these tests differed on different OS's.
8
+
9
+ =begin
10
+
11
+ describe "UDP sockets" do
12
+
13
+ it "should be able to immediately reuse an address (port) if the previous socket was closed" do
14
+ port = 8870
15
+ socket = UDPSocket.new
16
+ socket.bind(nil, port)
17
+ socket.close
18
+
19
+ expect(-> do
20
+ socket = UDPSocket.new
21
+ socket.bind(nil, port)
22
+ socket.close
23
+ end).to_not raise_error
24
+
25
+ end
26
+
27
+
28
+ it "should NOT be able to immediately reuse an address (port) if the previous socket was NOT closed" do
29
+ port = 8860
30
+ socket = UDPSocket.new
31
+ socket.bind(nil, port)
32
+
33
+ expect(-> do
34
+ socket = UDPSocket.new
35
+ socket.bind(nil, port)
36
+ socket.close
37
+ end).to raise_error
38
+ end
39
+
40
+
41
+ it "should NOT be able to immediately reuse an address (port) if the previous socket was NOT closed even if REUSEADDR was enabled" do
42
+ port = 8884
43
+ socket = UDPSocket.new
44
+ socket.setsockopt(Socket::SOL_SOCKET,Socket::SO_REUSEADDR, true)
45
+ socket.bind(nil, port)
46
+
47
+ expect(-> do
48
+ socket2 = UDPSocket.new
49
+ socket2.setsockopt(Socket::SOL_SOCKET,Socket::SO_REUSEADDR, true)
50
+ socket2.bind(nil, port)
51
+ socket2.close
52
+ end).to raise_error
53
+
54
+ end
55
+
56
+ end
57
+
58
+ =end
59
+ end
@@ -0,0 +1,44 @@
1
+ require 'rspec'
2
+
3
+ $LOAD_PATH << File.join(File.dirname(__FILE__), '..', '..', 'lib')
4
+
5
+ #class Object
6
+ # def puts(s)
7
+ # print "#{Thread.current}: #{s}\n"
8
+ # end
9
+ #end
10
+
11
+ RSpec.configure do |config|
12
+
13
+ config.expect_with :rspec do |c|
14
+ # disable (forbid) the `should` syntax; it's deprecated and will later be removed
15
+ c.syntax = :expect
16
+ end
17
+ end
18
+
19
+
20
+ # Returns a function seeded with the specified record array and zone
21
+ # that can be used to test a given SOA RR and serial value.
22
+ def check_soa_fn(record_array, zone)
23
+ ->(index, serial) do
24
+ rr = record_array[index]
25
+ expect(rr.class).to eq(Dnsruby::RR::IN::SOA)
26
+ expect(rr.serial).to eq(serial)
27
+ expect(rr.name.to_s).to eq(zone.to_s)
28
+ end
29
+ end
30
+
31
+
32
+ # Returns a function seeded with the specified record array and name
33
+ # that can be used to test a given A RR and address.
34
+ def check_a_fn(record_array, name)
35
+ ->(index, address) do
36
+ rr = record_array[index]
37
+ expect(rr.class).to eq(Dnsruby::RR::IN::A)
38
+ expect(rr.name.to_s).to eq(name.to_s)
39
+ expect(rr.address.to_s).to eq(address.to_s)
40
+ end
41
+ end
42
+
43
+
44
+
File without changes
metadata ADDED
@@ -0,0 +1,212 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mock_dns_server
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - Keith Bennett
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dnsruby
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.54'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.54'
27
+ - !ruby/object:Gem::Dependency
28
+ name: hexdump
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '0.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '0.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thread_safe
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '0.3'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '0.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: awesome_print
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.2'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '1.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '1.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: '10.1'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '10.1'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '3.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ version: '3.0'
125
+ description: Mock DNS Server
126
+ email:
127
+ - keithrbennett@gmail.com
128
+ executables:
129
+ - show_dig_request
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - .gitignore
134
+ - Gemfile
135
+ - LICENSE.txt
136
+ - README.md
137
+ - RELEASE_NOTES.md
138
+ - Rakefile
139
+ - bin/show_dig_request
140
+ - lib/mock_dns_server.rb
141
+ - lib/mock_dns_server/action_factory.rb
142
+ - lib/mock_dns_server/conditional_action.rb
143
+ - lib/mock_dns_server/conditional_action_factory.rb
144
+ - lib/mock_dns_server/conditional_actions.rb
145
+ - lib/mock_dns_server/dnsruby_monkey_patch.rb
146
+ - lib/mock_dns_server/history.rb
147
+ - lib/mock_dns_server/history_inspections.rb
148
+ - lib/mock_dns_server/ip_address_dispenser.rb
149
+ - lib/mock_dns_server/message_builder.rb
150
+ - lib/mock_dns_server/message_helper.rb
151
+ - lib/mock_dns_server/message_transformer.rb
152
+ - lib/mock_dns_server/predicate_factory.rb
153
+ - lib/mock_dns_server/serial_history.rb
154
+ - lib/mock_dns_server/serial_number.rb
155
+ - lib/mock_dns_server/serial_transaction.rb
156
+ - lib/mock_dns_server/server.rb
157
+ - lib/mock_dns_server/server_context.rb
158
+ - lib/mock_dns_server/server_thread.rb
159
+ - lib/mock_dns_server/version.rb
160
+ - mock_dns_server.gemspec
161
+ - spec/mock_dns_server/conditions_factory_spec.rb
162
+ - spec/mock_dns_server/history_inspections_spec.rb
163
+ - spec/mock_dns_server/history_spec.rb
164
+ - spec/mock_dns_server/ip_address_dispenser_spec.rb
165
+ - spec/mock_dns_server/message_builder_spec.rb
166
+ - spec/mock_dns_server/predicate_factory_spec.rb
167
+ - spec/mock_dns_server/serial_history_spec.rb
168
+ - spec/mock_dns_server/serial_number_spec.rb
169
+ - spec/mock_dns_server/serial_transaction_spec.rb
170
+ - spec/mock_dns_server/server_context_spec.rb
171
+ - spec/mock_dns_server/server_spec.rb
172
+ - spec/mock_dns_server/socket_research_spec.rb
173
+ - spec/spec_helper.rb
174
+ - todo.txt
175
+ homepage: http://www.github.com
176
+ licenses:
177
+ - BSD-3-Clause
178
+ metadata: {}
179
+ post_install_message:
180
+ rdoc_options: []
181
+ require_paths:
182
+ - lib
183
+ required_ruby_version: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - '>='
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ required_rubygems_version: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - '>='
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
193
+ requirements: []
194
+ rubyforge_project:
195
+ rubygems_version: 2.0.14
196
+ signing_key:
197
+ specification_version: 4
198
+ summary: Mock DNS Server
199
+ test_files:
200
+ - spec/mock_dns_server/conditions_factory_spec.rb
201
+ - spec/mock_dns_server/history_inspections_spec.rb
202
+ - spec/mock_dns_server/history_spec.rb
203
+ - spec/mock_dns_server/ip_address_dispenser_spec.rb
204
+ - spec/mock_dns_server/message_builder_spec.rb
205
+ - spec/mock_dns_server/predicate_factory_spec.rb
206
+ - spec/mock_dns_server/serial_history_spec.rb
207
+ - spec/mock_dns_server/serial_number_spec.rb
208
+ - spec/mock_dns_server/serial_transaction_spec.rb
209
+ - spec/mock_dns_server/server_context_spec.rb
210
+ - spec/mock_dns_server/server_spec.rb
211
+ - spec/mock_dns_server/socket_research_spec.rb
212
+ - spec/spec_helper.rb