Rearrange contact info response fields #2660

This commit is contained in:
Martin Lensment 2015-06-02 13:14:56 +03:00
parent 1d76e10b55
commit b1cec9007a
3 changed files with 27 additions and 15 deletions

View file

@ -84,6 +84,10 @@ class Contact < ActiveRecord::Base
end
end
def roid
"EIS-#{id}"
end
def to_s
name || '[no name]'
end

View file

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

View file

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