dns-zonefile 1.1.0 → 1.1.2

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: 2827522219ce8faf8c79547c65317965d5a628eb
4
- data.tar.gz: 9cb7a17d1ee296c80c68e682ee1b4d3a2384232e
3
+ metadata.gz: dd38c55e83f1bf952fdba0831fd183b81bf2f556
4
+ data.tar.gz: 11c7b7481eb3bf6f56ca8fe46f64ee4c5516e421
5
5
  SHA512:
6
- metadata.gz: 786c0b7a22598d0f27826ef8c3e7ea8e851e990fedd981f3d88dd112c98a8b483f1c7fd665eddf51a83f60a23360350a81a714699a0a5225c1f2a4482c037e8d
7
- data.tar.gz: 654452ea27aa6752a3d2a275e93634dee0283c3e3011a782254e83fe73e7fbaa9e88433bc2b0947d3200475aa6c4aca8c05faff34c68c928c8f45ffae3d2c5c1
6
+ metadata.gz: 3820bd3385d77de0f50d99afa3ab5bd74ca370ebfb92caa9984042d318936c9e9de968437af0d117f97d65341b6455594c1262417011a39d9be6696ecb339ee7
7
+ data.tar.gz: 83b879336f94c811c1b4075b7a5e86dedc2304ae94f7d6dad28c2b09166c665d565be90c3f4f37dae2fc74ea7a45dda001a07318b3785fc48f977db58f407918
data/.gitignore CHANGED
@@ -1,3 +1,10 @@
1
- *.gem
2
- .rvmrc
3
- Gemfile.lock
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /dns-zonefile-*.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -1,4 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - ruby-head
4
- - 2.3.0
3
+ - 2.2.4
4
+ before_install: gem install bundler -v 1.11.2
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in dns-zonefile.gemspec
4
4
  gemspec
data/Rakefile CHANGED
@@ -1,11 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
2
3
 
3
- require 'rake'
4
- require 'rspec/core/rake_task'
5
4
  RSpec::Core::RakeTask.new(:spec)
6
5
 
7
- task :default => [ :spec ]
8
-
9
- task :build do
10
- puts %x[gem build dns-zonefile.gemspec]
11
- end
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "dns/zonefile"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -1,31 +1,42 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "dns/zonefile/version"
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dns/zonefile/version'
4
5
 
5
- Gem::Specification.new do |s|
6
- s.name = "dns-zonefile"
7
- s.version = DNS::Zonefile::VERSION
8
- s.authors = ["Craig R Webster"]
9
- s.email = ["craig@barkingiguana.com"]
10
- s.homepage = ""
11
- s.summary = %q{Work with zonefiles (RFC 1035 section 5 and RFC 1034 section 3.6.1)}
12
- s.description = %q{The format of a DNS Zonefile is defined in RFC 1035 section 5 and RFC
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "dns-zonefile"
8
+ spec.version = DNS::Zonefile::VERSION
9
+ spec.authors = ["Craig R Webster"]
10
+ spec.email = ["craig@barkingiguana.com"]
11
+
12
+ spec.summary = %q{Work with zonefiles (RFC 1035 section 5 and RFC 1034 section 3.6.1)}
13
+ spec.description = <<-EOD
14
+ The format of a DNS Zonefile is defined in RFC 1035 section 5 and RFC
13
15
  1034 section 3.6.1. To anyone who's using BIND they'll look very
14
16
  familiar.
15
17
 
16
18
  This is an attempt to use Ruby parse them into an object graph which can
17
19
  be investigated programatically, manipulated, validated or printed into
18
- some canonical form.}
20
+ some canonical form.
21
+ EOD
22
+ spec.homepage = "http://barkingiguana.com/"
19
23
 
20
- s.rubyforge_project = "dns-zonefile"
24
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
25
+ # delete this section to allow pushing this gem to any host.
26
+ if spec.respond_to?(:metadata)
27
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
28
+ else
29
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
30
+ end
21
31
 
22
- s.files = `git ls-files`.split("\n")
23
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
24
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
25
- s.require_paths = ["lib"]
32
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
33
+ spec.bindir = "exe"
34
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
35
+ spec.require_paths = ["lib"]
26
36
 
