Domain transfer improvements, various test fixes

This commit is contained in:
Martin Lensment 2014-08-28 18:10:04 +03:00
parent 187316078b
commit 0adca73f88
5 changed files with 44 additions and 19 deletions

View file

@ -24,8 +24,11 @@ group :red_green_refactor, halt_on_fail:true do
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end
guard :rubocop do
watch(%r{.+\.rb$})
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
end
# Martin does not want rubocop
unless Socket.gethostname == 'martin'
guard :rubocop do
watch(%r{.+\.rb$})
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
end
end
end

View file

@ -60,7 +60,7 @@ module Epp::DomainsHelper
end
def transfer_domain
@domain = find_domain
@domain = find_domain(secure: false)
handle_errors(@domain) and return unless @domain
handle_errors(@domain) and return unless @domain.transfer(domain_transfer_params)
@ -128,8 +128,10 @@ module Epp::DomainsHelper
end
## SHARED
def find_domain
domain = Domain.find_by(name: @ph[:name])
def find_domain(secure = { secure: true })
domain = Domain.find_by(name: @ph[:name], registrar: current_epp_user.registrar) if secure[:secure] == true
domain = Domain.find_by(name: @ph[:name]) if secure[:secure] == false
unless domain
epp_errors << { code: '2303', msg: I18n.t('errors.messages.epp_domain_not_found'), value: { obj: 'name', val: @ph[:name] } }
end

View file

@ -205,6 +205,7 @@ class Domain < ActiveRecord::Base
end
### TRANSFER ###
def transfer(params)
return false unless authenticate(params[:pw])
@ -212,6 +213,8 @@ class Domain < ActiveRecord::Base
approve_pending_transfer and return true
end
return true if pending_transfer
wait_time = SettingGroup.domain_general.setting(:transfer_wait_time).value.to_i
if wait_time > 0

View file

@ -7,4 +7,19 @@
# Mayor.create(name: 'Emanuel', city: cities.first)
Country.where(name: 'Estonia', iso: 'EE').first_or_create
EppUser.where(username: 'gitlab', password: 'ghyt9e4fu', active: true).first_or_create
zone = Registrar.where(
name: 'Zone Media OÜ',
reg_no: '10577829',
address: 'Lõõtsa 2, Tallinna linn, Harju maakond, 11415'
).first_or_create
EppUser.where(username: 'zone', password: 'ghyt9e4fu', active: true, registrar: zone).first_or_create
elkdata = Registrar.where(
name: 'Elkdata OÜ',
reg_no: '10510593',
address: 'Tondi 51-10, 11316 Tallinn'
).first_or_create
EppUser.where(username: 'elkdata', password: '8932iods', active: true, registrar: elkdata).first_or_create

View file

@ -1,7 +1,7 @@
require 'rails_helper'
describe 'EPP Domain', epp: true do
let(:server) { server = Epp::Server.new({ server: 'localhost', tag: 'gitlab', password: 'ghyt9e4fu', port: 701 }) }
let(:server) { Epp::Server.new({ server: 'localhost', tag: 'gitlab', password: 'ghyt9e4fu', port: 701 }) }
context 'with valid user' do
before(:each) do
@ -46,7 +46,6 @@ describe 'EPP Domain', epp: true do
d = Domain.first
dtl = d.domain_transfers.last
trn_data = response[:parsed].css('trnData')
expect(trn_data.css('name').text).to eq('example.ee')
expect(trn_data.css('trStatus').text).to eq('serverApproved')
@ -61,25 +60,28 @@ describe 'EPP Domain', epp: true do
response = epp_request(domain_transfer_xml, :xml)
trn_data = response[:parsed].css('trnData')
d = Domain.first
dtl = d.domain_transfers.last
expect(d.domain_transfers.count).to eq(2)
expect(trn_data.css('name').text).to eq('example.ee')
expect(trn_data.css('trStatus').text).to eq('pending')
expect(trn_data.css('reID').text).to eq('10577829')
req_time = dtl.transfer_requested_at.to_time.utc.to_s
expect(trn_data.css('reDate').text).to eq(req_time)
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('exDate').text).to eq(d.valid_to.to_time.utc.to_s)
# should return same data if pending already
response = epp_request(domain_transfer_xml, :xml)
trn_data = response[:parsed].css('trnData')
d = Domain.first
expect(d.domain_transfers.count).to eq(2)
expect(trn_data.css('name').text).to eq('example.ee')
expect(trn_data.css('trStatus').text).to eq('pending')
expect(trn_data.css('reID').text).to eq('10577829')
expect(trn_data.css('reDate').text).to eq(req_time)
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('exDate').text).to eq(d.valid_to.to_time.utc.to_s)
end
@ -196,7 +198,7 @@ describe 'EPP Domain', epp: true do
end
it 'creates domain with nameservers with ips' do
response = epp_request('domains/create_w_host_attrs.xml')
epp_request('domains/create_w_host_attrs.xml')
expect(Domain.first.nameservers.count).to eq(2)
ns = Domain.first.nameservers.first
expect(ns.ipv4).to eq('192.0.2.2')
@ -270,14 +272,14 @@ describe 'EPP Domain', epp: true do
end
context 'with valid domain' do
before(:each) { Fabricate(:domain, name: 'example.ee') }
before(:each) { Fabricate(:domain, name: 'example.ee', registrar: EppUser.first.registrar) }
it 'renews a domain' do
response = epp_request(domain_renew_xml, :xml)
exDate = response[:parsed].css('renData exDate').text
ex_date = response[:parsed].css('renData exDate').text
name = response[:parsed].css('renData name').text
expect(exDate).to eq ('2015-08-07 00:00:00 UTC')
expect(name).to eq ('example.ee')
expect(ex_date).to eq('2015-08-07 00:00:00 UTC')
expect(name).to eq('example.ee')
end
it 'returns an error when given and current exp dates do not match' do