mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 07:04:47 +02:00
Ensure that Whois record is updated/destroyed when actions performed on Zone objects
This commit is contained in:
parent
7e640a376e
commit
55de10a53d
4 changed files with 36 additions and 1 deletions
|
@ -75,6 +75,7 @@ class UpdateWhoisRecordJob < Que::Job
|
||||||
|
|
||||||
def delete_zone(name)
|
def delete_zone(name)
|
||||||
WhoisRecord.where(name: name).destroy_all
|
WhoisRecord.where(name: name).destroy_all
|
||||||
|
Whois::Record.where(name: name).destroy_all
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_status_from_whois(domain_name:, domain_status:)
|
def remove_status_from_whois(domain_name:, domain_status:)
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Concerns
|
||||||
|
|
||||||
included do
|
included do
|
||||||
after_save :update_whois_record, if: :subzone?
|
after_save :update_whois_record, if: :subzone?
|
||||||
after_destroy :update_whois_record, if: :subzone?
|
after_destroy :update_whois_record
|
||||||
end
|
end
|
||||||
|
|
||||||
def subzone?
|
def subzone?
|
||||||
|
|
9
test/fixtures/dns/zones.yml
vendored
9
test/fixtures/dns/zones.yml
vendored
|
@ -9,3 +9,12 @@ one:
|
||||||
minimum_ttl: 1
|
minimum_ttl: 1
|
||||||
email: admin@registry.test
|
email: admin@registry.test
|
||||||
master_nameserver: ns.test
|
master_nameserver: ns.test
|
||||||
|
subzone:
|
||||||
|
origin: 'sub.zone'
|
||||||
|
ttl: 1
|
||||||
|
refresh: 1
|
||||||
|
retry: 1
|
||||||
|
expire: 1
|
||||||
|
minimum_ttl: 1
|
||||||
|
email: admin@registry.test
|
||||||
|
master_nameserver: ns.test
|
||||||
|
|
|
@ -124,6 +124,31 @@ class DNS::ZoneTest < ActiveSupport::TestCase
|
||||||
assert zone.invalid?
|
assert zone.invalid?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_determines_if_subzone
|
||||||
|
zone = valid_zone
|
||||||
|
zone.update(origin: 'pri.ee')
|
||||||
|
assert zone.subzone?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_updates_whois_after_update
|
||||||
|
subzone = dns_zones(:subzone)
|
||||||
|
assert_nil Whois::Record.find_by(name: subzone.origin)
|
||||||
|
|
||||||
|
subzone.update(expire: 42)
|
||||||
|
|
||||||
|
whois_record = Whois::Record.find_by(name: subzone.origin)
|
||||||
|
assert whois_record.present?
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_deletes_whois_record_after_destroy
|
||||||
|
subzone = dns_zones(:subzone)
|
||||||
|
subzone.update(expire: 42)
|
||||||
|
assert Whois::Record.find_by(name: subzone.origin).present?
|
||||||
|
|
||||||
|
subzone.destroy
|
||||||
|
assert_nil Whois::Record.find_by(name: subzone.origin)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def valid_zone
|
def valid_zone
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue