Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions app/interactions/actions/domain_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def call
# domain.attach_default_contacts
assign_expiry_time
maybe_attach_legal_doc
validate_ns_records
validate_dns_records

commit
end
Expand Down Expand Up @@ -181,6 +183,24 @@ def maybe_attach_legal_doc
::Actions::BaseAction.attach_legal_doc_to_new(domain, params[:legal_document], domain: true)
end

def validate_ns_records
return unless domain.nameservers.any?

result = DNSValidator.validate(domain: domain, name: domain.name, record_type: 'NS')
return if result[:errors].blank?

assign_dns_validation_error(result[:errors])
end

def validate_dns_records
return unless domain.dnskeys.any?

result = DNSValidator.validate(domain: domain, name: domain.name, record_type: 'DNSKEY')
return if result[:errors].blank?

assign_dns_validation_error(result[:errors])
end

def process_auction_and_disputes
dn = DNS::DomainName.new(domain.name)
Dispute.close_by_domain(domain.name)
Expand All @@ -200,6 +220,12 @@ def commit
domain.save
end

def assign_dns_validation_error(errors)
errors.each do |error|
domain.add_epp_error('2306', nil, nil, error)
end
end

def validation_process_errored?
return if domain.valid?

Expand Down
29 changes: 28 additions & 1 deletion app/interactions/actions/domain_transfer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ def call
# return domain.pending_transfer if domain.pending_transfer
# attach_legal_document(::Deserializers::Xml::LegalDocument.new(frame).call)

return if domain.errors[:epp_errors].any?
return false if domain.errors[:epp_errors].any?

commit
true
end

def domain_exists?
Expand All @@ -34,6 +35,8 @@ def run_validations
validate_registrar
validate_eligilibty
validate_not_discarded
validate_ns_records
validate_dns_records
end

def valid_transfer_code?
Expand Down Expand Up @@ -62,6 +65,30 @@ def validate_not_discarded
domain.add_epp_error('2106', nil, nil, 'Object is not eligible for transfer')
end

def validate_ns_records
return unless domain.nameservers.any?

result = DNSValidator.validate(domain: domain, name: domain.name, record_type: 'NS')
return if result[:errors].blank?

assign_dns_validation_error(result[:errors])
end

def validate_dns_records
return unless domain.dnskeys.any?

result = DNSValidator.validate(domain: domain, name: domain.name, record_type: 'DNSKEY')
return if result[:errors].blank?

assign_dns_validation_error(result[:errors])
end

def assign_dns_validation_error(errors)
errors.each do |error|
domain.add_epp_error('2306', nil, nil, error)
end
end

def commit
bare_domain = Domain.find(domain.id)
::DomainTransfer.request(bare_domain, user)
Expand Down
26 changes: 26 additions & 0 deletions app/interactions/actions/domain_update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def call
validate_domain_integrity
assign_new_registrant if params[:registrant]
assign_relational_modifications
validate_ns_records
validate_dns_records
assign_requested_statuses

::Actions::BaseAction.maybe_attach_legal_doc(domain, params[:legal_document])
Expand Down Expand Up @@ -97,6 +99,30 @@ def validate_ns_integrity(ns_attr)
end
end

def validate_ns_records
return unless domain.nameservers.any?

result = DNSValidator.validate(domain: domain, name: domain.name, record_type: 'NS')
return if result[:errors].blank?

assign_dns_validation_error(result[:errors])
end

def validate_dns_records
return unless domain.dnskeys.any?

result = DNSValidator.validate(domain: domain, name: domain.name, record_type: 'DNSKEY')
return if result[:errors].blank?

assign_dns_validation_error(result[:errors])
end

def assign_dns_validation_error(errors)
errors.each do |error|
domain.add_epp_error('2306', nil, nil, error)
end
end

def assign_dnssec_modifications
@dnskeys = []
params[:dns_keys].each do |key|
Expand Down
8 changes: 8 additions & 0 deletions app/jobs/dns_validation_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class DNSValidationJob < ApplicationJob
queue_as :default

def perform(domain_id)
domain = Domain.find(domain_id)
DNSValidator.validate(domain: domain, name: domain.name, record_type: 'all')
end
end
Loading
Loading