dns_adapter 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/dns_adapter.gemspec +1 -1
- data/lib/dns_adapter/resolv_client.rb +8 -4
- data/lib/dns_adapter/version.rb +1 -1
- data/spec/resolv_client_spec.rb +64 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f19132b4cfb08ff5ec8ebf1d890930207c2b8878
|
4
|
+
data.tar.gz: 1b169dc215f89e09f844f64e4f0573704716b706
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95f8e9bebe8cbe45c4f9b4c8b102e4184228952c202d274b8b6595dea6a8ccc774c13f5a190e2eabd8976314d61d57da1da79d25bec9ac56444899e96fcef345
|
7
|
+
data.tar.gz: be86352abc7d1f4f5a038e6ead661fc620cc7f4955ea7d0078a6f10655b1efe5dd30cbe2f0bdddf33891ace87a6a913db2b71c3f2c80eb5aa10f5680108d8616
|
data/.travis.yml
CHANGED
data/dns_adapter.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(/^(test|spec|features)\//)
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency 'bundler'
|
21
|
+
spec.add_development_dependency 'bundler'
|
22
22
|
spec.add_development_dependency 'rake', '~> 10.0'
|
23
23
|
spec.add_development_dependency 'rspec', '>= 3.0'
|
24
24
|
spec.add_development_dependency 'rubocop'
|
@@ -16,7 +16,8 @@ module DNSAdapter
|
|
16
16
|
fetch_records(domain, 'MX') do |record|
|
17
17
|
{
|
18
18
|
type: 'MX',
|
19
|
-
exchange: record.exchange.to_s
|
19
|
+
exchange: record.exchange.to_s,
|
20
|
+
ttl: record.ttl
|
20
21
|
}
|
21
22
|
end
|
22
23
|
end
|
@@ -25,7 +26,8 @@ module DNSAdapter
|
|
25
26
|
fetch_records(arpa_address, 'PTR') do |record|
|
26
27
|
{
|
27
28
|
type: 'PTR',
|
28
|
-
name: record.name.to_s
|
29
|
+
name: record.name.to_s,
|
30
|
+
ttl: record.ttl
|
29
31
|
}
|
30
32
|
end
|
31
33
|
end
|
@@ -44,7 +46,8 @@ module DNSAdapter
|
|
44
46
|
fetch_records(domain, type) do |record|
|
45
47
|
{
|
46
48
|
type: type,
|
47
|
-
address: record.address.to_s
|
49
|
+
address: record.address.to_s,
|
50
|
+
ttl: record.ttl
|
48
51
|
}
|
49
52
|
end
|
50
53
|
end
|
@@ -55,7 +58,8 @@ module DNSAdapter
|
|
55
58
|
type: type,
|
56
59
|
# Use strings.join('') to avoid JRuby issue where
|
57
60
|
# data only returns the first string
|
58
|
-
text: record.strings.join('')
|
61
|
+
text: record.strings.join(''),
|
62
|
+
ttl: record.ttl
|
59
63
|
}
|
60
64
|
end
|
61
65
|
end
|
data/lib/dns_adapter/version.rb
CHANGED
data/spec/resolv_client_spec.rb
CHANGED
@@ -56,6 +56,16 @@ describe DNSAdapter::ResolvClient do
|
|
56
56
|
subject.fetch_a_records(domain_with_trailing)
|
57
57
|
end.to raise_error(DNSAdapter::TimeoutError)
|
58
58
|
end
|
59
|
+
|
60
|
+
it 'should map the Resolv timeout errors to Coppertone errors' do
|
61
|
+
expect(Resolv::DNS).to receive(:new).and_return(mock_resolver)
|
62
|
+
expect(mock_resolver).to receive(:getresources)
|
63
|
+
.with(domain, Resolv::DNS::Resource::IN::A)
|
64
|
+
.and_return(nil)
|
65
|
+
expect do
|
66
|
+
subject.fetch_a_records(domain_with_trailing)
|
67
|
+
end.to raise_error(DNSAdapter::Error)
|
68
|
+
end
|
59
69
|
end
|
60
70
|
|
61
71
|
context '#fetch_aaaa_records' do
|
@@ -304,4 +314,58 @@ describe DNSAdapter::ResolvClient do
|
|
304
314
|
.to raise_error(DNSAdapter::TimeoutError)
|
305
315
|
end
|
306
316
|
end
|
317
|
+
|
318
|
+
context '#fetch_ptr_records' do
|
319
|
+
let(:first_ptr_name) { SecureRandom.hex(10) }
|
320
|
+
let(:first_ptr_record) do
|
321
|
+
Resolv::DNS::Resource::IN::PTR.new(first_ptr_name)
|
322
|
+
end
|
323
|
+
let(:record_list) { [first_ptr_record] }
|
324
|
+
let(:arpa_domain) { '126.18.67.80.in-addr.arpa' }
|
325
|
+
let(:arpa_domain_with_trailing) { "#{arpa_domain}." }
|
326
|
+
|
327
|
+
it 'should map the Resolv classes to a set of hashes' do
|
328
|
+
expect(Resolv::DNS).to receive(:new).and_return(mock_resolver)
|
329
|
+
expect(mock_resolver).to receive(:getresources)
|
330
|
+
.with(arpa_domain, Resolv::DNS::Resource::IN::PTR)
|
331
|
+
.and_return(record_list)
|
332
|
+
results = subject.fetch_ptr_records(arpa_domain)
|
333
|
+
expect(results.size).to eq(record_list.length)
|
334
|
+
expect(results.map { |x| x[:type] })
|
335
|
+
.to eq(record_list.length.times.map { 'PTR' })
|
336
|
+
expect(results.map { |x| x[:name] }).to eq(
|
337
|
+
[first_ptr_name])
|
338
|
+
end
|
339
|
+
|
340
|
+
it 'should map when the domain has a trailing dot' do
|
341
|
+
expect(Resolv::DNS).to receive(:new).and_return(mock_resolver)
|
342
|
+
expect(mock_resolver).to receive(:getresources)
|
343
|
+
.with(arpa_domain, Resolv::DNS::Resource::IN::PTR)
|
344
|
+
.and_return(record_list)
|
345
|
+
results = subject.fetch_ptr_records(arpa_domain_with_trailing)
|
346
|
+
expect(results.size).to eq(record_list.length)
|
347
|
+
expect(results.map { |x| x[:type] })
|
348
|
+
.to eq(record_list.length.times.map { 'PTR' })
|
349
|
+
expect(results.map { |x| x[:name] }).to eq(
|
350
|
+
[first_ptr_name])
|
351
|
+
end
|
352
|
+
|
353
|
+
it 'should map the Resolv errors to Coppertone errors' do
|
354
|
+
expect(Resolv::DNS).to receive(:new).and_return(mock_resolver)
|
355
|
+
expect(mock_resolver).to receive(:getresources)
|
356
|
+
.with(arpa_domain, Resolv::DNS::Resource::IN::PTR)
|
357
|
+
.and_raise(Resolv::ResolvError)
|
358
|
+
expect { subject.fetch_ptr_records(arpa_domain_with_trailing) }
|
359
|
+
.to raise_error(DNSAdapter::Error)
|
360
|
+
end
|
361
|
+
|
362
|
+
it 'should map the Resolv timeout errors to Coppertone errors' do
|
363
|
+
expect(Resolv::DNS).to receive(:new).and_return(mock_resolver)
|
364
|
+
expect(mock_resolver).to receive(:getresources)
|
365
|
+
.with(arpa_domain, Resolv::DNS::Resource::IN::PTR)
|
366
|
+
.and_raise(Resolv::ResolvTimeout)
|
367
|
+
expect { subject.fetch_ptr_records(arpa_domain_with_trailing) }
|
368
|
+
.to raise_error(DNSAdapter::TimeoutError)
|
369
|
+
end
|
370
|
+
end
|
307
371
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dns_adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter M. Goldstein
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
108
|
version: '0'
|
109
109
|
requirements: []
|
110
110
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.4.
|
111
|
+
rubygems_version: 2.4.5
|
112
112
|
signing_key:
|
113
113
|
specification_version: 4
|
114
114
|
summary: An adapter layer for DNS queries.
|