rspec-dns 0.1.4 → 0.1.5
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.
- checksums.yaml +4 -4
- data/.travis.yml +4 -0
- data/Gemfile +2 -0
- data/README.md +4 -2
- data/lib/rspec-dns/have_dns.rb +8 -6
- data/rspec-dns.gemspec +1 -1
- data/spec/rspec-dns/0.2.0.192.rev.zone +11 -0
- data/spec/rspec-dns/have_dns_spec.rb +23 -1
- data/spec/spec_helper.rb +3 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5b1649bcb3fb43e7a9477d0b067e98641eddd00
|
4
|
+
data.tar.gz: 23857c8cd47db2afc0ba151b65985d3c46f9fa92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 705b3cfc3e884a3289a69ab244094694838e76f74540fe576dc1345c27d8cb73082eccd4f93c9cd787ea71821ef8cd0298723f87fccb34e1cea0b2f727ac29a1
|
7
|
+
data.tar.gz: 7372eef0ad1d0025baa54ddcf971d21ef0d2aa4b604e8681b2f09227426a872e339c79c54c0b3253396e7d343709f6be09b25275dc5b20237b944dedc1d4c4f0
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
rspec-dns
|
2
2
|
=========
|
3
3
|
|
4
|
+
[](http://badge.fury.io/rb/rspec-dns)
|
4
5
|
[](https://travis-ci.org/spotify/rspec-dns)
|
6
|
+
[](https://gemnasium.com/spotify/rspec-dns)
|
5
7
|
|
6
8
|
rspec-dns is an rspec plugin for easy DNS testing. It uses dnsruby instead of the standard library for the name resolution.
|
7
9
|
|
@@ -87,7 +89,7 @@ Here's some usage examples:
|
|
87
89
|
end
|
88
90
|
```
|
89
91
|
|
90
|
-
The other method chains are actually [Dnsruby](http://
|
92
|
+
The other method chains are actually [Dnsruby](http://www.rubydoc.info/gems/dnsruby/Dnsruby/RR) attributes on the record. You can prefix them with `and_`, `with_`, `and_with` or whatever your heart desires. The predicate is what is checked. The rest is syntactic sugar.
|
91
93
|
|
92
94
|
Depending on the type of record, the following attributes may be available:
|
93
95
|
|
@@ -141,7 +143,7 @@ nameserver:
|
|
141
143
|
If this file is missing Resolv will use the settings in /etc/resolv.conf.
|
142
144
|
You can also configure with `config` chain.
|
143
145
|
|
144
|
-
The full list of configuration options can be found on the [Dnsruby docs](http://www.
|
146
|
+
The full list of configuration options can be found on the [Dnsruby docs](http://www.rubydoc.info/gems/dnsruby/Dnsruby/Config).
|
145
147
|
|
146
148
|
### Configuring connection timeout
|
147
149
|
|
data/lib/rspec-dns/have_dns.rb
CHANGED
@@ -133,10 +133,16 @@ RSpec::Matchers.define :have_dns do
|
|
133
133
|
end
|
134
134
|
|
135
135
|
def _records
|
136
|
+
@_name ||= if (IPAddr.new(@dns) rescue nil) # Check if IPAddr(v4,v6)
|
137
|
+
IPAddr.new(@dns).reverse
|
138
|
+
else
|
139
|
+
@dns
|
140
|
+
end
|
141
|
+
|
136
142
|
if @zone_file
|
137
143
|
@_records = Dnsruby::Message.new
|
138
144
|
rrs = Dnsruby::ZoneReader.new(@zone_origin).process_file(@zone_file)
|
139
|
-
rrs.each { |rr| @_records.add_answer(rr) }
|
145
|
+
rrs.each { |rr| @_records.add_answer(rr) if @_name == rr.name.to_s }
|
140
146
|
end
|
141
147
|
|
142
148
|
@_records ||= begin
|
@@ -146,11 +152,7 @@ RSpec::Matchers.define :have_dns do
|
|
146
152
|
Timeout::timeout(query_timeout + 0.2) do
|
147
153
|
resolver = Dnsruby::Resolver.new(config)
|
148
154
|
resolver.query_timeout = query_timeout
|
149
|
-
|
150
|
-
resolver.query(@dns, Dnsruby::Types.PTR)
|
151
|
-
else
|
152
|
-
resolver.query(@dns, Dnsruby::Types.ANY)
|
153
|
-
end
|
155
|
+
resolver.query(@_name, Dnsruby::Types.ANY)
|
154
156
|
end
|
155
157
|
rescue Exception => e
|
156
158
|
if Dnsruby::NXDomain === e
|
data/rspec-dns.gemspec
CHANGED
@@ -133,17 +133,39 @@ describe 'rspec-dns matchers' do
|
|
133
133
|
expect('www.example.com').to have_dns.with_type('A')
|
134
134
|
.and_address('192.0.2.4')
|
135
135
|
.in_zone_file(file, origin)
|
136
|
+
expect('doubt.example.com').not_to have_dns.with_type('A')
|
137
|
+
.and_address('192.0.2.4')
|
138
|
+
.in_zone_file(file, origin)
|
136
139
|
expect('www.example.com').to have_dns.with_type('AAAA')
|
137
140
|
.and_address('2001:DB8:6C::430')
|
138
141
|
.in_zone_file(file, origin)
|
139
142
|
end
|
143
|
+
context 'in reverse' do
|
144
|
+
it 'can evalutate PTR records in zone file' do
|
145
|
+
file = 'spec/rspec-dns/0.2.0.192.rev.zone'
|
146
|
+
origin = '2.0.192.in-addr.arpa.'
|
147
|
+
|
148
|
+
expect('4.2.0.192.in-addr.arpa').to have_dns.with_type('PTR')
|
149
|
+
.and_domainname('www.example.com')
|
150
|
+
.in_zone_file(file, origin)
|
151
|
+
expect('5.2.0.192.in-addr.arpa').not_to have_dns.with_type('PTR')
|
152
|
+
.and_domainname('www.example.com')
|
153
|
+
.in_zone_file(file, origin)
|
154
|
+
expect('192.0.2.4').to have_dns.with_type('PTR')
|
155
|
+
.and_domainname('www.example.com')
|
156
|
+
.in_zone_file(file, origin)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
140
160
|
it 'can evalutate records in zone file without origin' do
|
141
161
|
file = 'spec/rspec-dns/example.zone'
|
142
162
|
|
143
|
-
expect('
|
163
|
+
expect('').to have_dns.with_type('NS')
|
144
164
|
.and_domainname('ns').in_zone_file(file)
|
145
165
|
expect('www').to have_dns.with_type('A')
|
146
166
|
.and_address('192.0.2.4').in_zone_file(file)
|
167
|
+
expect('doubt').not_to have_dns.with_type('A')
|
168
|
+
.and_address('192.0.2.4').in_zone_file(file)
|
147
169
|
end
|
148
170
|
it 'can evalutate records with dns servers if file is nil' do
|
149
171
|
file = nil
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-dns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seth Vargo
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-01
|
14
|
+
date: 2015-02-01 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rake
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- lib/rspec-dns.rb
|
72
72
|
- lib/rspec-dns/have_dns.rb
|
73
73
|
- rspec-dns.gemspec
|
74
|
+
- spec/rspec-dns/0.2.0.192.rev.zone
|
74
75
|
- spec/rspec-dns/example.zone
|
75
76
|
- spec/rspec-dns/have_dns_spec.rb
|
76
77
|
- spec/spec_helper.rb
|
@@ -100,6 +101,7 @@ specification_version: 4
|
|
100
101
|
summary: rspec-dns provides an easy-to-use DSL for testing your DNS records are responding
|
101
102
|
as they should.
|
102
103
|
test_files:
|
104
|
+
- spec/rspec-dns/0.2.0.192.rev.zone
|
103
105
|
- spec/rspec-dns/example.zone
|
104
106
|
- spec/rspec-dns/have_dns_spec.rb
|
105
107
|
- spec/spec_helper.rb
|