27
- s.add_development_dependency "rspec"
28
- s.add_development_dependency "rake"
29
- s.add_runtime_dependency "treetop"
30
- s.add_runtime_dependency "polyglot"
37
+ spec.add_dependency "treetop", '~> 1.6'
38
+ spec.add_dependency "polyglot", '~> 0.3'
39
+ spec.add_development_dependency "bundler", "~> 1.11"
40
+ spec.add_development_dependency "rake", "~> 10.0"
41
+ spec.add_development_dependency "rspec", "~> 3.0"
31
42
  end
@@ -1,6 +1,6 @@
1
1
  require 'dns/zonefile/version'
2
2
  require 'treetop'
3
- Treetop.load 'lib/dns/zonefile'
3
+ Treetop.load File.expand_path('../zonefile', __FILE__)
4
4
 
5
5
  module DNS
6
6
  module Zonefile
@@ -1,5 +1,5 @@
1
1
  module DNS
2
2
  module Zonefile
3
- VERSION = "1.1.0"
3
+ VERSION = "1.1.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,72 +1,86 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dns-zonefile
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig R Webster
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-01 00:00:00.000000000 Z
11
+ date: 2016-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rspec
14
+ name: treetop
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
19
+ version: '1.6'
20
+ type: :runtime
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: '0'
26
+ version: '1.6'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: polyglot
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '0.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.11'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - ">="
52
+ - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '0'
54
+ version: '1.11'
41
55
  - !ruby/object:Gem::Dependency
42
- name: treetop
56
+ name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - ">="
59
+ - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
61
+ version: '10.0'
62
+ type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - ">="
66
+ - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: '0'
68
+ version: '10.0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: polyglot
70
+ name: rspec
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - ">="
73
+ - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
75
+ version: '3.0'
76
+ type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - ">="
80
+ - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: '0'
69
- description: |-
82
+ version: '3.0'
83
+ description: |
70
84
  The format of a DNS Zonefile is defined in RFC 1035 section 5 and RFC
71
85
  1034 section 3.6.1. To anyone who's using BIND they'll look very
72
86
  familiar.
@@ -81,6 +95,7 @@ extensions: []
81
95
  extra_rdoc_files: []
82
96
  files:
83
97
  - ".gitignore"
98
+ - ".rspec"
84
99
  - ".travis.yml"
85
100
  - Dockerfile
86
101
  - Gemfile
@@ -88,6 +103,8 @@ files:
88
103
  - README.md
89
104
  - Rakefile
90
105
  - TODO
106
+ - bin/console
107
+ - bin/setup
91
108
  - dns-zonefile.gemspec
92
109
  - doc/example.com.zone
93
110
  - doc/example2.com.zone
@@ -97,11 +114,10 @@ files:
97
114
  - lib/dns/zonefile.rb
98
115
  - lib/dns/zonefile.treetop
99
116
  - lib/dns/zonefile/version.rb
100
- - spec/dns/zonefile_spec.rb
101
- - spec/spec_helper.rb
102
- homepage: ''
117
+ homepage: http://barkingiguana.com/
103
118
  licenses: []
104
- metadata: {}
119
+ metadata:
120
+ allowed_push_host: https://rubygems.org
105
121
  post_install_message:
106
122
  rdoc_options: []
107
123
  require_paths:
@@ -117,11 +133,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
133
  - !ruby/object:Gem::Version
118
134
  version: '0'
119
135
  requirements: []
120
- rubyforge_project: dns-zonefile
136
+ rubyforge_project:
121
137
  rubygems_version: 2.4.5.1
122
138
  signing_key:
123
139
  specification_version: 4
124
140
  summary: Work with zonefiles (RFC 1035 section 5 and RFC 1034 section 3.6.1)
125
- test_files:
126
- - spec/dns/zonefile_spec.rb
127
- - spec/spec_helper.rb
141
+ test_files: []
@@ -1,435 +0,0 @@
1
- require 'spec_helper'
2
- require 'dns/zonefile'
3
-
4
- RSpec.describe "DNS::Zonefile" do
5
- it "should be versioned" do
6
- expect { DNS::Zonefile.const_get(:VERSION) }.to_not raise_error
7
- end
8
-
9
- it "should provide a way of parsing a string" do
10
- expect(DNS::Zonefile).to respond_to(:parse)
11
- end
12
-
13
- describe "parsing a zonefile string" do
14
- before(:each) do
15
- @zonefile =<<-ZONE
16
- ; Hi! I'm an example zonefile.
17
- $ORIGIN example.com.
18
- $TTL 86400; expire in 1 day.
19
- $OTHER abc
20
- ; line above has spaces at the end, but no comment
21
- @ IN SOA ns.example.com. hostmaster\\.awesome.example.com. (
22
- ;
23
- 2007120710 ; serial number of this zone file
24
- ;two
25
- ;comments
26
- 1d ; slave refresh (1 day)
27
- 1d ; slave retry time in case of a problem (1 day)
28
- 4W ; slave expiration time (4 weeks)
29
- 3600 ; minimum caching time in case of failed lookups (1 hour)
30
- )
31
- ; That's the SOA part done.
32
-
33
- ; Next comment line has nothing after the semi-colon.
34
- ;
35
-
36
- ; Let's start the resource records.
37
- example.com. NS ns ; ns.example.com is the nameserver for example.com
38
- example.com. NS ns.somewhere.com. ; ns.somewhere.com is a backup nameserver for example.com
39
- example.com. A 10.0.0.1 ; ip address for "example.com". next line has spaces after the IP, but no actual comment.
40
- @ A 10.0.0.11
41
- A 10.0.0.12 ; tertiary ip for "example.com"
42
- ns A 10.0.0.2 ; ip address for "ns.example.com"
43
- 60 A 10.0.0.21 ; secondary ip for "ns.example.com" with TTL
44
- * A 10.0.0.100 ; wildcard
45
- *.sub A 10.0.0.101 ; subdomain wildcard
46
- with-class IN A 10.0.0.3 ; record that includes the class type of IN
47
- with-ttl 60 A 10.0.0.5 ; with a specified TTL
48
- ttl-class 60 IN A 10.0.0.6 ; with TTL and class type
49
- www CNAME ns ; "www.example.com" is an alias for "ns.example.com"
50
- wwwtest CNAME www ; "wwwtest.example.com" is another alias for "www.example.com"
51
- www2 CNAME ns.example.com. ; yet another alias, with FQDN target
52
-
53
- ; Email... that'll be fun then
54
- example.com. MX 10 mail.example.com. ; mail.example.com is the mailserver for example.com
55
- @ MX 20 mail2.example.com. ; Similar to above line, but using "@" to say "use $ORIGIN"
56
- @ MX 50 mail3 ; Similar to above line, but using a host within this domain
57
-
58
- @ AAAA 2001:db8:a::1 ; IPv6, lowercase
59
- ns AAAA 2001:DB8:B::1 ; IPv6, uppercase
60
- mail AAAA 2001:db8:c::10.0.0.4 ; IPv6, with trailing IPv4-type address
61
-
62
- sip NAPTR 100 10 "U" "E2U+sip" "!^.*$!sip:cs@example.com!i" . ; NAPTR record
63
- sip2 NAPTR 100 10 "" "" "/urn:cid:.+@([^\\.]+\\.)(.*)$/\\2/i" . ; another one
64
-
65
- _xmpp-server._tcp SRV 5 0 5269 xmpp-server.l.google.com. ; SRV record
66
-
67
- ; TXT record, with embedded semicolons
68
- _domainkey TXT "v=DKIM1\\;g=*\\;k=rsa\\; p=4tkw1bbkfa0ahfjgnbewr2ttkvahvfmfizowl9s4g0h28io76ndow25snl9iumpcv0jwxr2k"
69
- with_ms_txt TXT ( "Some text" )
70
-
71
- @ TXT "some other \\"message\\" goes here" ; embedded quotes
72
- long TXT "a multi-segment TXT record" "usually used for really long TXT records" "since each segment can only span 255 chars"
73
- unquoted TXT some text data
74
-
75
- multiline TXT "A TXT record
76
- split across multiple lines
77
- with LF and CRLF line endings"
78
-
79
- ; Microsoft AD DNS Examples with Aging.
80
- with-age [AGE:999992222] 60 A 10.0.0.7 ; with a specified AGE
81
- with-age-aaaa [AGE:999992222] 60 AAAA 10.0.0.8 ; with a specified AGE
82
- _ldap._tcp.pupy._sites.dc._msdcs [AGE:3636525] 600 SRV 0 100 389 host01.ad
83
- P229392922 [AGE:3636449] 172800 CNAME printer01.ad
84
-
85
- @ SPF "v=spf1 a a:other.domain.com ~all"
86
-
87
- 45 IN PTR @
88
-
89
-
90
- eam 900 IN SRV 5 0 5269 www
91
- eam IN 900 SRV 5 0 5269 www
92
- eam IN SRV 5 0 5269 www
93
- eam 900 SRV 5 0 5269 www
94
- eam SRV 5 0 5269 www
95
-
96
- eam 900 IN CNAME www
97
- eam IN 900 CNAME www
98
- eam IN CNAME www
99
- eam 900 CNAME www
100
- eam CNAME www
101
-
102
- $ORIGIN test.example.com.
103
- $TTL 3600; expire in 1 day.
104
- @ A 10.1.0.1 ; Test with alternate origin
105
- MX 10 mail.example.com.
106
- www A 10.1.0.2 ; www.test.example.com.
107
-
108
- ZONE
109
- end
110
-
111
- it "should set the origin correctly" do
112
- zone = DNS::Zonefile.parse(@zonefile)
113
- expect(zone.origin).to eq('@')
114
- end
115
-
116
- it "should interpret the origin correctly" do
117
- zone = DNS::Zonefile.load(@zonefile)
118
- expect(zone.soa.origin).to eq('example.com.')
119
- end
120
-
121
- it "should set the zone variables correctly" do
122
- zone = DNS::Zonefile.parse(@zonefile)
123
- expect(zone.variables['TTL']).to eq('86400')
124
- expect(zone.variables['ORIGIN']).to eq('example.com.')
125
- end
126
-
127
- it "should interpret the SOA correctly" do
128
- zone = DNS::Zonefile.load(@zonefile)
129
- soa = zone.soa
130
- expect(soa.klass).to eq('IN')
131
- expect(soa.ttl).to eq(86400)
132
- expect(soa.nameserver).to eq('ns.example.com.')
133
- expect(soa.responsible_party).to eq('hostmaster\.awesome.example.com.')
134
- expect(soa.serial).to eq(2007120710)
135
- expect(soa.refresh_time).to eq(86400)
136
- expect(soa.retry_time).to eq(86400)
137
- expect(soa.expiry_time).to eq(2419200)
138
- expect(soa.nxttl).to eq(3600)
139
- end
140
-
141
- it "should build the correct number of resource records" do
142
- zone = DNS::Zonefile.parse(@zonefile)
143
- expect(zone.rr.size).to eq(49)
144
- end
145
-
146
- it "should build the correct NS records" do
147
- zone = DNS::Zonefile.load(@zonefile)
148
- ns_records = zone.records_of DNS::Zonefile::NS
149
- expect(ns_records.size).to eq(2)
150
-
151
- expect(ns_records.detect { |ns|
152
- ns.host == "example.com." && ns.nameserver == "ns.example.com."
153
- }).to_not be_nil
154
-
155
- expect(ns_records.detect { |ns|
156
- ns.host == "example.com." && ns.nameserver == "ns.somewhere.com." && ns.ttl == 86400
157
- }).to_not be_nil
158
- end
159
-
160
- it "should build the correct A records" do
161
- zone = DNS::Zonefile.load(@zonefile)
162
- a_records = zone.records_of DNS::Zonefile::A
163
- expect(a_records.size).to eq(13)
164
-
165
- expect(a_records.detect { |a|
166
- a.host == "example.com." && a.address == "10.0.0.1"
167
- }).to_not be_nil
168
-
169
- expect(a_records.detect { |a|
170
- a.host == "example.com." && a.address == "10.0.0.11"
171
- }).to_not be_nil
172
-
173
- expect(a_records.detect { |a|
174
- a.host == "example.com." && a.address == "10.0.0.12"
175
- }).to_not be_nil
176
-
177
- expect(a_records.detect { |a|
178
- a.host == "ns.example.com." && a.address == "10.0.0.2" && a.ttl == 86400
179
- }).to_not be_nil
180
-
181
- expect(a_records.detect { |a|
182
- a.host == "ns.example.com." && a.address == "10.0.0.21" && a.ttl == 60
183
- }).to_not be_nil
184
-
185
- expect(a_records.detect { |a|
186
- a.host == "*.example.com." && a.address == "10.0.0.100"
187
- }).to_not be_nil
188
-
189
- expect(a_records.detect { |a|
190
- a.host == "*.sub.example.com." && a.address == "10.0.0.101"
191
- }).to_not be_nil
192
-
193
- expect(a_records.detect { |a|
194
- a.host == "with-class.example.com." && a.address == "10.0.0.3" && a.ttl == 86400
195
- }).to_not be_nil
196
-
197
- expect(a_records.detect { |a|
198
- a.host == "with-ttl.example.com." && a.address == "10.0.0.5" && a.ttl == 60
199
- }).to_not be_nil
200
-
201
- expect(a_records.detect { |a|
202
- a.host == "with-age.example.com." && a.address == "10.0.0.7" && a.ttl == 60
203
- }).to_not be_nil
204
-
205
- expect(a_records.detect { |a|
206
- a.host == "ttl-class.example.com." && a.address == "10.0.0.6" && a.ttl == 60
207
- }).to_not be_nil
208
-
209
- expect(a_records.detect { |a|
210
- a.host == "test.example.com." && a.address == "10.1.0.1" && a.ttl == 3600
211
- }).to_not be_nil
212
-
213
- expect(a_records.detect { |a|
214
- a.host == "www.test.example.com." && a.address == "10.1.0.2" && a.ttl == 3600
215
- }).to_not be_nil
216
- end
217
-
218
- it "should build the correct CNAME records" do
219
- zone = DNS::Zonefile.load(@zonefile)
220
- cname_records = zone.records_of DNS::Zonefile::CNAME
221
- expect(cname_records.size).to eq(9)
222
-
223
- expect(cname_records.detect { |cname|
224
- cname.host == "www.example.com." && cname.target == "ns.example.com."
225
- }).to_not be_nil
226
-
227
- expect(cname_records.detect { |cname|
228
- cname.host == "wwwtest.example.com." && cname.domainname == "www.example.com."
229
- }).to_not be_nil
230
-
231
- expect(cname_records.detect { |cname|
232
- cname.host == "www2.example.com." && cname.domainname == "ns.example.com." && cname.ttl == 86400
233
- }).to_not be_nil
234
-
235
- expect(cname_records.detect { |cname|
236
- cname.host == "P229392922.example.com." && cname.domainname == "printer01.ad.example.com." && cname.ttl == 172800
237
- }).to_not be_nil
238
-
239
- eam_records = cname_records.select { |c| c.host =~ /eam\./ }
240
-
241
- expect(eam_records.length).to eq(5)
242
-
243
- eam_records.each { |cname|
244
- expect(cname.target).to eq("www.example.com.")
245
- }
246
-
247
- r = eam_records.group_by { |c| c.ttl }
248
- expect(r[900].length).to eq(3)
249
- expect(r[86400].length).to eq(2)
250
- end
251
-
252
- it "should build the correct MX records" do
253
- zone = DNS::Zonefile.load(@zonefile)
254
- mx_records = zone.records_of DNS::Zonefile::MX
255
- expect(mx_records.length).to eq(4)
256
-
257
- expect(mx_records.detect { |mx|
258
- mx.host == "example.com." && mx.priority == 10 && mx.exchanger == 'mail.example.com.'
259
- }).to_not be_nil
260
-
261
- expect(mx_records.detect { |mx|
262
- mx.host == "example.com." && mx.priority == 20 && mx.exchange == 'mail2.example.com.'
263
- }).to_not be_nil
264
-
265
- expect(mx_records.detect { |mx|
266
- mx.host == "example.com." && mx.priority == 50 && mx.domainname == 'mail3.example.com.' && mx.ttl == 86400
267
- }).to_not be_nil
268
-
269
- expect(mx_records.detect { |mx|
270
- mx.host == "test.example.com." && mx.priority == 10 && mx.domainname == 'mail.example.com.' && mx.ttl == 3600
271
- }).to_not be_nil
272
- end
273
-
274
- it "should build the correct AAAA records" do
275
- zone = DNS::Zonefile.load(@zonefile)
276
- aaaa_records = zone.records_of DNS::Zonefile::AAAA
277
- expect(aaaa_records.length).to eq(4)
278
-
279
- expect(aaaa_records.detect { |a|
280
- a.host == "example.com." && a.address == "2001:db8:a::1"
281
- }).to_not be_nil
282
-
283
- expect(aaaa_records.detect { |a|
284
- a.host == "ns.example.com." && a.address == "2001:db8:b::1"
285
- }).to_not be_nil
286
-
287
- expect(aaaa_records.detect { |a|
288
- a.host == "mail.example.com." && a.address == "2001:db8:c::10.0.0.4" && a.ttl == 86400
289
- }).to_not be_nil
290
-
291
- expect(aaaa_records.detect { |a|
292
- a.host == "with-age-aaaa.example.com." && a.address == "10.0.0.8" && a.ttl == 60
293
- }).to_not be_nil
294
-
295
- end
296
-
297
- it "should build the correct NAPTR records" do
298
- zone = DNS::Zonefile.load(@zonefile)
299
- naptr_records = zone.records_of DNS::Zonefile::NAPTR
300
- expect(naptr_records.length).to eq(2)
301
-
302
- expect(naptr_records.detect { |r|
303
- r.host == "sip.example.com." && r.data == '100 10 "U" "E2U+sip" "!^.*$!sip:cs@example.com!i" .'
304
- }).to_not be_nil
305
-
306
- expect(naptr_records.detect { |r|
307
- r.host == "sip2.example.com." && r.data == %q{100 10 "" "" "/urn:cid:.+@([^\\.]+\\.)(.*)$/\\2/i" .} && r.ttl == 86400
308
- }).to_not be_nil
309
- end
310
-
311
- it "should build the correct SRV records" do
312
- zone = DNS::Zonefile.load(@zonefile)
313
- srv_records = zone.records_of DNS::Zonefile::SRV
314
- expect(srv_records.length).to eq(7)
315
-
316
- expect(srv_records.detect { |r|
317
- r.host == "_xmpp-server._tcp.example.com." && r.priority == 5 && r.weight == 0 && r.port == 5269 && r.target == 'xmpp-server.l.google.com.' && r.ttl == 86400
318
- }).to_not be_nil
319
-
320
- expect(srv_records.detect { |r|
321
- r.host == "_ldap._tcp.pupy._sites.dc._msdcs.example.com." && r.priority == 0 && r.weight == 100 && r.port == 389 && r.target == 'host01.ad.example.com.' && r.ttl == 600
322
- }).to_not be_nil
323
-
324
- eam_records = srv_records.select { |s| s.host =~ /eam\./ }
325
- expect(eam_records.length).to eq(5)
326
- eam_records.each { |srv|
327
- expect(srv.target).to eq("www.example.com.")
328
- expect(srv.priority).to eq(5)
329
- expect(srv.port).to eq(5269)
330
- expect(srv.weight).to eq(0)
331
- }
332
-
333
- r = eam_records.group_by { |c| c.ttl }
334
- expect(r[900].length).to eq(3)
335
- expect(r[86400].length).to eq(2)
336
- end
337
-
338
- it "should build the correct TXT records" do
339
- zone = DNS::Zonefile.load(@zonefile)
340
- txt_records = zone.records_of DNS::Zonefile::TXT
341
- expect(txt_records.size).to eq(6)
342
-
343
- expect(txt_records.detect { |r|
344
- r.host == "_domainkey.example.com." && r.data == '"v=DKIM1\;g=*\;k=rsa\; p=4tkw1bbkfa0ahfjgnbewr2ttkvahvfmfizowl9s4g0h28io76ndow25snl9iumpcv0jwxr2k"'
345
- }).to_not be_nil
346
-
347
- expect(txt_records.detect { |r|
348
- r.host == "with_ms_txt.example.com." && r.data == '"Some text"'
349
- }).to_not be_nil
350
-
351
- expect(txt_records.detect { |r|
352
- r.host == "example.com." && r.data == '"some other \"message\" goes here"' && r.ttl == 86400
353
- }).to_not be_nil
354
-
355
- expect(txt_records.detect { |r|
356
- r.host == "long.example.com." && r.data == '"a multi-segment TXT record" "usually used for really long TXT records" "since each segment can only span 255 chars"'
357
- }).to_not be_nil
358
-
359
- expect(txt_records.detect { |r|
360
- r.host == "unquoted.example.com." && r.data == 'some text data'
361
- }).to_not be_nil
362
-
363
- expect(txt_records.detect { |r|
364
- r.host == "multiline.example.com." && r.data == "\"A TXT record\nsplit across multiple lines\nwith LF and CRLF line endings\""
365
- }).to_not be_nil
366
- end
367
-
368
- it "should build the correct SPF records" do
369
- zone = DNS::Zonefile.load(@zonefile)
370
- spf_records = zone.records_of DNS::Zonefile::SPF
371
- expect(spf_records.length).to eq(1)
372
-
373
- expect(spf_records.detect { |r|
374
- r.host == "example.com." && r.data == '"v=spf1 a a:other.domain.com ~all"' && r.ttl == 86400
375
- }).to_not be_nil
376
- end
377
-
378
- it "should build the correct PTR records" do
379
- zone = DNS::Zonefile.load(@zonefile)
380
- ptr_records = zone.records_of DNS::Zonefile::PTR
381
- expect(ptr_records.length).to eq(1)
382
-
383
- expect(ptr_records.detect { |r|
384
- r.host == "45.example.com." && r.target == 'example.com.' && r.ttl == 86400
385
- }).to_not be_nil
386
- end
387
- end
388
-
389
- describe "parsing an SOA without parens" do
390
- before(:each) do
391
- @zonefile =<<-ZONE
392
- example.com. 86400 IN SOA ns0.example.com. hostmaster.example.com. 2006010558 43200 3600 1209600 180
393
- example.com. 3600 IN A 1.2.3.4
394
- example.com. 86400 IN SOA ns0.example.com. hostmaster.example.com. 2006010558 43200 3600 1209600 180
395
-
396
- ZONE
397
- end
398
-
399
- it "should parse the SOA record correctly" do
400
- zone = DNS::Zonefile.load(@zonefile)
401
- soa = zone.soa
402
- expect(soa.klass).to eql('IN')
403
- expect(soa.ttl).to eql(86400)
404
- expect(soa.nameserver).to eql('ns0.example.com.')
405
- expect(soa.responsible_party).to eql('hostmaster.example.com.')
406
- expect(soa.serial).to eql(2006010558)
407
- expect(soa.refresh_time).to eql(43200)
408
- expect(soa.retry_time).to eql(3600)
409
- expect(soa.expiry_time).to eql(1209600)
410
- expect(soa.nxttl).to eql(180)
411
- end
412
- end
413
-
414
- describe "parsing an SOA with just . for responsible party" do
415
- before(:each) do
416
- @zonefile =<<-ZONE
417
- @ IN SOA ns.domain.example.com. . (
418
- 2007120710 ; serial number of this zone file
419
- 1d ; slave refresh (1 day)
420
- 1d ; slave retry time in case of a problem (1 day)
421
- 4W ; slave expiration time (4 weeks)
422
- 3600 ; minimum caching time in case of failed lookups (1 hour)
423
- )
424
- ZONE
425
- end
426
-
427
- it "should parse the SOA record correctly" do
428
- zone = DNS::Zonefile.load(@zonefile)
429
- soa = zone.soa
430
- expect(soa.klass).to eql('IN')
431
- expect(soa.nameserver).to eql('ns.domain.example.com.')
432
- expect(soa.responsible_party).to eql('.')
433
- end
434
- end
435
- end
@@ -1,2 +0,0 @@
1
- require 'rspec'
2
- require 'dns/zonefile'