mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 13:15:40 +02:00
Merge pull request #2170 from internetee/2169-disputes-fix-for-password-checking
Disputes: fix for registration of disputed domains
This commit is contained in:
commit
a4d94bffad
3 changed files with 53 additions and 7 deletions
|
@ -8,12 +8,12 @@ module Whois
|
||||||
def execute
|
def execute
|
||||||
::PaperTrail.request.whodunnit = "job - #{self.class.name} - #{type}"
|
::PaperTrail.request.whodunnit = "job - #{self.class.name} - #{type}"
|
||||||
|
|
||||||
klass = determine_class
|
collection = determine_collection
|
||||||
|
|
||||||
Array(names).each do |name|
|
Array(names).each do |name|
|
||||||
record = find_record(klass, name)
|
record = find_record(collection, name)
|
||||||
if record
|
if record
|
||||||
Whois::UpdateRecord.run(record: { klass: klass.to_s, id: record.id, type: type })
|
Whois::UpdateRecord.run(record: { klass: collection.to_s, id: record.id, type: type })
|
||||||
else
|
else
|
||||||
Whois::DeleteRecord.run(name: name, type: type)
|
Whois::DeleteRecord.run(name: name, type: type)
|
||||||
end
|
end
|
||||||
|
@ -22,7 +22,7 @@ module Whois
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def determine_class
|
def determine_collection
|
||||||
case type
|
case type
|
||||||
when 'reserved' then ReservedDomain
|
when 'reserved' then ReservedDomain
|
||||||
when 'blocked' then BlockedDomain
|
when 'blocked' then BlockedDomain
|
||||||
|
@ -32,8 +32,12 @@ module Whois
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_record(klass, name)
|
def find_record(collection, name)
|
||||||
klass == DNS::Zone ? klass.find_by(origin: name) : klass.find_by(name: name)
|
if collection == Dispute.active
|
||||||
|
collection.find_by(domain_name: name)
|
||||||
|
else
|
||||||
|
collection == DNS::Zone ? collection.find_by(origin: name) : collection.find_by(name: name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,12 +21,16 @@ module Domain::Disputable
|
||||||
@in_disputed_list ||= Dispute.active.find_by(domain_name: name).present?
|
@in_disputed_list ||= Dispute.active.find_by(domain_name: name).present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def in_auction_list?
|
||||||
|
@in_auction_list ||= Auction.find_by(domain: name, status: Auction.statuses[:started]).present?
|
||||||
|
end
|
||||||
|
|
||||||
def disputed?
|
def disputed?
|
||||||
Dispute.active.where(domain_name: name).any?
|
Dispute.active.where(domain_name: name).any?
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_disputed
|
def validate_disputed
|
||||||
return if persisted? || !in_disputed_list?
|
return if persisted? || !in_disputed_list? || in_auction_list?
|
||||||
|
|
||||||
if reserved_pw.blank?
|
if reserved_pw.blank?
|
||||||
errors.add(:base, :required_parameter_missing_disputed)
|
errors.add(:base, :required_parameter_missing_disputed)
|
||||||
|
|
|
@ -814,4 +814,42 @@ class EppDomainCreateBaseTest < EppTestCase
|
||||||
assert_correct_against_schema response_xml
|
assert_correct_against_schema response_xml
|
||||||
assert_epp_response :billing_failure
|
assert_epp_response :billing_failure
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_registers_disputed_domain_with_password
|
||||||
|
now = Time.zone.parse('2010-07-05')
|
||||||
|
travel_to now
|
||||||
|
disputed_domain = disputes(:active)
|
||||||
|
password = disputed_domain.password
|
||||||
|
|
||||||
|
request_xml = <<-XML
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee', for_version: '1.0')}">
|
||||||
|
<command>
|
||||||
|
<create>
|
||||||
|
<domain:create xmlns:domain="#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}">
|
||||||
|
<domain:name>#{disputed_domain.domain_name}</domain:name>
|
||||||
|
<domain:registrant>#{contacts(:john).code}</domain:registrant>
|
||||||
|
</domain:create>
|
||||||
|
</create>
|
||||||
|
<extension>
|
||||||
|
<eis:extdata xmlns:eis="#{Xsd::Schema.filename(for_prefix: 'eis', for_version: '1.0')}">
|
||||||
|
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||||
|
<eis:reserved>
|
||||||
|
<eis:pw>#{password}</eis:pw>
|
||||||
|
</eis:reserved>
|
||||||
|
</eis:extdata>
|
||||||
|
</extension>
|
||||||
|
</command>
|
||||||
|
</epp>
|
||||||
|
XML
|
||||||
|
|
||||||
|
assert_difference 'Domain.count' do
|
||||||
|
post epp_create_path, params: { frame: request_xml },
|
||||||
|
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||||
|
end
|
||||||
|
response_xml = Nokogiri::XML(response.body)
|
||||||
|
|
||||||
|
assert_correct_against_schema response_xml
|
||||||
|
assert_epp_response :completed_successfully
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue