mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 01:17:18 +02:00
Merge branch 'registry-430' into registry-475
This commit is contained in:
commit
5fdc1938af
8 changed files with 207 additions and 59 deletions
|
@ -105,29 +105,36 @@ class Epp::DomainsController < EppController
|
||||||
|
|
||||||
balance_ok?('renew', period, period_unit) # loading pricelist
|
balance_ok?('renew', period, period_unit) # loading pricelist
|
||||||
|
|
||||||
ActiveRecord::Base.transaction do
|
begin
|
||||||
success = @domain.renew(
|
ActiveRecord::Base.transaction(isolation: :serializable) do
|
||||||
params[:parsed_frame].css('curExpDate').text,
|
@domain.reload
|
||||||
period, period_unit
|
|
||||||
)
|
|
||||||
|
|
||||||
if success
|
success = @domain.renew(
|
||||||
unless balance_ok?('renew', period, period_unit)
|
params[:parsed_frame].css('curExpDate').text,
|
||||||
handle_errors
|
period, period_unit
|
||||||
fail ActiveRecord::Rollback
|
)
|
||||||
|
|
||||||
|
if success
|
||||||
|
unless balance_ok?('renew', period, period_unit)
|
||||||
|
handle_errors
|
||||||
|
fail ActiveRecord::Rollback
|
||||||
|
end
|
||||||
|
|
||||||
|
current_user.registrar.debit!({
|
||||||
|
sum: @domain_pricelist.price.amount,
|
||||||
|
description: "#{I18n.t('renew')} #{@domain.name}",
|
||||||
|
activity_type: AccountActivity::RENEW,
|
||||||
|
log_pricelist_id: @domain_pricelist.id
|
||||||
|
})
|
||||||
|
|
||||||
|
render_epp_response '/epp/domains/renew'
|
||||||
|
else
|
||||||
|
handle_errors(@domain)
|
||||||
end
|
end
|
||||||
|
|
||||||
current_user.registrar.debit!({
|
|
||||||
sum: @domain_pricelist.price.amount,
|
|
||||||
description: "#{I18n.t('renew')} #{@domain.name}",
|
|
||||||
activity_type: AccountActivity::RENEW,
|
|
||||||
log_pricelist_id: @domain_pricelist.id
|
|
||||||
})
|
|
||||||
|
|
||||||
render_epp_response '/epp/domains/renew'
|
|
||||||
else
|
|
||||||
handle_errors(@domain)
|
|
||||||
end
|
end
|
||||||
|
rescue ActiveRecord::StatementInvalid => e
|
||||||
|
sleep rand / 100
|
||||||
|
retry
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -18,11 +18,6 @@ api_log_development:
|
||||||
<<: *default
|
<<: *default
|
||||||
database: registry_api_log_development
|
database: registry_api_log_development
|
||||||
|
|
||||||
registrant_write_development:
|
|
||||||
<<: *default
|
|
||||||
database: registry_development
|
|
||||||
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
<<: *default
|
<<: *default
|
||||||
database: registry_test
|
database: registry_test
|
||||||
|
@ -34,8 +29,3 @@ whois_test:
|
||||||
api_log_test:
|
api_log_test:
|
||||||
<<: *default
|
<<: *default
|
||||||
database: registry_api_log_test
|
database: registry_api_log_test
|
||||||
|
|
||||||
registrant_write_test:
|
|
||||||
<<: *default
|
|
||||||
database: registry_test
|
|
||||||
|
|
||||||
|
|
|
@ -25,14 +25,6 @@ staging:
|
||||||
username: registrant_read_only
|
username: registrant_read_only
|
||||||
password: registrant_read_only_pwd
|
password: registrant_read_only_pwd
|
||||||
|
|
||||||
registrant_write_staging:
|
|
||||||
<<: *default
|
|
||||||
database: registry_development # registry real database
|
|
||||||
host: localhost
|
|
||||||
username: registrant_write # user should have write access only to registrant_verifications table
|
|
||||||
password: registrant_write_pwd
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Production config for Registrant
|
# Production config for Registrant
|
||||||
#
|
#
|
||||||
|
@ -43,10 +35,3 @@ production:
|
||||||
host: localhost # registry production mirror location
|
host: localhost # registry production mirror location
|
||||||
username: registrant_read_only
|
username: registrant_read_only
|
||||||
password: registrant_read_only_pwd
|
password: registrant_read_only_pwd
|
||||||
|
|
||||||
registrant_write_production:
|
|
||||||
<<: *default
|
|
||||||
database: registry_production # registry production database name
|
|
||||||
host: localhost # registry database location
|
|
||||||
username: registrant_write # user should have write access only to registrant_verifications table
|
|
||||||
password: registrant_write_pwd
|
|
||||||
|
|
|
@ -18,11 +18,6 @@ api_log_test:
|
||||||
<<: *default
|
<<: *default
|
||||||
database: registry_api_log_test
|
database: registry_api_log_test
|
||||||
|
|
||||||
registrant_write_test:
|
|
||||||
<<: *default
|
|
||||||
database: registry_test
|
|
||||||
|
|
||||||
# only for testing assets
|
|
||||||
production:
|
production:
|
||||||
<<: *default
|
<<: *default
|
||||||
database: registry_test
|
database: registry_test
|
||||||
|
@ -34,7 +29,3 @@ whois_test:
|
||||||
api_log_test:
|
api_log_test:
|
||||||
<<: *default
|
<<: *default
|
||||||
database: registry_api_log_test
|
database: registry_api_log_test
|
||||||
|
|
||||||
registrant_write_test:
|
|
||||||
<<: *default
|
|
||||||
database: registry_test
|
|
||||||
|
|
|
@ -17,7 +17,3 @@ whois_test:
|
||||||
api_log_test:
|
api_log_test:
|
||||||
<<: *default
|
<<: *default
|
||||||
database: registry_api_log_test
|
database: registry_api_log_test
|
||||||
|
|
||||||
registrant_write_test:
|
|
||||||
<<: *default
|
|
||||||
database: registry_test
|
|
||||||
|
|
90
spec/requests/epp/domain/renew/account_balance_spec.rb
Normal file
90
spec/requests/epp/domain/renew/account_balance_spec.rb
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe 'EPP domain:renew' do
|
||||||
|
let(:request) { post '/epp/command/renew', frame: request_xml }
|
||||||
|
let!(:user) { create(:api_user_epp, registrar: registrar) }
|
||||||
|
let!(:pricelist) { create(:pricelist,
|
||||||
|
category: 'com',
|
||||||
|
duration: '1year',
|
||||||
|
price: Money.from_amount(1),
|
||||||
|
operation_category: 'renew',
|
||||||
|
valid_from: Time.zone.parse('05.07.2010'),
|
||||||
|
valid_to: Time.zone.parse('05.07.2010'))
|
||||||
|
}
|
||||||
|
|
||||||
|
before :example do
|
||||||
|
Setting.days_to_renew_domain_before_expire = 0
|
||||||
|
travel_to Time.zone.parse('05.07.2010')
|
||||||
|
sign_in_to_epp_area(user: user)
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when account balance is sufficient' do
|
||||||
|
let!(:registrar) { create(:registrar_with_unlimited_balance) }
|
||||||
|
let!(:domain) { 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">1</domain:period>
|
||||||
|
</domain:renew>
|
||||||
|
</renew>
|
||||||
|
</command>
|
||||||
|
</epp>
|
||||||
|
XML
|
||||||
|
}
|
||||||
|
|
||||||
|
it 'renews domain' do
|
||||||
|
request
|
||||||
|
domain.reload
|
||||||
|
expect(domain.expire_time).to eq(Time.zone.parse('05.07.2011'))
|
||||||
|
end
|
||||||
|
|
||||||
|
specify do
|
||||||
|
request
|
||||||
|
expect(response).to have_code_of(1000)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when account balance is not sufficient' do
|
||||||
|
let!(:registrar) { create(:registrar_with_zero_balance) }
|
||||||
|
let!(:domain) { 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-04</domain:curExpDate>
|
||||||
|
<domain:period unit="y">1</domain:period>
|
||||||
|
</domain:renew>
|
||||||
|
</renew>
|
||||||
|
</command>
|
||||||
|
</epp>
|
||||||
|
XML
|
||||||
|
}
|
||||||
|
|
||||||
|
it 'does not renew domain' do
|
||||||
|
request
|
||||||
|
domain.reload
|
||||||
|
expect(domain.expire_time).to eq(Time.zone.parse('05.07.2010'))
|
||||||
|
end
|
||||||
|
|
||||||
|
specify do
|
||||||
|
request
|
||||||
|
expect(response).to have_code_of(2104)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
89
spec/requests/epp/domain/renew/expire_time_spec.rb
Normal file
89
spec/requests/epp/domain/renew/expire_time_spec.rb
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe 'EPP domain:renew' do
|
||||||
|
let(:request) { post '/epp/command/renew', frame: request_xml }
|
||||||
|
let!(:user) { create(:api_user_epp, registrar: registrar) }
|
||||||
|
let!(:registrar) { create(:registrar_with_unlimited_balance) }
|
||||||
|
let!(:pricelist) { create(:pricelist,
|
||||||
|
category: 'com',
|
||||||
|
duration: '1year',
|
||||||
|
price: Money.from_amount(1),
|
||||||
|
operation_category: 'renew',
|
||||||
|
valid_from: Time.zone.parse('05.07.2010'),
|
||||||
|
valid_to: Time.zone.parse('05.07.2010'))
|
||||||
|
}
|
||||||
|
|
||||||
|
before :example do
|
||||||
|
Setting.days_to_renew_domain_before_expire = 0
|
||||||
|
travel_to Time.zone.parse('05.07.2010')
|
||||||
|
sign_in_to_epp_area(user: user)
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when given expire time and current match' do
|
||||||
|
let!(:domain) { 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">1</domain:period>
|
||||||
|
</domain:renew>
|
||||||
|
</renew>
|
||||||
|
</command>
|
||||||
|
</epp>
|
||||||
|
XML
|
||||||
|
}
|
||||||
|
|
||||||
|
it 'renews domain' do
|
||||||
|
request
|
||||||
|
domain.reload
|
||||||
|
expect(domain.expire_time).to eq(Time.zone.parse('05.07.2011'))
|
||||||
|
end
|
||||||
|
|
||||||
|
specify do
|
||||||
|
request
|
||||||
|
expect(response).to have_code_of(1000)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when given expire time and current do not match' do
|
||||||
|
let!(:domain) { 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-04</domain:curExpDate>
|
||||||
|
<domain:period unit="y">1</domain:period>
|
||||||
|
</domain:renew>
|
||||||
|
</renew>
|
||||||
|
</command>
|
||||||
|
</epp>
|
||||||
|
XML
|
||||||
|
}
|
||||||
|
|
||||||
|
it 'does not renew domain' do
|
||||||
|
request
|
||||||
|
domain.reload
|
||||||
|
expect(domain.expire_time).to eq(Time.zone.parse('05.07.2010'))
|
||||||
|
end
|
||||||
|
|
||||||
|
specify do
|
||||||
|
request
|
||||||
|
expect(response).to have_code_of(2306)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -7,7 +7,7 @@ RSpec.describe 'EPP domain:renew' do
|
||||||
subject(:response_code) { response_xml.xpath('//xmlns:result').first['code'] }
|
subject(:response_code) { response_xml.xpath('//xmlns:result').first['code'] }
|
||||||
subject(:response_description) { response_xml.css('result msg').text }
|
subject(:response_description) { response_xml.css('result msg').text }
|
||||||
|
|
||||||
before do
|
before :example do
|
||||||
travel_to Time.zone.parse('05.07.2010')
|
travel_to Time.zone.parse('05.07.2010')
|
||||||
sign_in_to_epp_area(user: user)
|
sign_in_to_epp_area(user: user)
|
||||||
FactoryGirl.create(:account, registrar: registrar, balance: 1)
|
FactoryGirl.create(:account, registrar: registrar, balance: 1)
|
Loading…
Add table
Add a link
Reference in a new issue