diff --git a/app/models/domain.rb b/app/models/domain.rb index 1b1c840f6..b57a2c44b 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -266,7 +266,7 @@ class Domain < ActiveRecord::Base end def reserved_pw - ReservedDomain.select("names -> '#{name}' AS pw").first.pw + ReservedDomain.pw_for(name) end def pending_transfer @@ -474,7 +474,6 @@ class Domain < ActiveRecord::Base # rubocop:disable Lint/Loop def generate_auth_info - return if auth_info.present? begin self.auth_info = SecureRandom.hex end while self.class.exists?(auth_info: auth_info) diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index b98aa83b1..626477675 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -745,7 +745,7 @@ class Epp::Domain < Domain next end - unless DomainNameValidator.validate_reservation(x) + if ReservedDomain.pw_for(x).present? res << { name: x, avail: 0, reason: I18n.t('errors.messages.epp_domain_reserved') } next end diff --git a/app/models/reserved_domain.rb b/app/models/reserved_domain.rb index 807c44f91..61a57ec50 100644 --- a/app/models/reserved_domain.rb +++ b/app/models/reserved_domain.rb @@ -1,3 +1,9 @@ class ReservedDomain < ActiveRecord::Base include Versions # version/reserved_domain_version.rb + + class << self + def pw_for(domain_name) + select("names -> '#{domain_name}' AS pw").first.try(:pw) + end + end end diff --git a/app/validators/domain_name_validator.rb b/app/validators/domain_name_validator.rb index 1ac609a5a..325fe447a 100644 --- a/app/validators/domain_name_validator.rb +++ b/app/validators/domain_name_validator.rb @@ -42,10 +42,10 @@ class DomainNameValidator < ActiveModel::EachValidator BlockedDomain.where("names @> ?::varchar[]", "{#{value}}").count == 0 end - def validate_reservation(record, value) - return true unless value - return true if record.reserved_pw == record.auth_info - !ReservedDomain.exists?(name: value.mb_chars.downcase.strip) - end + # def validate_reservation(record, value) + # return true unless value + # return true if record.reserved_pw == record.auth_info + # !ReservedDomain.exists?(name: value.mb_chars.downcase.strip) + # end end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 943f453fd..228002ec0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -239,7 +239,7 @@ en: errors: messages: blank: 'is missing' - epp_domain_reserved: 'Domain name is reserved or restricted' + epp_domain_reserved: 'Domain name is reserved' epp_obj_does_not_exist: 'Object does not exist' epp_command_failed: 'Command failed' epp_authorization_error: 'Authorization error' diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index d4430ac15..442ca16a1 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -224,8 +224,8 @@ describe 'EPP Domain', epp: true do xml = domain_create_xml(name: { value: '1162.ee' }) response = epp_plain_request(xml) - response[:result_code].should == '2302' - response[:msg].should == 'Domain name is reserved [name_dirty]' + response[:result_code].should == '2304' + response[:msg].should == 'Domain is reserved and requires correct auth info' response[:clTRID].should == 'ABC-12345' end @@ -1419,8 +1419,8 @@ describe 'EPP Domain', epp: true do login_as :registrar2 do epp_plain_request(xml) # transfer domain response = epp_plain_request(xml) # attempt second transfer - response[:result_code].should == '2201' response[:msg].should == 'Authorization error' + response[:result_code].should == '2201' end end diff --git a/spec/fabricators/reserved_domain_fabricator.rb b/spec/fabricators/reserved_domain_fabricator.rb index f14948902..672fa3e53 100644 --- a/spec/fabricators/reserved_domain_fabricator.rb +++ b/spec/fabricators/reserved_domain_fabricator.rb @@ -1,3 +1,3 @@ Fabricator(:reserved_domain) do - name '1162.ee' + names { { '1162.ee': 'abc' } } end