Add basic domain creating via EPP

This commit is contained in:
Martin Lensment 2014-06-25 18:12:00 +03:00
parent 8c1ea03f95
commit aa88c30565
4 changed files with 34 additions and 1 deletions

View file

@ -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

View 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

View 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

View file

@ -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