mirror of
https://github.com/internetee/registry.git
synced 2025-05-30 09:30:03 +02:00
commit
9a196c445e
7 changed files with 127 additions and 3 deletions
|
@ -27,7 +27,7 @@ class Epp::SessionsController < EppController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if !webclient_request && @api_user
|
if !Rails.env.development? && (!webclient_request && @api_user)
|
||||||
unless @api_user.api_pki_ok?(request.env['HTTP_SSL_CLIENT_CERT'], request.env['HTTP_SSL_CLIENT_S_DN_CN'])
|
unless @api_user.api_pki_ok?(request.env['HTTP_SSL_CLIENT_CERT'], request.env['HTTP_SSL_CLIENT_S_DN_CN'])
|
||||||
epp_errors << {
|
epp_errors << {
|
||||||
msg: 'Authentication error; server closing connection (certificate is not valid)',
|
msg: 'Authentication error; server closing connection (certificate is not valid)',
|
||||||
|
|
|
@ -97,7 +97,7 @@ class EppController < ApplicationController
|
||||||
e_s = epp_session
|
e_s = epp_session
|
||||||
return if e_s.new_record?
|
return if e_s.new_record?
|
||||||
|
|
||||||
if e_s.updated_at < Time.zone.now - 5.minutes
|
if !Rails.env.development? && (e_s.updated_at < Time.zone.now - 5.minutes)
|
||||||
@api_user = current_user # cache current_user for logging
|
@api_user = current_user # cache current_user for logging
|
||||||
e_s.destroy
|
e_s.destroy
|
||||||
response.headers['X-EPP-Returncode'] = '1500'
|
response.headers['X-EPP-Returncode'] = '1500'
|
||||||
|
|
|
@ -601,7 +601,18 @@ class Epp::Domain < Domain
|
||||||
return false if errors.any?
|
return false if errors.any?
|
||||||
|
|
||||||
p = self.class.convert_period_to_time(period, unit)
|
p = self.class.convert_period_to_time(period, unit)
|
||||||
self.valid_to = valid_to + p
|
renewed_expire_time = valid_to + p
|
||||||
|
|
||||||
|
# Change it when Pricelist model periods change
|
||||||
|
max_reg_time = 4.years.from_now
|
||||||
|
|
||||||
|
if renewed_expire_time >= max_reg_time
|
||||||
|
add_epp_error('2105', nil, nil, I18n.t('epp.domains.object_is_not_eligible_for_renewal',
|
||||||
|
max_date: max_reg_time.to_date.to_s(:db)))
|
||||||
|
return false if errors.any?
|
||||||
|
end
|
||||||
|
|
||||||
|
self.valid_to = renewed_expire_time
|
||||||
self.outzone_at = nil
|
self.outzone_at = nil
|
||||||
self.delete_at = nil
|
self.delete_at = nil
|
||||||
self.period = period
|
self.period = period
|
||||||
|
|
4
config/locales/epp/domains.en.yml
Normal file
4
config/locales/epp/domains.en.yml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
en:
|
||||||
|
epp:
|
||||||
|
domains:
|
||||||
|
object_is_not_eligible_for_renewal: Object is not eligible for renewal; Expiration date must be before %{max_date}
|
7
spec/factories/account.rb
Normal file
7
spec/factories/account.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :account do
|
||||||
|
account_type Account::CASH
|
||||||
|
balance 1
|
||||||
|
currency 'EUR'
|
||||||
|
end
|
||||||
|
end
|
10
spec/factories/pricelist.rb
Normal file
10
spec/factories/pricelist.rb
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :pricelist do
|
||||||
|
valid_from Time.zone.parse('05.07.2010')
|
||||||
|
valid_to Time.zone.parse('05.07.2010')
|
||||||
|
category 'com'
|
||||||
|
duration '1year'
|
||||||
|
operation_category 'create'
|
||||||
|
price 1.to_money
|
||||||
|
end
|
||||||
|
end
|
92
spec/requests/epp/domain/renew_spec.rb
Normal file
92
spec/requests/epp/domain/renew_spec.rb
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe 'EPP domain:renew' do
|
||||||
|
let(:user) { FactoryGirl.create(:api_user_epp, registrar: registrar) }
|
||||||
|
let(:registrar) { FactoryGirl.create(:registrar) }
|
||||||
|
subject(:response_xml) { Nokogiri::XML(response.body) }
|
||||||
|
subject(:response_code) { response_xml.xpath('//xmlns:result').first['code'] }
|
||||||
|
subject(:response_description) { response_xml.css('result msg').text }
|
||||||
|
|
||||||
|
before do
|
||||||
|
travel_to Time.zone.parse('05.07.2010')
|
||||||
|
sign_in_to_epp_area(user: user)
|
||||||
|
FactoryGirl.create(:account, registrar: registrar, balance: 1)
|
||||||
|
Setting.days_to_renew_domain_before_expire = 0
|
||||||
|
|
||||||
|
FactoryGirl.create(:pricelist,
|
||||||
|
category: 'com',
|
||||||
|
duration: '3years',
|
||||||
|
price: 1.to_money,
|
||||||
|
operation_category: 'renew',
|
||||||
|
valid_from: Time.zone.parse('05.07.2010'),
|
||||||
|
valid_to: Time.zone.parse('05.07.2010')
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when domain can be renewed' do
|
||||||
|
let!(:domain) { FactoryGirl.create(:domain,
|
||||||
|
registrar: registrar,
|
||||||
|
name: 'test.com',
|
||||||
|
expire_time: Time.zone.parse('05.07.2010'))
|
||||||
|
}
|
||||||
|
let(:request_xml) { <<-XML
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||||
|
<command>
|
||||||
|
<renew>
|
||||||
|
<domain:renew xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||||
|
<domain:name>test.com</domain:name>
|
||||||
|
<domain:curExpDate>2010-07-05</domain:curExpDate>
|
||||||
|
<domain:period unit="y">3</domain:period>
|
||||||
|
</domain:renew>
|
||||||
|
</renew>
|
||||||
|
</command>
|
||||||
|
</epp>
|
||||||
|
XML
|
||||||
|
}
|
||||||
|
|
||||||
|
it 'returns epp code of 1000' do
|
||||||
|
post '/epp/command/renew', frame: request_xml
|
||||||
|
expect(response_code).to eq('1000')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns epp description' do
|
||||||
|
post '/epp/command/renew', frame: request_xml
|
||||||
|
expect(response_description).to eq('Command completed successfully')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when domain cannot be renewed' do
|
||||||
|
let!(:domain) { FactoryGirl.create(:domain,
|
||||||
|
registrar: registrar,
|
||||||
|
name: 'test.com',
|
||||||
|
expire_time: Time.zone.parse('05.07.2011'))
|
||||||
|
}
|
||||||
|
let(:request_xml) { <<-XML
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||||
|
<command>
|
||||||
|
<renew>
|
||||||
|
<domain:renew xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||||
|
<domain:name>test.com</domain:name>
|
||||||
|
<domain:curExpDate>2011-07-05</domain:curExpDate>
|
||||||
|
<domain:period unit="y">3</domain:period>
|
||||||
|
</domain:renew>
|
||||||
|
</renew>
|
||||||
|
</command>
|
||||||
|
</epp>
|
||||||
|
XML
|
||||||
|
}
|
||||||
|
|
||||||
|
it 'returns epp code of 2105' do
|
||||||
|
post '/epp/command/renew', frame: request_xml
|
||||||
|
expect(response_code).to eq('2105')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns epp description' do
|
||||||
|
post '/epp/command/renew', frame: request_xml
|
||||||
|
expect(response_description).to eq('Object is not eligible for renewal; ' \
|
||||||
|
'Expiration date must be before 2014-07-05')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue