assert_zone 0.1.0 → 0.2.0

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: 89d8940f7e5ac70cbb41e52e420da161f62cc3c1
4
- data.tar.gz: da902f0de706d65602f7edee7686b77736ad3d92
3
+ metadata.gz: fa0ffd6f47f0c8ca157e80874169820de36d3aab
4
+ data.tar.gz: e556bf0c5d46eca4db28a64cd97fde1cb17c4902
5
5
  SHA512:
6
- metadata.gz: b7c2d0f93db961e7381c7f4c8c9a14f92005b6d46b306f5e36640cdcd6b825d3f32087099b295c8945b3b311ad46044205fc754c1276dfa25e16beedcb2b3551
7
- data.tar.gz: 19149e2e6b3ba287307474ada76ca7581ae375cdf76414701fb9dd3daf7adaf2348a2f026f7d02d555a706ee25290a232ff4c339de535f80f2da3e0fd75514d2
6
+ metadata.gz: ce624793f4c312c70237e5eff306a32b878ef9f7d24236023e21e01e43064bf0b1b3441f63a93f2f6692e022837b5d347382637db40660c1a54384d3695d4a57
7
+ data.tar.gz: c51a633907b983b39d2adb97e9ae499ffcbd87ffe49504cbb6f0d822cade7e63fb4eb44ba03d56309acacea1564d2dcdb2f1dab27ac08d4e2464ca6ca810cf89
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
- # AssertZone
1
+ # assert_zone
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/assert_zone`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ This small utility will help you verify that a DNS server is responding with the correct information, based on a zone file.
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,7 +20,16 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ It's simple: `assert_zone ZONE_FILE [NAMESERVER] [options]`
24
+
25
+ Assuming you have a zone file named `zone.txt` in the current directory, you can run `assert_zone zone.txt` to verify that each record in the zone file matches what the nameserver responds with.
26
+
27
+ By default, it will use the nameserver listed in the SOA record in the zone file. You can also specify a custom nameserver: `assert_zone zone.txt ns1.example.com`.
28
+
29
+ There are a few option flags you can add to the command:
30
+
31
+ * `--color` will display the results in color
32
+ * `--use-local-resolver` will not specify a nameserver and will use your system settings
26
33
 
27
34
  ## Development
28
35
 
@@ -32,10 +39,9 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
39
 
33
40
  ## Contributing
34
41
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/assert_zone.
42
+ Bug reports and pull requests are welcome on GitHub at https://github.com/dwradcliffe/assert_zone.
36
43
 
37
44
 
38
45
  ## License
39
46
 
40
47
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
-
data/exe/assert_zone CHANGED
@@ -4,12 +4,18 @@ require 'bundler/setup'
4
4
  require 'assert_zone'
5
5
  require 'optparse'
6
6
 
7
- flags = []
7
+ options = {
8
+ rspec_flags: [],
9
+ use_local_resolver: false
10
+ }
8
11
 
9
12
  OptionParser.new do |opts|
10
13
  opts.banner = "Usage: assert_zone ZONE_FILE [NAMESERVER] [options]"
11
14
  opts.on('--color', 'Use color') do |v|
12
- flags << '--color'
15
+ options[:rspec_flags] << '--color'
16
+ end
17
+ opts.on('--use-local-resolver', 'Use local resolver settings instead of explicit nameserver') do |v|
18
+ options[:use_local_resolver] = true
13
19
  end
14
20
  opts.on_tail('-h', '--help', 'Show this message') do
15
21
  puts opts
@@ -21,4 +27,4 @@ OptionParser.new do |opts|
21
27
  end
22
28
  end.parse!
23
29
 
24
- AssertZone.run(ARGV[0], ARGV[1], flags)
30
+ AssertZone.run(ARGV[0], nameserver: ARGV[1], rspec_flags: options[:rspec_flags], use_local_resolver: options[:use_local_resolver])
@@ -1,3 +1,3 @@
1
1
  module AssertZone
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/assert_zone.rb CHANGED
@@ -4,16 +4,23 @@ require 'rspec'
4
4
  require 'rspec-dns'
5
5
 
6
6
  module AssertZone
7
- def self.run(filename, nameserver = nil, rspec_flags = [])
7
+ def self.run(filename, nameserver: nil, rspec_flags: [], use_local_resolver: false)
8
8
  ns_config = {}
9
9
  ns_config[:nameserver] = nameserver if nameserver
10
10
 
11
11
  zone = DNS::Zone.load(File.read(filename))
12
12
 
13
+ unless use_local_resolver
14
+ # default to nameserver from SOA in zone
15
+ ns_config[:nameserver] ||= zone.soa.nameserver
16
+ # output the custom nameserver
17
+ puts "Using nameserver: #{ns_config[:nameserver]}"
18
+ end
19
+
13
20
  zone.records.each do |record|
14
21
  next if ['SOA', 'NS'].include?(record.type)
15
22
 
16
- fqdn = record.label == '@' ? zone.origin : "#{record.label}.#{zone.origin}"
23
+ fqdn = record.label == '@' ? zone.origin : "#{record.label}.#{zone.origin}".chomp('.')
17
24
 
18
25
  describe fqdn do
19
26
  if record.is_a?(DNS::Zone::RR::A)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assert_zone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Radcliffe