Basic transfer command for domain

This commit is contained in:
Martin Lensment 2014-08-27 17:25:39 +03:00
parent bb78c0f581
commit 707c60b36e
8 changed files with 76 additions and 2 deletions

View file

@ -9,6 +9,8 @@ module Epp::Common
included do
protect_from_forgery with: :null_session
before_action :validate_request, only: [:proxy]
helper_method :current_epp_user
end
def proxy

View file

@ -14,6 +14,10 @@ class Epp::CommandsController < ApplicationController
send("renew_#{OBJECT_TYPES[params_hash['epp']['xmlns:ns2']]}")
end
def transfer
send("transfer_#{OBJECT_TYPES[params_hash['epp']['xmlns:ns2']]}")
end
def check
send("check_#{OBJECT_TYPES[params_hash['epp']['xmlns:ns2']]}")
end

View file

@ -59,6 +59,18 @@ module Epp::DomainsHelper
end
end
def transfer_domain
@domain = find_domain
handle_errors(@domain) and return unless @domain
@domain.transfer_requested_at = Time.now
@domain.transferred_at = Time.now
@domain.save
render '/epp/domains/transfer'
end
### HELPER METHODS ###
private
@ -104,6 +116,12 @@ module Epp::DomainsHelper
xml_attrs_present?(@ph, [['name']])
end
## TRANSFER
def validate_domain_transfer_request
@ph = params_hash['epp']['command']['transfer']['transfer']
xml_attrs_present?(@ph, [['name']])
end
## SHARED
def find_domain
domain = Domain.find_by(name: @ph[:name])

View file

@ -0,0 +1,21 @@
xml.epp_head do
xml.response do
xml.result('code' => '1000') do
xml.msg 'Command completed successfully'
end
xml.resData do
xml.tag!('domain:trnData', 'xmlns:domain' => 'urn:ietf:params:xml:ns:domain-1.0') do
xml.tag!('domain:name', @domain.name)
xml.tag!('domain:trStatus', 'serverApproved')
xml.tag!('domain:reID', current_epp_user.username)
xml.tag!('domain:reDate', @domain.transfer_requested_at)
xml.tag!('domain:acID', current_epp_user.username)
xml.tag!('domain:acDate', @domain.transferred_at)
xml.tag!('domain:exDate', @domain.valid_to)
end
end
end
xml << render('/epp/shared/trID')
end

View file

@ -0,0 +1,7 @@
class AddTransferFieldsToDomain < ActiveRecord::Migration
def change
add_column :domains, :transferred_at, :datetime
add_column :domains, :transfer_requested_at, :datetime
add_column :domains, :transfer_to, :integer
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20140826103454) do
ActiveRecord::Schema.define(version: 20140827140759) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -90,7 +90,10 @@ ActiveRecord::Schema.define(version: 20140826103454) do
t.string "name_dirty"
t.string "name_puny"
t.integer "period"
t.string "period_unit", limit: 1
t.string "period_unit", limit: 1
t.datetime "transferred_at"
t.datetime "transfer_requested_at"
t.integer "transfer_to"
end
create_table "epp_sessions", force: true do |t|

View file

@ -349,6 +349,10 @@ describe 'EPP Domain', epp: true do
expect(d.owner_contact_code).to eq('mak21')
expect(d.auth_info).to eq('2BARfoo')
end
it 'transfers a domain' do
response = epp_request('domains/transfer.xml')
end
end
it 'checks a domain' do

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
<command>
<transfer op="query">
<domain:transfer
xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
<domain:name>example.ee</domain:name>
<domain:authInfo>
<domain:pw roid="JD1234-REP">98oiewslkfkd</domain:pw>
</domain:authInfo>
</domain:transfer>
</transfer>
<clTRID>ABC-12345</clTRID>
</command>
</epp>