Honor CID and new format independently

This commit is contained in:
Priit Tark 2015-05-06 18:59:58 +03:00
parent 0a07004633
commit ba26ea4bac
5 changed files with 11 additions and 39 deletions

View file

@ -59,7 +59,7 @@ class Epp::ContactsController < EppController
end
def find_contact
code = params[:parsed_frame].css('id').text.strip.upcase.sub(/^CID:/, '')
code = params[:parsed_frame].css('id').text.strip.upcase
@contact = Epp::Contact.find_by_epp_code(code)

View file

@ -118,7 +118,6 @@ class Contact < ActiveRecord::Base
# custom code from client
# add prefix when needed
if code.present?
code.sub!(/^CID:/, '')
prefix, *custom_code = code.split(':')
code = custom_code.join(':') if prefix == registrar.code
end

View file

@ -8,7 +8,8 @@ class Epp::Contact < Contact
class << self
# support legacy search
def find_by_epp_code(code)
find_by(code: code.sub(/^CID:/, ''))
# find_by(code: code.sub(/^CID:/, '')) # legacy support turned off
find_by(code: code)
end
# rubocop: disable Metrics/PerceivedComplexity

View file

@ -164,12 +164,12 @@ describe 'EPP Contact', epp: true do
response[:result_code].should == '2005'
end
it 'should not add registrar prefix for code when legacy prefix present' do
it 'should add registrar prefix for code when legacy prefix present' do
response = create_request({ id: { value: 'CID:FIRST0:abc:ABC:NEW:12345' } })
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
Contact.last.code.should == 'FIRST0:ABC:ABC:NEW:12345'
Contact.last.code.should == 'FIRST0:CID:FIRST0:ABC:ABC:NEW:12345'
end
it 'should not remove suffix CID' do
@ -177,7 +177,7 @@ describe 'EPP Contact', epp: true do
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'
Contact.last.code.should == 'FIRST0:ABC:CID:ABC:NEW:12345'
Contact.last.code.should == 'FIRST0:CID:FIRST0:ABC:CID:ABC:NEW:12345'
end
it 'should not add registrar prefix for code when prefix present' do
@ -802,10 +802,10 @@ describe 'EPP Contact', epp: true do
ids = response[:parsed].css('resData chkData id')
ids[0].text.should == 'FIXED:CHECK-LEGACY'
ids[1].text.should == 'FIXED:CHECK-LEGACY'
ids[1].text.should == 'CID:FIXED:CHECK-LEGACY'
ids[0].attributes['avail'].text.should == '0'
ids[1].attributes['avail'].text.should == '0'
ids[1].attributes['avail'].text.should == '1'
end
end
@ -847,10 +847,10 @@ describe 'EPP Contact', epp: true do
contact.css('name').first.text.should == 'Johnny Awesome'
end
it 'should honour legacy CID format' do
Fabricate(:contact, code: 'INFO-5555', name: 'Johnny Awesome')
it 'should add legacy CID format as append' do
Fabricate(:contact, code: 'CID:FIXED:INFO-5555', name: 'Johnny Awesome')
response = info_request({ id: { value: 'CID:FIXED:INFO-5555' } })
response = info_request({ id: { value: 'FIXED:CID:FIXED:INFO-5555' } })
response[:msg].should == 'Command completed successfully'
response[:result_code].should == '1000'

View file

@ -1378,34 +1378,6 @@ describe 'EPP Domain', epp: true do
d.auth_info.should == existing_pw
end
it 'updates a domain with legacy CID format' do
existing_pw = domain.auth_info
xml_params = {
name: { value: domain.name },
chg: [
registrant: { value: 'CID:FIXED:CITIZEN_1234' }
]
}
response = epp_plain_request(domain_update_xml(xml_params, {}, {
_anonymus: [
legalDocument: {
value: 'JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0Zp==',
attrs: { type: 'pdf' }
}
]
}), :xml)
response[:results][0][:msg].should == 'Command completed successfully'
response[:results][0][:result_code].should == '1000'
d = Domain.last
d.registrant_code.should == 'FIXED:CITIZEN_1234'
d.auth_info.should == existing_pw
end
it 'updates domain and adds objects' do
xml = domain_update_xml({
name: { value: domain.name },