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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0cd133f133a42e4d8bb583d7566d3ef78caaf9f088a95f589c950f5abc73d99
4
- data.tar.gz: b6a90cd39ac38ff25d40c557a4f615b6d4339a3841015157dfb99525890d7973
3
+ metadata.gz: a8897b410d2961cdad8b275971188063eee2f43eb36d887acf3bb7b51acc4749
4
+ data.tar.gz: ab1c93e8b44f9e9583037d9e9ad770a667d81c56371148219f41b0b52e097119
5
5
  SHA512:
6
- metadata.gz: de50121fbebd43ca08d483bd1332988e7c2ab6b4659d7605b16de613ac6cbbd6b1190c680b449cc4c11073187d148c4cfe32818a9a2b2a1fa7d48a0137a574a8
7
- data.tar.gz: 63865b57418f08551a82af80ff526c62b3c78ba364bfe9136d9f0dc8bea8e7489aa23fc3d6af80c596940609ac09ec25f58e66a3a2b75352e771e5854f170a12
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
- method = "ib_find_#{type.name.split('::').last.downcase}_record".to_sym
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 ib_find_ptr_record(fqdn, ptr = nil)
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["ipv#{ip.ipv4? ? 4 : 6}addr".to_sym] = ip.to_s
94
+ params[:ipv6addr] = ip.to_s
74
95
  params[:name] = ptr
75
96
  end
76
97
  Infoblox::Ptr.find(connection, params)
@@ -1,7 +1,7 @@
1
1
  module Proxy
2
2
  module Dns
3
3
  module Infoblox
4
- VERSION = '1.0.0'.freeze
4
+ VERSION = '1.1.0'.freeze
5
5
  end
6
6
  end
7
7
  end
@@ -48,20 +48,31 @@ class InfobloxTest < Test::Unit::TestCase
48
48
  end
49
49
 
50
50
  def test_conflict_ptr_ok
51
- @provider.expects(:ib_find_ptr_record).with("13.202.168.192.in-addr.arpa").returns([])
52
- assert_equal(-1, @provider.record_conflicts_ip("13.202.168.192.in-addr.arpa", Resolv::DNS::Resource::IN::PTR, "test.example.com"))
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(:ib_find_ptr_record).with("13.202.168.192.in-addr.arpa").returns([true])
57
- @provider.expects(:ib_find_ptr_record).with("13.202.168.192.in-addr.arpa", "test.example.com").returns([true])
58
- assert_equal(0, @provider.record_conflicts_ip("13.202.168.192.in-addr.arpa", Resolv::DNS::Resource::IN::PTR, "test.example.com"))
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(:ib_find_ptr_record).with("13.202.168.192.in-addr.arpa").returns([false])
63
- @provider.expects(:ib_find_ptr_record).with("13.202.168.192.in-addr.arpa", "test.example.com").returns([false])
64
- assert_equal(1, @provider.record_conflicts_ip("13.202.168.192.in-addr.arpa", Resolv::DNS::Resource::IN::PTR, "test.example.com"))
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
@@ -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 test_create_ptr_record
45
- @server.expects(:create_ptr_record).with("test.com", "33.33.168.192.in-addr.arpa")
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.0.0
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: 2019-07-25 00:00:00.000000000 Z
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