Contact info command now honors disclosure

This commit is contained in:
Andres Keskküla 2014-08-29 11:51:56 +03:00
parent 0a1c2d3d57
commit 22f753aa6c
5 changed files with 46 additions and 18 deletions

View file

@ -1,26 +1,30 @@
if @contact.international_address
address = @contact.international_address
xml.tag!('contact:postalInfo', type: 'int') do # TODO instance method of defining type
xml.tag!('contact:name', address.name)
xml.tag!('contact:org', address.org_name)
xml.tag!('contact:addr') do
xml.tag!('contact:street', address.street) if address.street
xml.tag!('contact:street', address.street2) if address.street2
xml.tag!('contact:street', address.street3) if address.street3
xml.tag!('contact:cc', address.try(:country).try(:iso)) unless address.try(:country).nil?
xml.tag!('contact:name', address.name) if @contact.disclosure.int_name
xml.tag!('contact:org', address.org_name) if @contact.disclosure.int_org_name
if @contact.disclosure.int_addr
xml.tag!('contact:addr') do
xml.tag!('contact:street', address.street) if address.street
xml.tag!('contact:street', address.street2) if address.street2
xml.tag!('contact:street', address.street3) if address.street3
xml.tag!('contact:cc', address.try(:country).try(:iso)) unless address.try(:country).nil?
end
end
end
end
if @contact.local_address
address = @contact.local_address
xml.tag!('contact:postalInfo', type: 'loc') do
xml.tag!('contact:name', address.name)
xml.tag!('contact:org', address.org_name)
xml.tag!('contact:addr') do
xml.tag!('contact:street', address.street) if address.street
xml.tag!('contact:street', address.street2) if address.street2
xml.tag!('contact:street', address.street3) if address.street3
xml.tag!('contact:cc', address.try(:country).try(:iso)) unless address.try(:country).nil?
xml.tag!('contact:postalInfo', type: 'loc') do
xml.tag!('contact:name', address.name) if @contact.disclosure.loc_name
xml.tag!('contact:org', address.org_name) if @contact.disclosure.loc_org_name
if @contact.disclosure.loc_addr
xml.tag!('contact:addr') do
xml.tag!('contact:street', address.street) if address.street
xml.tag!('contact:street', address.street2) if address.street2
xml.tag!('contact:street', address.street3) if address.street3
xml.tag!('contact:cc', address.try(:country).try(:iso)) unless address.try(:country).nil?
end
end
end
end

View file

@ -7,9 +7,9 @@ xml.epp_head do
xml.resData do
xml.tag!('contact:chkData', 'xmlns:contact' => 'urn:ietf:params:xml:ns:contact-1.0') do
xml << render('/epp/contacts/postal_info')
xml.tag!('contact:voice', @contact.phone)
xml.tag!('contact:fax', @contact.fax)
xml.tag!('contact:email', @contact.email)
xml.tag!('contact:voice', @contact.phone) if @contact.disclosure.phone
xml.tag!('contact:fax', @contact.fax) if @contact.disclosure.fax
xml.tag!('contact:email', @contact.email) if @contact.disclosure.email
xml.tag!('contact:clID', @current_epp_user.username) if @current_epp_user
xml.tag!('contact:crID', @contact.cr_id ) if @contact.cr_id
xml.tag!('contact:crDate', @contact.created_at)

View file

@ -228,6 +228,19 @@ describe 'EPP Contact', epp: true do
end
it 'doesn\'t disclose private elements' do
Fabricate(:contact, code: 'info-4444', auth_info: '2fooBAR',
disclosure: Fabricate(:contact_disclosure, email: false, phone: false))
response = epp_request('contacts/info.xml')
contact = response[:parsed].css('resData chkData')
expect(response[:result_code]).to eq('1000')
expect(contact.css('phone').present?).to eq(false)
expect(contact.css('email').present?).to eq(false)
expect(contact.css('name').present?).to be(true)
end
it 'doesn\'t display unassociated object' do
Fabricate(:contact, code: 'info-4444')

View file

@ -0,0 +1,10 @@
Fabricator(:contact_disclosure) do
email true
phone true
loc_addr true
loc_name true
loc_org_name true
int_name true
int_org_name true
int_addr true
end

View file

@ -6,4 +6,5 @@ Fabricator(:contact) do
ident_type 'op'
auth_info 'ccds4324pok'
international_address
disclosure { Fabricate(:contact_disclosure) }
end