smart_proxy_dns_infoblox 0.0.3 → 0.0.4

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: 7d7a93d41d181fc6748937bb4aa4f855b80438a8
4
- data.tar.gz: 66a8acdb1320e1f5aa412e2468b683553cb061fe
3
+ metadata.gz: f067a373f17dd6adba9aea33e3084c5e005d3b26
4
+ data.tar.gz: 6e19878e4ac1cd475a30da5a23632cf35e245ab6
5
5
  SHA512:
6
- metadata.gz: c6245b3a70f9295f6e40cc800e751167b7732cfa3b3e04c49c432e72d2ddf64b4e9336d62f346168bae8f83a4f098c4d6e1b48869e4c25406f44c91ce2653401
7
- data.tar.gz: dc19c4c51440d517e874333818dd3151be474726370739837b092bcc5daa5d83a52713dd4d97701390c253bc8dfa0ed26aba0a2c40c213880975bd26216b2b4e
6
+ metadata.gz: 0f67055c0fb692c6380c6bcda4b1f56c046d9b39c5c526f80622256b9e31a937efa3c5485b14f9589890e85a2d8322e8f9a52df0d0c09aefd623cba28f0cc410
7
+ data.tar.gz: 422837060375ce89e38fbedbf5f98ea48c515c21e2c961fb70d57a30391ea659bd9add9e3ab21eae78824dd0f189556ad08a974a4230241c716ee60edbf21efb
@@ -0,0 +1,8 @@
1
+ ---
2
+ #
3
+ # Configuration file for 'infoblox dns provider
4
+ #
5
+
6
+ :username: "infoblox"
7
+ :password: "infoblox"
8
+ :dns_server: "infoblox.my.domain"
@@ -1,3 +1,9 @@
1
- require 'smart_proxy_dns_infoblox/dns_infoblox_plugin'
1
+ module Proxy
2
+ module Dns
3
+ module Infoblox; end
4
+ end
5
+ end
2
6
 
3
- module Proxy::Dns::Infoblox; end
7
+ require 'smart_proxy_dns_infoblox/plugin_configuration'
8
+ require 'smart_proxy_dns_infoblox/dns_infoblox_version'
9
+ require 'smart_proxy_dns_infoblox/dns_infoblox_plugin'
@@ -1,57 +1,58 @@
1
- require 'dns/dns'
2
- require 'dns_common/dns_common'
3
- require 'infoblox'
4
1
  module Proxy::Dns::Infoblox
5
2
  class Record < ::Proxy::Dns::Record
6
- include Proxy::Log
7
- include Proxy::Util
3
+ attr_reader :connection
8
4
 
9
- attr_reader :example_setting, :optional_path, :required_setting, :required_path
10
-
11
- def initialize
5
+ def initialize(host, connection, ttl)
12
6
  ENV['WAPI_VERSION']='2.0'
13
- @infoblox_user = ::Proxy::Dns::Infoblox::Plugin.settings.infoblox_user
14
- @infoblox_pw = ::Proxy::Dns::Infoblox::Plugin.settings.infoblox_pw
15
- @infoblox_host = ::Proxy::Dns::Infoblox::Plugin.settings.infoblox_host
16
- @conn = ::Infoblox::Connection.new(username: @infoblox_user ,password: @infoblox_pw, host: @infoblox_host)
17
- super('localhost', ::Proxy::Dns::Plugin.settings.dns_ttl)
7
+ @connection = connection
8
+ super(host, ttl)
18
9
  end
19
10
 
20
- # Calls to these methods are guaranteed to have non-nil parameters
21
11
  def create_a_record(fqdn, ip)
22
- raise(Proxy::Dns::Collision, "#{fqdn} is already used by #{ip_in_use}") if dns_find(fqdn)
23
-
24
- a_record = Infoblox::Arecord.new(connection: @conn, name: fqdn, ipv4addr: ip)
25
- a_record.post
12
+ case a_record_conflicts(fqdn, ip) #returns -1, 0, 1
13
+ when 1
14
+ raise(Proxy::Dns::Collision, "'#{fqdn} 'is already in use")
15
+ when 0 then
16
+ return nil
17
+ else
18
+ do_create(Infoblox::Arecord, :connection => connection, :name => fqdn, :ipv4addr => ip)
19
+ end
26
20
  end
27
21
 
28
- def create_ptr_record(fqdn, ip)
29
- #ip here comes in as 2.1.168.192.in-addr.arpa, so we need to strip and reverse.
30
- raise(Proxy::Dns::Collision, "#{ip} is already used by #{fqdn_in_use}") if dns_find(ip)
31
- fixed_ip = ip.chomp('.in-addr.arpa').split('.').reverse .join('.')
32
- ptr_record = Infoblox::Ptr.new(connection: @conn, ptrdname: fqdn, ipv4addr: fixed_ip)
33
-
34
- ptr_record.post
22
+ def create_ptr_record(fqdn, ptr)
23
+ case ptr_record_conflicts(fqdn, ptr_to_ip(ptr)) #returns -1, 0, 1
24
+ when 1
25
+ raise(Proxy::Dns::Collision, "'#{fqdn} 'is already in use")
26
+ when 0 then
27
+ return nil
28
+ else
29
+ do_create(Infoblox::Ptr, :connection => connection, :ptrdname => fqdn, :ipv4addr => ptr_to_ip(ptr))
30
+ end
35
31
  # FIXME: add a reverse 'PTR' record with ip, fqdn
36
- # Raise an error if the IP is already in DNS but with a different FQDN:
37
- # raise(Proxy::Dns::Collision, "#{ip} is already used by #{fqdn_in_use}")
38
32
  end
39
33
 
40
34
  def remove_a_record(fqdn)
41
- a_record = Infoblox::Arecord.find( @conn, {name: fqdn}).first
42
- a_record.delete || raise(Proxy::Dns::NotFound.new("Cannot find DNS entry for #{fqdn}"))
35
+ do_delete(Infoblox::Arecord.find(connection, :name => fqdn, :_max_results => 1).first, fqdn)
43
36
  end
44
37
 
45
- def remove_ptr_record(ip)
46
- #ip here comes in as 2.1.168.192.in-addr.arpa, so we need to strip and reverse.
47
- fixed_ip = ip.chomp('.in-addr.arpa').split('.').reverse .join('.')
48
- ptr_record = Infoblox::Ptr.find(@conn, { ipv4addr: fixed_ip }).first
49
- ptr_record.ipv6addr=nil
50
- ptr_record.view=nil
51
- ptr_record.delete || raise(Proxy::Dns::NotFound.new("Cannot find DNS entry for #{ip}"))
38
+ def remove_ptr_record(ptr)
39
+ ptr_record = Infoblox::Ptr.find(connection, :ipv4addr => ptr_to_ip(ptr), :_max_results => 1).first
40
+ unless ptr_record.nil?
41
+ ptr_record.ipv6addr = nil
42
+ ptr_record.view = nil
43
+ end
44
+
45
+ do_delete(ptr_record, ptr)
52
46
  # FIXME: remove the reverse 'PTR' record with ip
53
- # Raise an error if the IP is not in DNS:
54
- # raise Proxy::Dns::NotFound.new("Cannot find DNS entry for #{ip}")
47
+ end
48
+
49
+ def do_create(clazz, params)
50
+ clazz.new(params).post
51
+ end
52
+
53
+ def do_delete(record, id)
54
+ raise Proxy::Dns::NotFound, "Cannot find DNS entry for #{id}" if record.nil?
55
+ record.delete || (raise Proxy::Dns::NotFound, "Cannot find DNS entry for #{id}")
55
56
  end
56
57
  end
57
58
  end
@@ -1,21 +1,12 @@
1
- require 'smart_proxy_dns_infoblox/dns_infoblox_version'
2
-
3
1
  module Proxy::Dns::Infoblox
4
2
  class Plugin < ::Proxy::Provider
5
- plugin :dns_infoblox, ::Proxy::Dns::Infoblox::VERSION, :factory => proc { |attrs| ::Proxy::Dns::Infoblox::Record.record(attrs) }
6
-
7
- # Settings listed under default_settings are required.
8
- # An exception will be raised if they are initialized with nil values.
9
- # Settings not listed under default_settings are considered optional and by default have nil value.
10
- default_settings :infoblox_user => 'infoblox', :infoblox_pw => 'infoblox', :infoblox_host => 'infoblox.my.domain'
3
+ plugin :dns_infoblox, ::Proxy::Dns::Infoblox::VERSION
11
4
 
12
- requires :dns, '>= 1.11'
5
+ default_settings :username => 'infoblox', :password => 'infoblox', :dns_server => 'infoblox.my.domain'
13
6
 
14
- #validate_presence :infoblox_user, :infoblox_pw, :infoblox_host
7
+ requires :dns, '>= 1.12'
15
8
 
16
- after_activation do
17
- require 'smart_proxy_dns_infoblox/dns_infoblox_main'
18
- require 'smart_proxy_dns_infoblox/dns_infoblox_dependencies'
19
- end
9
+ load_classes ::Proxy::Dns::Infoblox::PluginConfiguration
10
+ load_dependency_injection_wirings ::Proxy::Dns::Infoblox::PluginConfiguration
20
11
  end
21
12
  end
@@ -1,7 +1,7 @@
1
1
  module Proxy
2
2
  module Dns
3
3
  module Infoblox
4
- VERSION = '0.0.3'
4
+ VERSION = '0.0.4'
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,25 @@
1
+ module Proxy::Dns::Infoblox
2
+ class PluginConfiguration
3
+ def load_classes
4
+ require 'infoblox'
5
+ require 'dns_common/dns_common'
6
+ require 'smart_proxy_dns_infoblox/dns_infoblox_main'
7
+ end
8
+
9
+ def load_dependency_injection_wirings(container_instance, settings)
10
+ container_instance.dependency :connection,
11
+ (lambda do
12
+ ::Infoblox.wapi_version = '2.0'
13
+ ::Infoblox::Connection.new(:username => settings[:username],
14
+ :password => settings[:password],
15
+ :host => settings[:dns_server],
16
+ :ssl_opts => {:verify => false})
17
+ end)
18
+ container_instance.dependency :dns_provider,
19
+ lambda {::Proxy::Dns::Infoblox::Record.new(
20
+ settings[:dns_server],
21
+ container_instance.get_dependency(:connection),
22
+ settings[:dns_ttl]) }
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,28 @@
1
+ require 'test_helper'
2
+ require 'infoblox'
3
+ require 'smart_proxy_dns_infoblox/plugin_configuration'
4
+
5
+ class InfobloxProviderWiringTest < Test::Unit::TestCase
6
+ def setup
7
+ @container = ::Proxy::DependencyInjection::Container.new
8
+ @config = ::Proxy::Dns::Infoblox::PluginConfiguration.new
9
+ end
10
+
11
+ def test_connection_wiring
12
+ @config.load_dependency_injection_wirings(@container, :username => 'user', :password => 'password', :dns_server => 'a_host')
13
+ connection = @container.get_dependency(:connection)
14
+
15
+ assert_equal 'user', connection.username
16
+ assert_equal 'password', connection.password
17
+ assert_equal 'https://a_host', connection.host
18
+ assert_equal({:verify => false}, connection.ssl_opts)
19
+ end
20
+
21
+ def test_dns_provider_wiring
22
+ @config.load_dependency_injection_wirings(@container, :username => 'user', :password => 'password', :dns_server => 'a_host')
23
+ provider = @container.get_dependency(:dns_provider)
24
+
25
+ assert !provider.connection.nil?
26
+ assert_equal 'a_host', provider.server
27
+ end
28
+ end
@@ -0,0 +1,115 @@
1
+ require 'test_helper'
2
+ require 'dns_common/dns_common'
3
+ require 'infoblox'
4
+ require 'smart_proxy_dns_infoblox/dns_infoblox_main'
5
+
6
+
7
+ class InfobloxTest < Test::Unit::TestCase
8
+ class DummyRecord
9
+ attr_accessor :ipv6addr, :view
10
+ end
11
+
12
+ def setup
13
+ @connection = Object.new
14
+ @record = DummyRecord.new
15
+ @provider = Proxy::Dns::Infoblox::Record.new('a_host', @connection, 999)
16
+ end
17
+
18
+ def test_create_a
19
+ fqdn = 'test.example.com'
20
+ ip = '10.1.1.1'
21
+
22
+ @provider.expects(:a_record_conflicts).with(fqdn, ip).returns(-1)
23
+ @provider.expects(:do_create).with(Infoblox::Arecord, :connection => @connection, :name => fqdn, :ipv4addr => ip)
24
+
25
+ @provider.create_a_record(fqdn, ip)
26
+ end
27
+
28
+ def test_create_a_conflicting_record
29
+ fqdn = 'test.example.com'
30
+ ip = '10.1.1.1'
31
+
32
+ @provider.expects(:a_record_conflicts).with(fqdn, ip).returns(1)
33
+ assert_raises(Proxy::Dns::Collision) { @provider.create_a_record(fqdn, ip) }
34
+ end
35
+
36
+ def test_create_a_already_exists
37
+ fqdn = 'test.example.com'
38
+ ip = '10.1.1.1'
39
+
40
+ @provider.expects(:a_record_conflicts).with(fqdn, ip).returns(0)
41
+ assert_nil @provider.create_a_record(fqdn, ip)
42
+ end
43
+
44
+ def test_create_ptr
45
+ fqdn = 'test.example.com'
46
+ ptr = '1.1.1.10.in-addr.arpa'
47
+ ip = '10.1.1.1'
48
+
49
+ @provider.expects(:ptr_record_conflicts).with(fqdn, ip).returns(-1)
50
+ @provider.expects(:do_create).with(Infoblox::Ptr, :connection => @connection, :ptrdname => fqdn, :ipv4addr => ip)
51
+
52
+ @provider.create_ptr_record(fqdn, ptr)
53
+ end
54
+
55
+ def test_create_ptr_conflicting_record
56
+ fqdn = 'test.example.com'
57
+ ptr = '1.1.1.10.in-addr.arpa'
58
+ ip = '10.1.1.1'
59
+
60
+ @provider.expects(:ptr_record_conflicts).with(fqdn, ip).returns(1)
61
+ assert_raises(Proxy::Dns::Collision) { @provider.create_ptr_record(fqdn, ptr) }
62
+ end
63
+
64
+ def test_create_ptr_already_exists
65
+ fqdn = 'test.example.com'
66
+ ptr = '1.1.1.10.in-addr.arpa'
67
+ ip = '10.1.1.1'
68
+
69
+ @provider.expects(:ptr_record_conflicts).with(fqdn, ip).returns(0)
70
+ assert_nil @provider.create_ptr_record(fqdn, ptr)
71
+ end
72
+
73
+ def test_remove_a
74
+ fqdn = 'test.example.com'
75
+ Infoblox::Arecord.expects(:find).with(@connection, :name => fqdn, :_max_results => 1).returns([@record])
76
+ @record.expects(:delete).returns(true)
77
+ @provider.remove_a_record(fqdn)
78
+ end
79
+
80
+ def test_remove_a_not_found
81
+ fqdn = 'test.example.com'
82
+ Infoblox::Arecord.expects(:find).with(@connection, :name => fqdn, :_max_results => 1).returns([])
83
+ assert_raises(Proxy::Dns::NotFound) { @provider.remove_a_record(fqdn) }
84
+ end
85
+
86
+ def test_remove_a_returns_with_a_non_200_status
87
+ fqdn = 'test.example.com'
88
+ Infoblox::Arecord.expects(:find).with(@connection, :name => fqdn, :_max_results => 1).returns([@record])
89
+ @record.expects(:delete).returns(false)
90
+ assert_raises(Proxy::Dns::NotFound) { @provider.remove_a_record(fqdn) }
91
+ end
92
+
93
+ def test_remove_ptr
94
+ ptr = '1.1.1.10.in-addr.arpa'
95
+ ip = '10.1.1.1'
96
+ Infoblox::Ptr.expects(:find).with(@connection, :ipv4addr => ip, :_max_results => 1).returns([@record])
97
+ @record.expects(:delete).returns(true)
98
+ @provider.remove_ptr_record(ptr)
99
+ end
100
+
101
+ def test_remove_ptr_not_found
102
+ ptr = '1.1.1.10.in-addr.arpa'
103
+ ip = '10.1.1.1'
104
+ Infoblox::Ptr.expects(:find).with(@connection, :ipv4addr => ip, :_max_results => 1).returns([])
105
+ assert_raises(Proxy::Dns::NotFound) { @provider.remove_ptr_record(ptr) }
106
+ end
107
+
108
+ def test_remove_ptr_returns_with_a_non_200_status
109
+ ptr = '1.1.1.10.in-addr.arpa'
110
+ ip = '10.1.1.1'
111
+ Infoblox::Ptr.expects(:find).with(@connection, :ipv4addr => ip, :_max_results => 1).returns([@record])
112
+ @record.expects(:delete).returns(false)
113
+ assert_raises(Proxy::Dns::NotFound) { @provider.remove_ptr_record(ptr) }
114
+ end
115
+ end
metadata CHANGED
@@ -1,71 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_proxy_dns_infoblox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Nicholson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-04 00:00:00.000000000 Z
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: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: mocha
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: test-unit
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
11
+ date: 2016-09-08 00:00:00.000000000 Z
12
+ dependencies: []
69
13
  description: Infoblox DNS provider plugin for Foreman's smart proxy
