Introduce request op to domain transfer #2746

This commit is contained in:
Martin Lensment 2015-07-10 15:42:14 +03:00
parent 6daf082129
commit c4da9c86a6
5 changed files with 121 additions and 10 deletions

View file

@ -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

View file

@ -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

View file

@ -866,3 +866,4 @@ en:
reserved_domains: 'Reserved domains'
invalid_yaml: 'Invalid YAML'
reserved_pw: 'Reserved pw'
no_transfers_found: 'No transfers found'

View file

@ -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

View file

@ -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: {