Merge branch 'master' of github.com:internetee/registry

This commit is contained in:
Martin Lensment 2014-07-31 12:55:31 +03:00
commit c78e40a65a
8 changed files with 75 additions and 10 deletions

View file

@ -8,7 +8,8 @@ module Epp::ContactsHelper
code: ph[:id],
phone: ph[:voice],
ident: ph[:ident],
email: ph[:email]
email: ph[:email],
org_name: ph[:postalInfo][:org]
)
end
@contact.name = ph[:postalInfo][:name]
@ -53,8 +54,17 @@ module Epp::ContactsHelper
end
def info_contact
epp_errors << { code: '2101', msg: 'Unimplemented command' }
render 'epp/error'
#TODO add data missing from contacts/info builder ( marked with 'if false' in said view )
current_epp_user
ph = params_hash['epp']['command']['info']['info']
@contact = Contact.where(code: ph[:id]).first
if @contact
render '/epp/contacts/info'
else
epp_errors << { code: '2303', msg: 'Object does not exist' }
render 'epp/error'
end
end
private

View file

@ -0,0 +1,33 @@
xml.epp_head do
xml.response do
xml.result('code' => '1000') do
xml.msg 'Command completed successfully'
end
xml.resData do
xml.tag!('contact:chkData', 'xmlns:contact' => 'http://www.nic.cz/xml/epp/contact-1.6',
'xsi:schemaLocation' => 'http://www.nic.cz/xml/epp/contact-1.6 contact-1.6.xsd') do
xml.tag!('contact:name', @contact.name)
xml.tag!('contact:org', @contact.org_name)
xml.tag!('contact:addr') do
xml.tag!('contact:street', @contact.addresses.first.street)
xml.tag!('contact:street', @contact.addresses.first.city)
end
xml.tag!('contact:voice', @contact.phone)
xml.tag!('contact:fax', @contact.fax)
xml.tag!('contact:email', @contact.email)
xml.tag!('contact:clID', @current_epp_user.username) if @current_epp_user
xml.tag!('contact:crID', '123') if false
xml.tag!('contact:crDate', @contact.created_at)
xml.tag!('contact:upID', '123') if false
xml.tag!('contact:upDate', @contact.updated_at) unless @contact.updated_at == @contact.created_at
xml.tag!('contact:trDate', '123') if false
xml.tag!('contact:authInfo', '123') if false
xml.tag!('contact:disclose', '123') if false
end
end
xml << render('/epp/shared/trID')
end
end

View file

@ -0,0 +1,5 @@
class AddOrgNameToContact < ActiveRecord::Migration
def change
add_column :contacts, :org_name, :string
end
end

View file

@ -38,6 +38,7 @@ ActiveRecord::Schema.define(version: 20140731081816) do
t.datetime "updated_at"
t.string "ident"
t.string "ident_type"
t.string "org_name"
end
create_table "countries", force: true do |t|

View file

@ -14,6 +14,7 @@ describe 'EPP Contact', epp: true do
expect(response[:clTRID]).to eq('ABC-12345')
expect(Contact.count).to eq(1)
expect(Contact.first.org_name).to eq('Example Inc.')
end
it 'updates a contact with same ident' do
@ -56,14 +57,23 @@ describe 'EPP Contact', epp: true do
end
#TODO replace after implementing info commad for contact
it 'returns error unimplemented command on info_contact' do
Fabricate(:contact)
it 'returns error when object does not exist' do
response = epp_request('contacts/info.xml')
expect(response[:result_code]).to eq('2101')
expect(response[:msg]).to eq('Unimplemented command')
expect(response[:result_code]).to eq('2303')
expect(response[:msg]).to eq('Object does not exist')
end
end
it 'returns info about contact' do
contact = Fabricate(:contact, :name => "Johnny Awesome")
Fabricate(:address)
response = epp_request('contacts/info.xml')
contact_res = response[:parsed].css('resData chkData')
expect(response[:result_code]).to eq('1000')
expect(response[:msg]).to eq('Command completed successfully')
expect(contact_res.css('name').first.text).to eq('Johnny Awesome')
end
end
end

View file

@ -4,7 +4,7 @@
<info>
<contact:info
xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
<contact:id>sh8013</contact:id>
<contact:id>sh8913</contact:id>
<contact:authInfo>
<contact:pw>2fooBAR</contact:pw>
</contact:authInfo>

View file

@ -0,0 +1,5 @@
Fabricator(:address) do
city Faker::Address.city
street Faker::Address.street_name
zip Faker::Address.zip
end

View file

@ -5,4 +5,5 @@ Fabricator(:contact) do
ident '37605030299'
code 'sh8913'
ident_type 'op'
addresses(count: 2)
end