70
14
  email:
71
15
  - matthew.a.nicholson@gmail.com
@@ -76,13 +20,14 @@ files:
76
20
  - LICENSE
77
21
  - README.md
78
22
  - bundler.d/dns_infoblox.rb
79
- - config/dns_infoblox.yml
23
+ - config/dns_infoblox.yml.example
80
24
  - lib/smart_proxy_dns_infoblox.rb
81
- - lib/smart_proxy_dns_infoblox/dns_infoblox_dependencies.rb
82
25
  - lib/smart_proxy_dns_infoblox/dns_infoblox_main.rb
83
26
  - lib/smart_proxy_dns_infoblox/dns_infoblox_plugin.rb
84
27
  - lib/smart_proxy_dns_infoblox/dns_infoblox_version.rb
85
- - test/dns_infoblox_record_test.rb
28
+ - lib/smart_proxy_dns_infoblox/plugin_configuration.rb
29
+ - test/configuration_test.rb
30
+ - test/infoblox_test.rb
86
31
  - test/test_helper.rb
87
32
  homepage: https://github.com/sjoeboo/smart_proxy_dns_infoblox
88
33
  licenses:
@@ -104,10 +49,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
49
  version: '0'
105
50
  requirements: []
106
51
  rubyforge_project:
107
- rubygems_version: 2.4.6
52
+ rubygems_version: 2.2.2
108
53
  signing_key:
109
54
  specification_version: 4
110
55
  summary: Infoblox DNS provider plugin for Foreman's smart proxy
111
56
  test_files:
112
- - test/dns_infoblox_record_test.rb
57
+ - test/configuration_test.rb
58
+ - test/infoblox_test.rb
113
59
  - test/test_helper.rb
@@ -1,8 +0,0 @@
1
- ---
2
- #
3
- # Configuration file for 'infoblox dns provider
4
- #
5
-
6
- :infoblox_user: "infoblox"
7
- :infoblox_pw: "infoblox"
8
- infoblox_host: "infoblox.my.domain"
@@ -1,5 +0,0 @@
1
- require 'dns_common/dependency_injection/dependencies'
2
-
3
- class Proxy::Dns::DependencyInjection::Dependencies
4
- dependency :dns_provider, Proxy::Dns::Infoblox::Record
5
- end
@@ -1,95 +0,0 @@
1
- require 'test_helper'
2
- require 'dns/dns_plugin'
3
- require 'smart_proxy_dns_infoblox/dns_infoblox_plugin'
4
- require 'smart_proxy_dns_infoblox/dns_infoblox_main'
5
-
6
-
7
- class DnsInfobloxRecordTest < Test::Unit::TestCase
8
-
9
- def test_default_settings
10
- Proxy::Dns::Infoblox::Plugin.load_test_settings({})
11
- assert_equal "default_value", Proxy::Dns::Nsupdate::Plugin.settings.required_setting
12
- assert_equal "/must/exist", Proxy::Dns::Nsupdate::Plugin.settings.required_path
13
- end
14
-
15
- def test_initialized_correctly
16
- Proxy::Dns::Infoblox::Plugin.load_test_settings(:example_setting => 'a_value',
17
- :required_setting => 'required_setting',
18
- :optional_path => '/some/path',
19
- :required_path => '/required/path')
20
-
21
- assert_equal 'a_value', klass.new.example_setting
22
- assert_equal 'required_value', klass.new.required_setting
23
- assert_equal '/some/path', klass.new.optional_path
24
- assert_equal '/required/path', klass.new.required_path
25
- end
26
-
27
- # Test that a missing :example_setting throws an error
28
- # Test A record creation
29
- def test_create_a
30
- # Use mocha to expect any calls to backend services to prevent creating real records
31
- # MyService.expects(:create).with(:ip => '10.1.1.1', :name => 'test.example.com').returns(true)
32
-
33
- assert klass.new.create_a_record('test.example.com', '10.1.1.1')
34
- end
35
-
36
- # Test A record creation fails if the record exists
37
- def test_create_a_conflict
38
- # Use mocha to expect any calls to backend services to prevent creating real records
39
- # MyService.expects(:create).with(:ip => '10.1.1.1', :name => 'test.example.com').returns(false)
40
-
41
- assert_raise(Proxy::Dns::Collision) { klass.new.create_a_record('test.example.com', '10.1.1.1') }
42
- end
43
-
44
- # Test PTR record creation
45
- def test_create_ptr
46
- # Use mocha to expect any calls to backend services to prevent creating real records
47
- # MyService.expects(:create_reverse).with(:ip => '10.1.1.1', :name => 'test.example.com').returns(true)
48
-
49
- assert klass.new.create_ptr_record('test.example.com', '10.1.1.1')
50
- end
51
-
52
- # Test PTR record creation fails if the record exists
53
- def test_create_ptr_conflict
54
- # Use mocha to expect any calls to backend services to prevent creating real records
55
- # MyService.expects(:create_reverse).with(:ip => '10.1.1.1', :name => 'test.example.com').returns(false)
56
-
57
- assert_raise(Proxy::Dns::Collision) { klass.new.create_ptr_record('test.example.com', '10.1.1.1') }
58
- end
59
-
60
- # Test A record removal
61
- def test_remove_a
62
- # Use mocha to expect any calls to backend services to prevent deleting real records
63
- # MyService.expects(:delete).with(:name => 'test.example.com').returns(true)
64
-
65
- assert klass.new.remove_a_record('test.example.com')
66
- end
67
-
68
- # Test A record removal fails if the record doesn't exist
69
- def test_remove_a_not_found
70
- # Use mocha to expect any calls to backend services to prevent deleting real records
71
- # MyService.expects(:delete).with(:name => 'test.example.com').returns(false)
72
-
73
- assert_raise(Proxy::Dns::NotFound) { assert klass.new.remove_a_record('test.example.com') }
74
- end
75
-
76
- # Test PTR record removal
77
- def test_remove_ptr
78
- # Use mocha to expect any calls to backend services to prevent deleting real records
79
- # MyService.expects(:delete).with(:ip => '10.1.1.1').returns(true)
80
-
81
- assert klass.new.remove_ptr_record('1.1.1.10.in-addr.arpa')
82
- end
83
-
84
- # Test PTR record removal fails if the record doesn't exist
85
- def test_remove_ptr_not_found
86
- # Use mocha to expect any calls to backend services to prevent deleting real records
87
- # MyService.expects(:delete).with(:ip => '10.1.1.1').returns(false)
88
-
89
- assert_raise(Proxy::Dns::NotFound) { assert klass.new.remove_ptr_record('1.1.1.10.in-addr.arpa') }
90
- end
91
-
92
- def klass
93
- Proxy::Dns::Infoblox::Record
94
- end
95
- end