mirror of
https://github.com/internetee/registry.git
synced 2025-07-22 02:35:57 +02:00
Check for domain dispute on create
This commit is contained in:
parent
928f96691c
commit
1dc2cf8e12
5 changed files with 41 additions and 4 deletions
|
@ -92,7 +92,7 @@ module Epp
|
|||
status: Auction.statuses[:payment_received])
|
||||
active_auction.domain_registered!
|
||||
end
|
||||
|
||||
Dispute.close_by_domain(@domain.name)
|
||||
render_epp_response '/epp/domains/create'
|
||||
else
|
||||
handle_errors(@domain)
|
||||
|
|
|
@ -27,6 +27,10 @@ class Dispute < ApplicationRecord
|
|||
dispute.update(closed: true) if dispute.present?
|
||||
end
|
||||
|
||||
def self.valid_auth?(domain_name, password)
|
||||
Dispute.active.find_by(domain_name: domain_name, password: password).present?
|
||||
end
|
||||
|
||||
def set_expiry_date
|
||||
return if starts_at.blank?
|
||||
|
||||
|
@ -98,7 +102,6 @@ class Dispute < ApplicationRecord
|
|||
private
|
||||
|
||||
def validate_start_date
|
||||
puts 'EXECUTED'
|
||||
return if starts_at.nil?
|
||||
|
||||
errors.add(:starts_at, :past) if starts_at.past?
|
||||
|
|
|
@ -90,7 +90,7 @@ class Domain < ApplicationRecord
|
|||
validates :transfer_code, presence: true
|
||||
|
||||
validate :validate_reservation
|
||||
|
||||
validate :validate_disputed
|
||||
def validate_reservation
|
||||
return if persisted? || !in_reserved_list?
|
||||
|
||||
|
@ -104,6 +104,19 @@ class Domain < ApplicationRecord
|
|||
errors.add(:base, :invalid_auth_information_reserved)
|
||||
end
|
||||
|
||||
def validate_disputed
|
||||
return if persisted? || !in_disputed_list?
|
||||
|
||||
if reserved_pw.blank?
|
||||
errors.add(:base, :required_parameter_missing_reserved)
|
||||
return false
|
||||
end
|
||||
|
||||
return if Dispute.valid_auth?(name, reserved_pw)
|
||||
|
||||
errors.add(:base, :invalid_auth_information_reserved)
|
||||
end
|
||||
|
||||
validate :status_is_consistant
|
||||
def status_is_consistant
|
||||
has_error = (statuses.include?(DomainStatus::SERVER_HOLD) && statuses.include?(DomainStatus::SERVER_MANUAL_INZONE))
|
||||
|
@ -277,6 +290,10 @@ class Domain < ApplicationRecord
|
|||
@in_reserved_list ||= ReservedDomain.by_domain(name).any?
|
||||
end
|
||||
|
||||
def in_disputed_list?
|
||||
@in_disputed_list ||= Dispute.active.find_by(domain_name: name).present?
|
||||
end
|
||||
|
||||
def disputed?
|
||||
Dispute.active.where(domain_name: name).any?
|
||||
end
|
||||
|
@ -302,6 +319,8 @@ class Domain < ApplicationRecord
|
|||
return false if statuses.include_any?(DomainStatus::DELETE_CANDIDATE, DomainStatus::PENDING_RENEW,
|
||||
DomainStatus::PENDING_TRANSFER, DomainStatus::PENDING_DELETE,
|
||||
DomainStatus::PENDING_UPDATE, DomainStatus::PENDING_DELETE_CONFIRMATION)
|
||||
return false if disputed?
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
|
|
|
@ -30,6 +30,22 @@ class AdminDisputesSystemTest < ApplicationSystemTestCase
|
|||
assert_text 'disputed.test'
|
||||
end
|
||||
|
||||
def test_throws_error_if_starts_at_is_past
|
||||
assert_nil Dispute.active.find_by(domain_name: 'disputed.test')
|
||||
|
||||
visit admin_disputes_path
|
||||
click_on 'New domain dispute'
|
||||
|
||||
fill_in 'Domain name', with: 'disputed.test'
|
||||
fill_in 'Password', with: '1234'
|
||||
fill_in 'Starts at', with: (Time.zone.today - 2.day).to_s
|
||||
fill_in 'Comment', with: 'Sample comment'
|
||||
click_on 'Save'
|
||||
|
||||
assert_text 'Dispute was successfully created.'
|
||||
assert_text 'disputed.test'
|
||||
end
|
||||
|
||||
def test_updates_dispute
|
||||
assert_not_equal Time.zone.today, @dispute.starts_at
|
||||
|
||||
|
|
|
@ -65,6 +65,5 @@ class DisputeStatusUpdateJobTest < ActiveSupport::TestCase
|
|||
|
||||
whois_record.reload
|
||||
assert_not whois_record.json['status'].include? 'disputed'
|
||||
puts whois_record.json['status']
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue