rspec-dns 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e2d0c99bfad61e22a989ccc3544a63b9a84bb7f1
4
- data.tar.gz: c8f66c1099c58144d58bf5bc7887ba0367f2d6ed
3
+ metadata.gz: a5b1649bcb3fb43e7a9477d0b067e98641eddd00
4
+ data.tar.gz: 23857c8cd47db2afc0ba151b65985d3c46f9fa92
5
5
  SHA512:
6
- metadata.gz: af49390d95c4cbf8ae1fc2ba64734c8796f4b73224e5009affe4e04f6fc56869b76e1bd9a203c41091038b0c0e5dbce88f39972da85464c941c44b2899ac59d5
7
- data.tar.gz: 4b6215758311f378b00bedfe13e4a54a4a5646aa00aa53d0b113b4af47d157b7259af629100c521c09aff2dbf8d9f73de0078f868f094977c069f53d27acce87
6
+ metadata.gz: 705b3cfc3e884a3289a69ab244094694838e76f74540fe576dc1345c27d8cb73082eccd4f93c9cd787ea71821ef8cd0298723f87fccb34e1cea0b2f727ac29a1
7
+ data.tar.gz: 7372eef0ad1d0025baa54ddcf971d21ef0d2aa4b604e8681b2f09227426a872e339c79c54c0b3253396e7d343709f6be09b25275dc5b20237b944dedc1d4c4f0
@@ -5,3 +5,7 @@ script: "rake travis"
5
5
  rvm:
6
6
  - 1.9.3
7
7
  - 2.0.0
8
+
9
+ addons:
10
+ code_climate:
11
+ repo_token: 2feb9f7ee6d879b72c3b33fd897a801d7aa0eadcc72898242b5a2dff2435b937
data/Gemfile CHANGED
@@ -1,2 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
+
4
+ gem "codeclimate-test-reporter", group: :test, require: nil
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  rspec-dns
2
2
  =========
3
3
 
4
+ [![Gem Version](https://badge.fury.io/rb/rspec-dns.svg)](http://badge.fury.io/rb/rspec-dns)
4
5
  [![Build Status](https://travis-ci.org/spotify/rspec-dns.png?branch=master)](https://travis-ci.org/spotify/rspec-dns)
6
+ [![Dependency Status](https://gemnasium.com/spotify/rspec-dns.png)](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://dnsruby.rubyforge.org/classes/Dnsruby/RR.html) 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.
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.ruby-doc.org/gems/docs/d/Dnsruby-1.0/Dnsruby/Config.html).
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
 
@@ -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
- if (IPAddr.new(@dns) rescue nil) # Check if IPAddr(v4,v6)
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
@@ -1,5 +1,5 @@
1
1
  Gem::Specification.new do |s|
2
- s.version = '0.1.4'
2
+ s.version = '0.1.5'
3
3
  s.name = 'rspec-dns'
4
4
  s.authors = ['Seth Vargo', 'Alexey Lapitsky', 'Johannes Russek', 'Hiroshi OTA']
5
5
  s.email = 'alexey@spotify.com'
@@ -0,0 +1,11 @@
1
+ $TTL 86400
2
+
3
+ @ IN SOA ns.example.com. root.example.com. (
4
+ 2015020102 ; Serial
5
+ 3600 ; Refresh
6
+ 900 ; Retry
7
+ 604800 ; Expire
8
+ 900 ; Minimum
9
+ )
10
+ IN NS ns.example.com.
11
+ 4 IN PTR www.example.com.
@@ -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('.').to have_dns.with_type('NS')
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
@@ -1,3 +1,6 @@
1
+ require "codeclimate-test-reporter"
2
+ CodeClimate::TestReporter.start
3
+
1
4
  require 'rspec'
2
5
  require 'rspec-dns'
3
6
 
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
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-27 00:00:00.000000000 Z
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