diff --git a/app/helpers/epp/contacts_helper.rb b/app/helpers/epp/contacts_helper.rb index 89a255dbb..9e1a6882b 100644 --- a/app/helpers/epp/contacts_helper.rb +++ b/app/helpers/epp/contacts_helper.rb @@ -33,6 +33,7 @@ module Epp::ContactsHelper end def info_contact + handle_errors and return unless has_rights? @contact = find_contact handle_errors(@contact) and return unless @contact render 'epp/contacts/info' @@ -88,7 +89,8 @@ module Epp::ContactsHelper def has_rights? authInfo = @ph.try(:[], :authInfo).try(:[], :pw) || @ph.try(:[], :chg).try(:[], :authInfo).try(:[], :pw) || [] id = @ph[:id] - return true if (id && authInfo && find_contact.auth_info == authInfo) + + return true if (id && authInfo && !find_contact.nil? && find_contact.auth_info == authInfo) epp_errors << { code: '2201', msg: t('errors.messages.epp_authorization_error'), value: { obj: 'pw', val: authInfo } } return false diff --git a/spec/epp/contact_spec.rb b/spec/epp/contact_spec.rb index 5b73ef54b..bfcec577b 100644 --- a/spec/epp/contact_spec.rb +++ b/spec/epp/contact_spec.rb @@ -158,7 +158,7 @@ describe 'EPP Contact', epp: true do expect(response[:results].count).to eq 1 end - it 'returns info about contact' do + it 'returns info about contact availability' do Fabricate(:contact, code: 'check-1234') response = epp_request(contact_check_xml( ids: [{ id: 'check-1234'}, { id: 'check-4321' }] ), :xml) @@ -192,7 +192,7 @@ describe 'EPP Contact', epp: true do end it 'returns info about contact' do - Fabricate(:contact, name: "Johnny Awesome", created_by_id: '1', code: 'info-4444') + Fabricate(:contact, name: "Johnny Awesome", created_by_id: '1', code: 'info-4444', auth_info: '2fooBAR') Fabricate(:address) response = epp_request('contacts/info.xml') @@ -204,10 +204,8 @@ describe 'EPP Contact', epp: true do end - it 'doesn\'t display unassociated object', pending: true do - pending 'until new contact rights systems is implemented' - Fabricate(:contact, name:"Johnny Awesome", created_by_id: '240', code: 'info-4444') - Fabricate(:epp_user, id: 240) + it 'doesn\'t display unassociated object' do + Fabricate(:contact, name:"Johnny Awesome", code: 'info-4444') response = epp_request('contacts/info.xml') expect(response[:result_code]).to eq('2201')