mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 17:37:17 +02:00
Add basic domain creating via EPP
This commit is contained in:
parent
8c1ea03f95
commit
aa88c30565
4 changed files with 34 additions and 1 deletions
|
@ -1,8 +1,15 @@
|
|||
class Epp::CommandsController < ApplicationController
|
||||
include Epp::Common
|
||||
include Epp::CommandsHelper
|
||||
include Epp::DomainsHelper
|
||||
|
||||
OBJECT_TYPES = {
|
||||
'http://www.nic.cz/xml/epp/domain-1.4 domain-1.4.xsd' => 'domain'
|
||||
}
|
||||
|
||||
private
|
||||
def create
|
||||
render '/epp/domains/create'
|
||||
type = OBJECT_TYPES[parsed_frame.css('create create').attr('schemaLocation').value]
|
||||
send("create_#{type}")
|
||||
end
|
||||
end
|
||||
|
|
6
app/helpers/epp/commands_helper.rb
Normal file
6
app/helpers/epp/commands_helper.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
module Epp::CommandsHelper
|
||||
def command_params
|
||||
node_set = parsed_frame.css('epp command create create').children.select(&:element?)
|
||||
node_set.inject({}) {|hash, obj| hash[obj.name.to_sym] = obj.text;hash }
|
||||
end
|
||||
end
|
18
app/helpers/epp/domains_helper.rb
Normal file
18
app/helpers/epp/domains_helper.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
module Epp::DomainsHelper
|
||||
def create_domain
|
||||
domain = Domain.create!(domain_params)
|
||||
render '/epp/domains/create'
|
||||
end
|
||||
|
||||
def domain_params
|
||||
cp = command_params
|
||||
{
|
||||
name: cp[:name],
|
||||
registrar: nil, #well come from current_epp_user
|
||||
registered_at: Time.now,
|
||||
valid_from: Date.today,
|
||||
valid_to: Date.today + cp[:period].to_i.years,
|
||||
auth_info: cp[:authInfo]
|
||||
}
|
||||
end
|
||||
end
|
|
@ -8,6 +8,8 @@ describe 'EPP Domain', epp: true do
|
|||
|
||||
it 'creates a domain' do
|
||||
response = epp_request('create_domain.xml')
|
||||
expect(response[:result_code]).to eq('1000')
|
||||
expect(response[:msg]).to eq('Command completed successfully')
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue