mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Merge branch 'master' of github.com:internetee/registry
This commit is contained in:
commit
c78e40a65a
8 changed files with 75 additions and 10 deletions
|
@ -8,7 +8,8 @@ module Epp::ContactsHelper
|
||||||
code: ph[:id],
|
code: ph[:id],
|
||||||
phone: ph[:voice],
|
phone: ph[:voice],
|
||||||
ident: ph[:ident],
|
ident: ph[:ident],
|
||||||
email: ph[:email]
|
email: ph[:email],
|
||||||
|
org_name: ph[:postalInfo][:org]
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
@contact.name = ph[:postalInfo][:name]
|
@contact.name = ph[:postalInfo][:name]
|
||||||
|
@ -53,9 +54,18 @@ module Epp::ContactsHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def info_contact
|
def info_contact
|
||||||
epp_errors << { code: '2101', msg: 'Unimplemented command' }
|
#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'
|
render 'epp/error'
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
33
app/views/epp/contacts/info.xml.builder
Normal file
33
app/views/epp/contacts/info.xml.builder
Normal 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
|
5
db/migrate/20140731073300_add_org_name_to_contact.rb
Normal file
5
db/migrate/20140731073300_add_org_name_to_contact.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class AddOrgNameToContact < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :contacts, :org_name, :string
|
||||||
|
end
|
||||||
|
end
|
|
@ -38,6 +38,7 @@ ActiveRecord::Schema.define(version: 20140731081816) do
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.string "ident"
|
t.string "ident"
|
||||||
t.string "ident_type"
|
t.string "ident_type"
|
||||||
|
t.string "org_name"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "countries", force: true do |t|
|
create_table "countries", force: true do |t|
|
||||||
|
|
|
@ -14,6 +14,7 @@ describe 'EPP Contact', epp: true do
|
||||||
expect(response[:clTRID]).to eq('ABC-12345')
|
expect(response[:clTRID]).to eq('ABC-12345')
|
||||||
|
|
||||||
expect(Contact.count).to eq(1)
|
expect(Contact.count).to eq(1)
|
||||||
|
expect(Contact.first.org_name).to eq('Example Inc.')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates a contact with same ident' do
|
it 'updates a contact with same ident' do
|
||||||
|
@ -56,14 +57,23 @@ describe 'EPP Contact', epp: true do
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#TODO replace after implementing info commad for contact
|
it 'returns error when object does not exist' do
|
||||||
it 'returns error unimplemented command on info_contact' do
|
|
||||||
Fabricate(:contact)
|
|
||||||
response = epp_request('contacts/info.xml')
|
response = epp_request('contacts/info.xml')
|
||||||
expect(response[:result_code]).to eq('2101')
|
expect(response[:result_code]).to eq('2303')
|
||||||
expect(response[:msg]).to eq('Unimplemented command')
|
expect(response[:msg]).to eq('Object does not exist')
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<info>
|
<info>
|
||||||
<contact:info
|
<contact:info
|
||||||
xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
|
xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
|
||||||
<contact:id>sh8013</contact:id>
|
<contact:id>sh8913</contact:id>
|
||||||
<contact:authInfo>
|
<contact:authInfo>
|
||||||
<contact:pw>2fooBAR</contact:pw>
|
<contact:pw>2fooBAR</contact:pw>
|
||||||
</contact:authInfo>
|
</contact:authInfo>
|
||||||
|
|
5
spec/fabricators/address_fabricator.rb
Normal file
5
spec/fabricators/address_fabricator.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
Fabricator(:address) do
|
||||||
|
city Faker::Address.city
|
||||||
|
street Faker::Address.street_name
|
||||||
|
zip Faker::Address.zip
|
||||||
|
end
|
|
@ -5,4 +5,5 @@ Fabricator(:contact) do
|
||||||
ident '37605030299'
|
ident '37605030299'
|
||||||
code 'sh8913'
|
code 'sh8913'
|
||||||
ident_type 'op'
|
ident_type 'op'
|
||||||
|
addresses(count: 2)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue