smart_proxy_dns_infoblox 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -2
- data/lib/smart_proxy_dns_infoblox/dns_infoblox_main.rb +25 -4
- data/lib/smart_proxy_dns_infoblox/dns_infoblox_version.rb +1 -1
- data/test/infoblox_test.rb +19 -8
- data/test/integration_test.rb +10 -2
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8897b410d2961cdad8b275971188063eee2f43eb36d887acf3bb7b51acc4749
|
4
|
+
data.tar.gz: ab1c93e8b44f9e9583037d9e9ad770a667d81c56371148219f41b0b52e097119
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eabe002514aeb1a4519ed1efccebf8f9ba6e28e5b5d474611d81cc9dcc0b57145554d75f3d3f6503d4448765dbd616f2bcfa1a0f6421de75f99e94de08c12254
|
7
|
+
data.tar.gz: 88aed8b900b4db24e55e5230be6afdc53a819ec87030cd49449f334c307531a9c4535e742bcad3667c10a063719e8f974a268144b6fb7f1af090591298d55855
|
data/README.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# SmartProxyDnsInfoblox
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/theforeman/smart_proxy_dns_infoblox.svg?branch=master)](https://travis-ci.org/theforeman/smart_proxy_dns_infoblox)
|
4
|
-
|
5
3
|
This plugin adds a new DNS provider for managing records in MyService.
|
6
4
|
|
7
5
|
## Installation
|
@@ -24,7 +24,12 @@ module Proxy::Dns::Infoblox
|
|
24
24
|
# 0 = already exists and do nothing
|
25
25
|
# 1 = conflict and error out
|
26
26
|
def record_conflicts_ip(fqdn, type, address)
|
27
|
-
|
27
|
+
if type == Resolv::DNS::Resource::IN::PTR
|
28
|
+
ip = IPAddr.new(ptr_to_ip(address))
|
29
|
+
method = "ib_find_#{type.name.split('::').last.downcase}#{ip.ipv4? ? 4 : 6}_record".to_sym
|
30
|
+
else
|
31
|
+
method = "ib_find_#{type.name.split('::').last.downcase}_record".to_sym
|
32
|
+
end
|
28
33
|
raise(Proxy::Dns::Error, "Finding of #{type} records not implemented") unless respond_to?(method, true)
|
29
34
|
|
30
35
|
return -1 if send(method, fqdn).empty?
|
@@ -62,15 +67,31 @@ module Proxy::Dns::Infoblox
|
|
62
67
|
Infoblox::AAAArecord.find(connection, params)
|
63
68
|
end
|
64
69
|
|
65
|
-
def
|
70
|
+
def ib_find_ptr4_record(fqdn, ptr = nil)
|
71
|
+
params = {
|
72
|
+
:_max_results => 1,
|
73
|
+
:view => dns_view,
|
74
|
+
:ptrdname => fqdn,
|
75
|
+
:'name~' => 'in-addr\.arpa$'
|
76
|
+
}
|
77
|
+
if ptr
|
78
|
+
ip = IPAddr.new(ptr_to_ip(ptr))
|
79
|
+
params[:ipv4addr] = ip.to_s
|
80
|
+
params[:name] = ptr
|
81
|
+
end
|
82
|
+
Infoblox::Ptr.find(connection, params)
|
83
|
+
end
|
84
|
+
|
85
|
+
def ib_find_ptr6_record(fqdn, ptr = nil)
|
66
86
|
params = {
|
67
87
|
:_max_results => 1,
|
68
88
|
:view => dns_view,
|
69
|
-
:ptrdname => fqdn
|
89
|
+
:ptrdname => fqdn,
|
90
|
+
:'name~' => 'ip6\.arpa$'
|
70
91
|
}
|
71
92
|
if ptr
|
72
93
|
ip = IPAddr.new(ptr_to_ip(ptr))
|
73
|
-
params[
|
94
|
+
params[:ipv6addr] = ip.to_s
|
74
95
|
params[:name] = ptr
|
75
96
|
end
|
76
97
|
Infoblox::Ptr.find(connection, params)
|
data/test/infoblox_test.rb
CHANGED
@@ -48,20 +48,31 @@ class InfobloxTest < Test::Unit::TestCase
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def test_conflict_ptr_ok
|
51
|
-
@provider.expects(:
|
52
|
-
assert_equal(-1, @provider.
|
51
|
+
@provider.expects(:ib_find_ptr4_record).with("test.example.com").returns([])
|
52
|
+
assert_equal(-1, @provider.record_conflicts_name("13.202.168.192.in-addr.arpa", Resolv::DNS::Resource::IN::PTR, "test.example.com"))
|
53
|
+
|
54
|
+
@provider.expects(:ib_find_ptr6_record).with("test.example.com").returns([])
|
55
|
+
assert_equal(-1, @provider.record_conflicts_name("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa", Resolv::DNS::Resource::IN::PTR, "test.example.com"))
|
53
56
|
end
|
54
57
|
|
55
58
|
def test_conflict_ptr_already_exists
|
56
|
-
@provider.expects(:
|
57
|
-
@provider.expects(:
|
58
|
-
assert_equal(0, @provider.
|
59
|
+
@provider.expects(:ib_find_ptr4_record).with("test.example.com").returns([true])
|
60
|
+
@provider.expects(:ib_find_ptr4_record).with("test.example.com", "13.202.168.192.in-addr.arpa").returns([true])
|
61
|
+
assert_equal(0, @provider.record_conflicts_name("13.202.168.192.in-addr.arpa", Resolv::DNS::Resource::IN::PTR, "test.example.com"))
|
62
|
+
|
63
|
+
@provider.expects(:ib_find_ptr6_record).with("test.example.com").returns([true])
|
64
|
+
@provider.expects(:ib_find_ptr6_record).with("test.example.com", "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa").returns([true])
|
65
|
+
assert_equal(0, @provider.record_conflicts_name("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa", Resolv::DNS::Resource::IN::PTR, "test.example.com"))
|
59
66
|
end
|
60
67
|
|
61
68
|
def test_conflict_ptr_conflict
|
62
|
-
@provider.expects(:
|
63
|
-
@provider.expects(:
|
64
|
-
assert_equal(1, @provider.
|
69
|
+
@provider.expects(:ib_find_ptr4_record).with("test.example.com").returns([false])
|
70
|
+
@provider.expects(:ib_find_ptr4_record).with("test.example.com", "13.202.168.192.in-addr.arpa").returns([false])
|
71
|
+
assert_equal(1, @provider.record_conflicts_name("13.202.168.192.in-addr.arpa", Resolv::DNS::Resource::IN::PTR, "test.example.com"))
|
72
|
+
|
73
|
+
@provider.expects(:ib_find_ptr6_record).with("test.example.com").returns([false])
|
74
|
+
@provider.expects(:ib_find_ptr6_record).with("test.example.com", "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa").returns([false])
|
75
|
+
assert_equal(1, @provider.record_conflicts_name("1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa", Resolv::DNS::Resource::IN::PTR, "test.example.com"))
|
65
76
|
end
|
66
77
|
|
67
78
|
def test_conflict_cname_ok
|
data/test/integration_test.rb
CHANGED
@@ -41,12 +41,20 @@ class IntegrationTest < ::Test::Unit::TestCase
|
|
41
41
|
assert last_response.ok?, "Last response was not ok: #{last_response.status} #{last_response.body}"
|
42
42
|
end
|
43
43
|
|
44
|
-
def
|
45
|
-
@server.expects(:
|
44
|
+
def test_create_ptr4_record
|
45
|
+
@server.expects(:ib_find_ptr4_record).with('test.com').returns([])
|
46
|
+
@server.expects(:ib_create_ptr_record).with('33.33.168.192.in-addr.arpa', 'test.com')
|
46
47
|
post '/', :fqdn => 'test.com', :value => '33.33.168.192.in-addr.arpa', :type => 'PTR'
|
47
48
|
assert last_response.ok?, "Last response was not ok: #{last_response.status} #{last_response.body}"
|
48
49
|
end
|
49
50
|
|
51
|
+
def test_create_ptr6_record
|
52
|
+
@server.expects(:ib_find_ptr6_record).with('test.com').returns([])
|
53
|
+
@server.expects(:ib_create_ptr_record).with('1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa', 'test.com')
|
54
|
+
post '/', :fqdn => 'test.com', :value => '1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa', :type => 'PTR'
|
55
|
+
assert last_response.ok?, "Last response was not ok: #{last_response.status} #{last_response.body}"
|
56
|
+
end
|
57
|
+
|
50
58
|
def test_delete_a_record
|
51
59
|
@server.expects(:remove_a_record).with("test.com")
|
52
60
|
delete '/test.com'
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_proxy_dns_infoblox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Nicholson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: infoblox
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rubocop
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|