Merge branch 'master' of github.com:internetee/registry

This commit is contained in:
Andres Keskküla 2014-08-28 15:38:10 +03:00
commit 23d24aad84
4 changed files with 34 additions and 12 deletions

View file

@ -63,7 +63,7 @@ module Epp::DomainsHelper
@domain = find_domain
handle_errors(@domain) and return unless @domain
handle_errors(@domain) and return unless @domain.transfer(@ph[:authInfo][:pw], current_epp_user)
handle_errors(@domain) and return unless @domain.transfer(domain_transfer_params)
render '/epp/domains/transfer'
end
@ -95,6 +95,14 @@ module Epp::DomainsHelper
}
end
def domain_transfer_params
res = {}
res[:pw] = parsed_frame.css('pw').first.try(:text)
res[:action] = parsed_frame.css('transfer').first[:op]
res[:current_user] = current_epp_user
res
end
## RENEW
def validate_domain_renew_request
@ph = params_hash['epp']['command']['renew']['renew']

View file

@ -73,8 +73,7 @@ class Contact < ActiveRecord::Base
end
def auth_info_matches(pw)
return true if auth_info == pw
false
auth_info == pw
end
# Find a way to use self.domains with contact

View file

@ -205,9 +205,12 @@ class Domain < ActiveRecord::Base
end
### TRANSFER ###
def transfer(pw, current_user)
return false unless authenticate(pw)
return true if pending_transfer
def transfer(params)
return false unless authenticate(params[:pw])
if pending_transfer && params[:action] == 'approve'
approve_pending_transfer and return true
end
wait_time = SettingGroup.domain_general.setting(:transfer_wait_time).value.to_i
@ -215,7 +218,7 @@ class Domain < ActiveRecord::Base
domain_transfers.create(
status: DomainTransfer::PENDING,
transfer_requested_at: Time.zone.now,
transfer_to: current_user.registrar,
transfer_to: params[:current_user].registrar,
transfer_from: registrar
)
else
@ -223,15 +226,26 @@ class Domain < ActiveRecord::Base
status: DomainTransfer::SERVER_APPROVED,
transfer_requested_at: Time.zone.now,
transferred_at: Time.zone.now,
transfer_to: current_user.registrar,
transfer_to: params[:current_user].registrar,
transfer_from: registrar
)
self.registrar = current_user.registrar
self.registrar = params[:current_user].registrar
save
end
end
def approve_pending_transfer
p = pending_transfer
p.update(
status: DomainTransfer::CLIENT_APPROVED,
transferred_at: Time.zone.now
)
self.registrar = p.transfer_to
save
end
def pending_transfer
domain_transfers.find_by(status: DomainTransfer::PENDING)
end

View file

@ -84,7 +84,7 @@ describe 'EPP Domain', epp: true do
expect(trn_data.css('exDate').text).to eq(d.valid_to.to_time.utc.to_s)
end
it 'approves the transfer request', pending: true do
it 'approves the transfer request' do
s = Setting.find_by(code: 'transfer_wait_time')
s.update(value: 1)
@ -93,12 +93,13 @@ describe 'EPP Domain', epp: true do
response = epp_request(xml, :xml)
trn_data = response[:parsed].css('trnData')
d = Domain.first
dtl = d.domain_transfers.last
expect(trn_data.css('name').text).to eq('example.ee')
expect(trn_data.css('trStatus').text).to eq('serverApproved')
expect(trn_data.css('trStatus').text).to eq('clientApproved')
expect(trn_data.css('reID').text).to eq('10577829')
expect(trn_data.css('reDate').text).to eq(dtl.transfer_requested_at.to_time.utc.to_s)
expect(trn_data.css('acID').text).to eq('10577829')
expect(trn_data.css('acID').text).to eq('123')
expect(trn_data.css('exDate').text).to eq(d.valid_to.to_time.utc.to_s)
end