diff --git a/app/controllers/epp/domains_controller.rb b/app/controllers/epp/domains_controller.rb index a50b96003..e3188786f 100644 --- a/app/controllers/epp/domains_controller.rb +++ b/app/controllers/epp/domains_controller.rb @@ -179,7 +179,7 @@ class Epp::DomainsController < EppController requires 'name' @prefix = nil - requires_attribute 'transfer', 'op', values: %(approve, query, reject) + requires_attribute 'transfer', 'op', values: %(approve, query, reject, request) end def find_domain diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index c95ba7bed..bb9ab55ce 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -461,6 +461,8 @@ class Epp::Domain < Domain def transfer(frame, action, current_user) case action when 'query' + return domain_transfers.last if domain_transfers.any? + when 'request' return pending_transfer if pending_transfer return query_transfer(frame, current_user) when 'approve' @@ -468,7 +470,7 @@ class Epp::Domain < Domain when 'reject' return reject_transfer(frame, current_user) if pending_transfer end - add_epp_error('2303', nil, nil, I18n.t('pending_transfer_was_not_found')) + add_epp_error('2303', nil, nil, I18n.t('no_transfers_found')) end # TODO: Eager load problems here. Investigate how it's possible not to query contact again diff --git a/config/locales/en.yml b/config/locales/en.yml index 6ffd49079..5c2bcd344 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -866,3 +866,4 @@ en: reserved_domains: 'Reserved domains' invalid_yaml: 'Invalid YAML' reserved_pw: 'Reserved pw' + no_transfers_found: 'No transfers found' diff --git a/spec/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 728bf19ca..f88db572a 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -839,7 +839,7 @@ describe 'EPP Domain', epp: true do xml = domain_transfer_xml({ name: { value: domain.name }, authInfo: { pw: { value: pw } } - }, 'query', { + }, 'request', { _anonymus: [ legalDocument: { value: 'dGVzdCBmYWlsCg==', @@ -887,7 +887,7 @@ describe 'EPP Domain', epp: true do xml = domain_transfer_xml({ name: { value: domain.name }, authInfo: { pw: { value: pw } } - }, 'query', { + }, 'request', { _anonymus: [ legalDocument: { value: 'dGVzdCBmYWlsCg==', @@ -965,7 +965,7 @@ describe 'EPP Domain', epp: true do xml = domain_transfer_xml({ name: { value: domain.name }, authInfo: { pw: { value: pw } } - }, 'query', { + }, 'request', { _anonymus: [ legalDocument: { value: 'dGVzdCBmYWlsCg==', @@ -1401,7 +1401,7 @@ describe 'EPP Domain', epp: true do xml = domain_transfer_xml({ name: { value: domain.name }, authInfo: { pw: { value: 'test' } } - }, 'query', { + }, 'request', { _anonymus: [ legalDocument: { value: 'dGVzdCBmYWlsCg==', @@ -1415,12 +1415,12 @@ describe 'EPP Domain', epp: true do response[:msg].should == 'Authorization error' end - it 'ignores transfer wha registrant registrar requests transfer' do + it 'ignores transfer when domain already belongs to registrar' do pw = domain.auth_info xml = domain_transfer_xml({ name: { value: domain.name }, authInfo: { pw: { value: pw } } - }, 'query', { + }, 'request', { _anonymus: [ legalDocument: { value: 'dGVzdCBmYWlsCg==', @@ -1446,7 +1446,7 @@ describe 'EPP Domain', epp: true do xml = domain_transfer_xml({ name: { value: domain.name }, authInfo: { pw: { value: pw } } - }, 'query', { + }, 'request', { _anonymus: [ legalDocument: { value: 'dGVzdCBmYWlsCg==', @@ -1482,6 +1482,114 @@ describe 'EPP Domain', epp: true do response[:result_code].should == '2303' end + it 'should not return transfers when there are none' do + xml = domain_transfer_xml({ + name: { value: domain.name }, + authInfo: { pw: { value: domain.auth_info } } + }, 'query') + + response = epp_plain_request(xml) + response[:results][0][:msg].should == 'No transfers found' + response[:results][0][:result_code].should == '2303' + end + + it 'should allow querying domain transfer' do + Setting.transfer_wait_time = 1 + pw = domain.auth_info + xml = domain_transfer_xml({ + name: { value: domain.name }, + authInfo: { pw: { value: pw } } + }, 'request', { + _anonymus: [ + legalDocument: { + value: 'dGVzdCBmYWlsCg==', + attrs: { type: 'pdf' } + } + ] + }) + + login_as :registrar2 do + response = epp_plain_request(xml) + response[:results][0][:msg].should == 'Command completed successfully' + response[:results][0][:result_code].should == '1000' + + trn_data = response[:parsed].css('trnData') + + dtl = domain.domain_transfers.last + + trn_data.css('name').text.should == domain.name + trn_data.css('trStatus').text.should == 'pending' + trn_data.css('reID').text.should == 'REGDOMAIN2' + trn_data.css('reDate').text.should == dtl.transfer_requested_at.in_time_zone.utc.utc.iso8601 + trn_data.css('acDate').text.should == dtl.wait_until.in_time_zone.utc.utc.iso8601 + trn_data.css('acID').text.should == 'REGDOMAIN1' + trn_data.css('exDate').text.should == domain.valid_to.in_time_zone.utc.utc.iso8601 + + xml = domain_transfer_xml({ + name: { value: domain.name }, + authInfo: { pw: { value: pw } } + }, 'query') + + response = epp_plain_request(xml) + response[:results][0][:msg].should == 'Command completed successfully' + response[:results][0][:result_code].should == '1000' + + trn_data = response[:parsed].css('trnData') + + dtl = domain.domain_transfers.last + trn_data.css('name').text.should == domain.name + trn_data.css('trStatus').text.should == 'pending' + trn_data.css('reID').text.should == 'REGDOMAIN2' + trn_data.css('reDate').text.should == dtl.transfer_requested_at.in_time_zone.utc.utc.iso8601 + trn_data.css('acDate').text.should == dtl.wait_until.in_time_zone.utc.utc.iso8601 + trn_data.css('acID').text.should == 'REGDOMAIN1' + trn_data.css('exDate').text.should == domain.valid_to.in_time_zone.utc.utc.iso8601 + end + + # approves pending transfer + xml = domain_transfer_xml({ + name: { value: domain.name }, + authInfo: { pw: { value: pw } } + }, 'approve', { + _anonymus: [ + legalDocument: { + value: 'dGVzdCBmYWlsCg==', + attrs: { type: 'pdf' } + } + ] + }) + + response = epp_plain_request(xml) + response[:results][0][:msg].should == 'Command completed successfully' + response[:results][0][:result_code].should == '1000' + + # query should return last completed transfer + domain.reload + pw = domain.auth_info + xml = domain_transfer_xml({ + name: { value: domain.name }, + authInfo: { pw: { value: pw } } + }, 'query') + + response = epp_plain_request(xml) + response[:results][0][:msg].should == 'Command completed successfully' + response[:results][0][:result_code].should == '1000' + + trn_data = response[:parsed].css('trnData') + + dtl = domain.domain_transfers.last + + trn_data.css('name').text.should == domain.name + trn_data.css('trStatus').text.should == 'clientApproved' + trn_data.css('reID').text.should == 'REGDOMAIN2' + trn_data.css('reDate').text.should == dtl.transfer_requested_at.in_time_zone.utc.utc.iso8601 + trn_data.css('acDate').text.should == dtl.transferred_at.in_time_zone.utc.utc.iso8601 + trn_data.css('acID').text.should == 'REGDOMAIN1' + trn_data.css('exDate').text.should == domain.valid_to.in_time_zone.utc.utc.iso8601 + + Setting.transfer_wait_time = 0 + end + ### UPDATE ### it 'should update right away without update pending status' do existing_pw = domain.auth_info diff --git a/spec/support/epp.rb b/spec/support/epp.rb index 0193787f5..698284735 100644 --- a/spec/support/epp.rb +++ b/spec/support/epp.rb @@ -349,7 +349,7 @@ module Epp epp_xml.check(xml_params) end - def domain_transfer_xml(xml_params = {}, op = 'query', custom_params = {}) + def domain_transfer_xml(xml_params = {}, op = 'request', custom_params = {}) defaults = { name: { value: next_domain_name }, authInfo: {