mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Domain transfer improvements, various test fixes
This commit is contained in:
parent
187316078b
commit
0adca73f88
5 changed files with 44 additions and 19 deletions
|
@ -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' }
|
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Martin does not want rubocop
|
||||||
|
unless Socket.gethostname == 'martin'
|
||||||
guard :rubocop do
|
guard :rubocop do
|
||||||
watch(%r{.+\.rb$})
|
watch(%r{.+\.rb$})
|
||||||
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -60,7 +60,7 @@ module Epp::DomainsHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def transfer_domain
|
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
|
||||||
handle_errors(@domain) and return unless @domain.transfer(domain_transfer_params)
|
handle_errors(@domain) and return unless @domain.transfer(domain_transfer_params)
|
||||||
|
@ -128,8 +128,10 @@ module Epp::DomainsHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
## SHARED
|
## SHARED
|
||||||
def find_domain
|
def find_domain(secure = { secure: true })
|
||||||
domain = Domain.find_by(name: @ph[:name])
|
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
|
unless domain
|
||||||
epp_errors << { code: '2303', msg: I18n.t('errors.messages.epp_domain_not_found'), value: { obj: 'name', val: @ph[:name] } }
|
epp_errors << { code: '2303', msg: I18n.t('errors.messages.epp_domain_not_found'), value: { obj: 'name', val: @ph[:name] } }
|
||||||
end
|
end
|
||||||
|
|
|
@ -205,6 +205,7 @@ class Domain < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
### TRANSFER ###
|
### TRANSFER ###
|
||||||
|
|
||||||
def transfer(params)
|
def transfer(params)
|
||||||
return false unless authenticate(params[:pw])
|
return false unless authenticate(params[:pw])
|
||||||
|
|
||||||
|
@ -212,6 +213,8 @@ class Domain < ActiveRecord::Base
|
||||||
approve_pending_transfer and return true
|
approve_pending_transfer and return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return true if pending_transfer
|
||||||
|
|
||||||
wait_time = SettingGroup.domain_general.setting(:transfer_wait_time).value.to_i
|
wait_time = SettingGroup.domain_general.setting(:transfer_wait_time).value.to_i
|
||||||
|
|
||||||
if wait_time > 0
|
if wait_time > 0
|
||||||
|
|
17
db/seeds.rb
17
db/seeds.rb
|
@ -7,4 +7,19 @@
|
||||||
# Mayor.create(name: 'Emanuel', city: cities.first)
|
# Mayor.create(name: 'Emanuel', city: cities.first)
|
||||||
|
|
||||||
Country.where(name: 'Estonia', iso: 'EE').first_or_create
|
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
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
describe 'EPP Domain', epp: true do
|
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
|
context 'with valid user' do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
|
@ -46,7 +46,6 @@ describe 'EPP Domain', epp: true do
|
||||||
|
|
||||||
d = Domain.first
|
d = Domain.first
|
||||||
dtl = d.domain_transfers.last
|
dtl = d.domain_transfers.last
|
||||||
|
|
||||||
trn_data = response[:parsed].css('trnData')
|
trn_data = response[:parsed].css('trnData')
|
||||||
expect(trn_data.css('name').text).to eq('example.ee')
|
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('serverApproved')
|
||||||
|
@ -61,25 +60,28 @@ describe 'EPP Domain', epp: true do
|
||||||
|
|
||||||
response = epp_request(domain_transfer_xml, :xml)
|
response = epp_request(domain_transfer_xml, :xml)
|
||||||
trn_data = response[:parsed].css('trnData')
|
trn_data = response[:parsed].css('trnData')
|
||||||
|
|
||||||
d = Domain.first
|
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('name').text).to eq('example.ee')
|
||||||
expect(trn_data.css('trStatus').text).to eq('pending')
|
expect(trn_data.css('trStatus').text).to eq('pending')
|
||||||
expect(trn_data.css('reID').text).to eq('10577829')
|
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(dtl.transfer_requested_at.to_time.utc.to_s)
|
||||||
expect(trn_data.css('reDate').text).to eq(req_time)
|
|
||||||
expect(trn_data.css('acID').text).to eq('10577829')
|
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)
|
expect(trn_data.css('exDate').text).to eq(d.valid_to.to_time.utc.to_s)
|
||||||
|
|
||||||
# should return same data if pending already
|
# should return same data if pending already
|
||||||
response = epp_request(domain_transfer_xml, :xml)
|
response = epp_request(domain_transfer_xml, :xml)
|
||||||
trn_data = response[:parsed].css('trnData')
|
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('name').text).to eq('example.ee')
|
||||||
expect(trn_data.css('trStatus').text).to eq('pending')
|
expect(trn_data.css('trStatus').text).to eq('pending')
|
||||||
expect(trn_data.css('reID').text).to eq('10577829')
|
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('acID').text).to eq('10577829')
|
||||||
expect(trn_data.css('exDate').text).to eq(d.valid_to.to_time.utc.to_s)
|
expect(trn_data.css('exDate').text).to eq(d.valid_to.to_time.utc.to_s)
|
||||||
end
|
end
|
||||||
|
@ -196,7 +198,7 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates domain with nameservers with ips' do
|
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)
|
expect(Domain.first.nameservers.count).to eq(2)
|
||||||
ns = Domain.first.nameservers.first
|
ns = Domain.first.nameservers.first
|
||||||
expect(ns.ipv4).to eq('192.0.2.2')
|
expect(ns.ipv4).to eq('192.0.2.2')
|
||||||
|
@ -270,14 +272,14 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with valid domain' do
|
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
|
it 'renews a domain' do
|
||||||
response = epp_request(domain_renew_xml, :xml)
|
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
|
name = response[:parsed].css('renData name').text
|
||||||
expect(exDate).to eq ('2015-08-07 00:00:00 UTC')
|
expect(ex_date).to eq('2015-08-07 00:00:00 UTC')
|
||||||
expect(name).to eq ('example.ee')
|
expect(name).to eq('example.ee')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns an error when given and current exp dates do not match' do
|
it 'returns an error when given and current exp dates do not match' do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue