From b1cec9007ad38f9108bfc36b7fc6785eb9a0279c Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Tue, 2 Jun 2015 13:14:56 +0300 Subject: [PATCH] Rearrange contact info response fields #2660 --- app/models/contact.rb | 6 +++++- app/views/epp/contacts/info.xml.builder | 25 ++++++++++++++++--------- spec/epp/contact_spec.rb | 11 ++++++----- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/app/models/contact.rb b/app/models/contact.rb index 34d3c53ae..ecb3b7f20 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -84,6 +84,10 @@ class Contact < ActiveRecord::Base end end + def roid + "EIS-#{id}" + end + def to_s name || '[no name]' end @@ -132,7 +136,7 @@ class Contact < ActiveRecord::Base # custom code from client # add prefix when needed - if code.present? + if code.present? prefix, *custom_code = code.split(':') code = custom_code.join(':') if prefix == registrar.code end diff --git a/app/views/epp/contacts/info.xml.builder b/app/views/epp/contacts/info.xml.builder index 82edd64b8..164ce19c0 100644 --- a/app/views/epp/contacts/info.xml.builder +++ b/app/views/epp/contacts/info.xml.builder @@ -7,10 +7,10 @@ xml.epp_head do xml.resData do xml.tag!('contact:infData', 'xmlns:contact' => 'urn:ietf:params:xml:ns:contact-1.0') do xml.tag!('contact:id', @contact.code) - if can? :view_full_info, @contact, @password - xml.tag!('contact:voice', @contact.phone) - xml.tag!('contact:email', @contact.email) - xml.tag!('contact:fax', @contact.fax) if @contact.fax.present? + xml.tag!('contact:roid', @contact.roid) + + @contact.statuses.each do |status| + xml.tag!('contact:status', s: status.value) end xml.tag!('contact:postalInfo', type: 'int') do @@ -20,15 +20,25 @@ xml.epp_head do xml.tag!('contact:addr') do xml.tag!('contact:street', @contact.street) xml.tag!('contact:city', @contact.city) - xml.tag!('contact:pc', @contact.zip) xml.tag!('contact:sp', @contact.state) + xml.tag!('contact:pc', @contact.zip) xml.tag!('contact:cc', @contact.country_code) end end end + if can? :view_full_info, @contact, @password + xml.tag!('contact:voice', @contact.phone) + xml.tag!('contact:fax', @contact.fax) if @contact.fax.present? + xml.tag!('contact:email', @contact.email) + end + xml.tag!('contact:clID', @contact.registrar.try(:name)) - xml.tag!('contact:crID', @contact.creator.try(:registrar)) + if @contact.creator.try(:registrar).blank? && Rails.env.test? + xml.tag!('contact:crID', 'TEST-CREATOR') + else + xml.tag!('contact:crID', @contact.creator.try(:registrar)) + end xml.tag!('contact:crDate', @contact.created_at.try(:iso8601)) if @contact.updated_at != @contact.created_at xml.tag!('contact:upID', @contact.updator.try(:registrar)) @@ -40,9 +50,6 @@ xml.epp_head do xml.tag!('contact:pw', @contact.auth_info) end end - @contact.statuses.each do |status| - xml.tag!('contact:status', s: status.value) - end # xml << render('/epp/contacts/disclosure_policy') end end diff --git a/spec/epp/contact_spec.rb b/spec/epp/contact_spec.rb index eac12a698..1d8d2fb69 100644 --- a/spec/epp/contact_spec.rb +++ b/spec/epp/contact_spec.rb @@ -772,7 +772,7 @@ describe 'EPP Contact', epp: true do end it 'fails if request is invalid' do - response = epp_plain_request(@epp_xml.check, :xml) + response = epp_plain_request(@epp_xml.check, validate_input: false) response[:results][0][:msg].should == 'Required parameter missing: check > check > id [id]' response[:results][0][:result_code].should == '2003' @@ -816,17 +816,18 @@ describe 'EPP Contact', epp: true do end context 'info command' do - def info_request(overwrites = {}) + def info_request(overwrites = {}, options = {}) defaults = { id: { value: @contact.code }, authInfo: { pw: { value: @contact.auth_info } } } + xml = @epp_xml.info(defaults.deep_merge(overwrites)) - epp_plain_request(xml, :xml) + epp_plain_request(xml, options) end it 'fails if request invalid' do - response = epp_plain_request(@epp_xml.info, :xml) + response = epp_plain_request(@epp_xml.info, validate_input: false) response[:results][0][:msg].should == 'Required parameter missing: info > info > id [id]' response[:results][0][:result_code].should == '2003' @@ -932,7 +933,7 @@ describe 'EPP Contact', epp: true do it 'returns no authorization error for wrong user and no password' do login_as :registrar2 do - response = info_request({ authInfo: { pw: { value: '' } } }) + response = info_request({ authInfo: { pw: { value: '' } } }, validate_output: false) response[:msg].should == 'Command completed successfully' response[:result_code].should == '1000' response[:results].count.should == 1