bind9mgr 0.3.8 → 0.3.9
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.
- data/History.txt +7 -0
- data/lib/bind9mgr.rb +1 -1
- data/lib/resource_record.rb +13 -6
- data/lib/zone.rb +5 -0
- data/spec/zone_spec.rb +35 -18
- metadata +3 -3
data/History.txt
CHANGED
data/lib/bind9mgr.rb
CHANGED
data/lib/resource_record.rb
CHANGED
@@ -17,6 +17,7 @@ module Bind9mgr
|
|
17
17
|
def valid?
|
18
18
|
@errors = []
|
19
19
|
(@errors << "Base type_and_rdata_shouldnt_be_blank"; return false) unless @type && @rdata
|
20
|
+
(@errors << "Rdata rdata_shouldnt_be_blank_string"; return false) if @rdata.kind_of?(String) && @rdata.length < 1
|
20
21
|
(@errors << "Owner invalid") if @owner && ( !@owner.kind_of?(String) || (@owner.match(/^\d+$/)) || (@owner == 'localhost') )
|
21
22
|
(@errors << "Class invalid") if !klass.nil? && !KLASSES.include?( klass )
|
22
23
|
(@errors << "Type not_supported") unless ALLOWED_TYPES.include?( type )
|
@@ -29,22 +30,28 @@ module Bind9mgr
|
|
29
30
|
end
|
30
31
|
|
31
32
|
def validate_soa
|
32
|
-
(@errors << "Rdata should_be_an_array"; return false)
|
33
|
-
(@errors << "Rdata should_have_7_elements"; return false)
|
33
|
+
(@errors << "Rdata should_be_an_array"; return false) unless @rdata.kind_of? Array
|
34
|
+
(@errors << "Rdata should_have_7_elements"; return false) unless @rdata.size == 7
|
34
35
|
(@errors << "Base a record validation is under construction") unless @rdata[0].match(/\.$/)
|
35
36
|
end
|
36
37
|
|
37
38
|
def validate_a
|
38
|
-
(@errors << "Rdata should_be_a_string"; return false)
|
39
|
-
(@errors << "Rdata should_not_be_blank"; return false) if @rdata.length < 1
|
39
|
+
(@errors << "Rdata should_be_a_string"; return false) unless @rdata.kind_of? String
|
40
|
+
(@errors << "Rdata should_not_be_blank"; return false) if @rdata.length < 1 # TODO DRY it
|
40
41
|
end
|
41
42
|
|
42
43
|
def validate_cname
|
43
|
-
|
44
|
+
(@errors << "owner should_be_a_string"; return false) unless @owner.kind_of? String
|
45
|
+
(@errors << "owner should_not_contain_only_digits"; return false) if @owner.match(/^\d+$/)
|
44
46
|
end
|
45
47
|
|
46
48
|
def validate_mx
|
47
|
-
|
49
|
+
(@errors << "Rdata should_be_an_array"; return false) unless @rdata.kind_of? Array
|
50
|
+
(@errors << "Rdata should_contain_priority"; return false) unless @rdata[0].to_s.match(/^\d+$/) # TODO how about integer value
|
51
|
+
(@errors << "Rdata target_should_not_contain_only_digits"; return false) if @rdata[1].match(/^\d+$/)
|
52
|
+
end
|
53
|
+
|
54
|
+
def validate_txt
|
48
55
|
end
|
49
56
|
|
50
57
|
##
|
data/lib/zone.rb
CHANGED
data/spec/zone_spec.rb
CHANGED
@@ -47,27 +47,44 @@ alias1 IN CNAME ns
|
|
47
47
|
end
|
48
48
|
pending "should generate zone entry content"
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
50
|
+
describe "records creation & validation" do
|
51
|
+
subject do
|
52
|
+
Bind9mgr::Zone.new( 'example.com', 'example.com.db',
|
53
|
+
{ :main_ns => '192.168.1.1',
|
54
|
+
:secondary_ns => '192.168.1.2',
|
55
|
+
:main_server_ip => '192.168.1.3',
|
56
|
+
:support_email => 'qwe@qwe.ru'
|
57
|
+
})
|
58
|
+
end
|
58
59
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
60
|
+
it "should add default rrs before generate db content" do
|
61
|
+
subject.gen_db_content
|
62
|
+
subject.records.size.should > 0
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should add dot to zone name on creation unless there is no one" do
|
66
|
+
subject.origin.should eql('example.com.')
|
67
|
+
subject.name.should eql('example.com')
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should not be valid without records" do
|
71
|
+
subject.should_not be_valid
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should pass when there are default records and some valid ones" do
|
75
|
+
subject.add_default_rrs
|
76
|
+
subject.add_rr( 'qwe', nil, nil, 'CNAME', '@' )
|
77
|
+
subject.should be_valid
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should not be valid with wrong records" do
|
81
|
+
subject.add_default_rrs
|
82
|
+
subject.add_rr( 'qwe', nil, nil, 'CNAME', '' )
|
83
|
+
subject.should_not be_valid
|
84
|
+
end
|
68
85
|
end
|
69
86
|
|
70
|
-
|
87
|
+
pending "should raise error when undefined rr target added" do
|
71
88
|
# examples
|
72
89
|
# 1:
|
73
90
|
# @ NS ns.example.com # here is no dot at the end of line -> error!
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bind9mgr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-10-15 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hoe
|
16
|
-
requirement: &
|
16
|
+
requirement: &24673600 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '2.12'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *24673600
|
25
25
|
description: This gem contains some classes to manage bind9 zone files
|
26
26
|
email:
|
27
27
|
- mikhail@mad-box.ru
|