mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Add basic contact creation request to EPP
This commit is contained in:
parent
d0251de28f
commit
2187be6364
6 changed files with 100 additions and 1 deletions
|
@ -14,6 +14,22 @@ module Epp::Common
|
||||||
Nokogiri::XML(params[:frame]).remove_namespaces!
|
Nokogiri::XML(params[:frame]).remove_namespaces!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_params_hash(path)
|
||||||
|
node_set = parsed_frame.css(path).children.select{ |x| x.element? && x.element_children.empty? }
|
||||||
|
|
||||||
|
node_set.inject({}) do |hash, obj|
|
||||||
|
#convert to array if 1 or more attributes with same name
|
||||||
|
if hash[obj.name.to_sym] && !hash[obj.name.to_sym].is_a?(Array)
|
||||||
|
hash[obj.name.to_sym] = [hash[obj.name.to_sym]]
|
||||||
|
hash[obj.name.to_sym] << obj.text.strip
|
||||||
|
else
|
||||||
|
hash[obj.name.to_sym] = obj.text.strip
|
||||||
|
end
|
||||||
|
|
||||||
|
hash
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def epp_session
|
def epp_session
|
||||||
EppSession.find_or_initialize_by(session_id: cookies['session'])
|
EppSession.find_or_initialize_by(session_id: cookies['session'])
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
class Epp::CommandsController < ApplicationController
|
class Epp::CommandsController < ApplicationController
|
||||||
include Epp::Common
|
include Epp::Common
|
||||||
include Epp::DomainsHelper
|
include Epp::DomainsHelper
|
||||||
|
include Epp::ContactsHelper
|
||||||
|
|
||||||
OBJECT_TYPES = {
|
OBJECT_TYPES = {
|
||||||
'http://www.nic.cz/xml/epp/domain-1.4 domain-1.4.xsd' => 'domain'
|
'http://www.nic.cz/xml/epp/domain-1.4 domain-1.4.xsd' => 'domain',
|
||||||
|
'http://www.nic.cz/xml/epp/contact-1.6 contact-1.6.xsd' => 'contact'
|
||||||
}
|
}
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
13
app/helpers/epp/contacts_helper.rb
Normal file
13
app/helpers/epp/contacts_helper.rb
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
module Epp::ContactsHelper
|
||||||
|
def create_contact
|
||||||
|
ccp = contact_create_params
|
||||||
|
end
|
||||||
|
|
||||||
|
### HELPER METHODS ###
|
||||||
|
|
||||||
|
def contact_create_params
|
||||||
|
{
|
||||||
|
addr: get_params_hash('epp command create create postalInfo addr')
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
16
app/views/epp/contacts/create.xml.builder
Normal file
16
app/views/epp/contacts/create.xml.builder
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
xml.epp_head do
|
||||||
|
xml.response do
|
||||||
|
xml.result('code' => '1000') do
|
||||||
|
xml.msg 'Command completed successfully'
|
||||||
|
end
|
||||||
|
|
||||||
|
xml.resData do
|
||||||
|
xml.tag!('contact:creData', '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:id', @id)
|
||||||
|
xml.tag!('contact:crDate', @crDate)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
xml << render('/epp/shared/trID')
|
||||||
|
end
|
||||||
|
end
|
18
spec/epp/contact_spec.rb
Normal file
18
spec/epp/contact_spec.rb
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
describe 'EPP Contact', epp: true do
|
||||||
|
let(:server) { Epp::Server.new({server: 'localhost', tag: 'test', password: 'test', port: 701}) }
|
||||||
|
|
||||||
|
context 'with valid user' do
|
||||||
|
before(:each) { Fabricate(:epp_user) }
|
||||||
|
|
||||||
|
# incomplete
|
||||||
|
it 'creates a contact' do
|
||||||
|
response = epp_request('contacts/create.xml')
|
||||||
|
expect(response[:result_code]).to eq('1000')
|
||||||
|
expect(response[:msg]).to eq('Command completed successfully')
|
||||||
|
expect(response[:clTRID]).to eq('ABC-12345')
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
34
spec/epp/requests/contacts/create.xml
Normal file
34
spec/epp/requests/contacts/create.xml
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||||
|
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd">
|
||||||
|
<command>
|
||||||
|
<create>
|
||||||
|
<contact:create 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">
|
||||||
|
<contact:id>sh8013</contact:id>
|
||||||
|
<contact:postalInfo type="int">
|
||||||
|
<contact:name>John Doe</contact:name>
|
||||||
|
<contact:org>Example Inc.</contact:org>
|
||||||
|
<contact:addr>
|
||||||
|
<contact:street>123 Example Dr.</contact:street>
|
||||||
|
<contact:street>Suite 100</contact:street>
|
||||||
|
<contact:city>Dulles</contact:city>
|
||||||
|
<contact:sp>VA</contact:sp>
|
||||||
|
<contact:pc>20166-6503</contact:pc>
|
||||||
|
<contact:cc>US</contact:cc>
|
||||||
|
</contact:addr>
|
||||||
|
</contact:postalInfo>
|
||||||
|
<contact:voice x="1234">+1.7035555555</contact:voice>
|
||||||
|
<contact:fax>+1.7035555556</contact:fax>
|
||||||
|
<contact:email>jdoe@example.com</contact:email>
|
||||||
|
<contact:authInfo>
|
||||||
|
<contact:pw>2fooBAR</contact:pw>
|
||||||
|
</contact:authInfo>
|
||||||
|
<contact:disclose flag="0">
|
||||||
|
<contact:voice/>
|
||||||
|
<contact:email/>
|
||||||
|
</contact:disclose>
|
||||||
|
</contact:create>
|
||||||
|
</create>
|
||||||
|
<clTRID>ABC-12345</clTRID>
|
||||||
|
</command>
|
||||||
|
</epp>
|
Loading…
Add table
Add a link
Reference in a new issue