mirror of
https://github.com/internetee/registry.git
synced 2025-07-01 16:53:37 +02:00
Validate period attribute on domain create #2763
This commit is contained in:
parent
7a8c7dd39e
commit
e46484405e
2 changed files with 38 additions and 0 deletions
|
@ -161,6 +161,8 @@ class Epp::DomainsController < EppController
|
|||
@prefix = nil
|
||||
requires 'extension > extdata > legalDocument'
|
||||
|
||||
optional_attribute 'period', 'unit', values: %w(d m y)
|
||||
|
||||
status_editing_disabled
|
||||
end
|
||||
|
||||
|
|
|
@ -435,6 +435,24 @@ describe 'EPP Domain', epp: true do
|
|||
a.activity_type = AccountActivity::CREATE
|
||||
end
|
||||
|
||||
it 'creates a domain without period' do
|
||||
old_balance = @registrar1.balance
|
||||
old_activities = @registrar1.cash_account.account_activities.count
|
||||
xml = domain_create_xml(period: nil)
|
||||
|
||||
response = epp_plain_request(xml)
|
||||
response[:msg].should == 'Command completed successfully'
|
||||
response[:result_code].should == '1000'
|
||||
Domain.last.valid_to.should be_within(60).of(1.years.since)
|
||||
@registrar1.balance.should be < old_balance
|
||||
@registrar1.cash_account.account_activities.count.should == old_activities + 1
|
||||
a = @registrar1.cash_account.account_activities.last
|
||||
a.description.should == "Create #{Domain.last.name}"
|
||||
a.sum.should == -BigDecimal.new('10.0')
|
||||
a.activity_type = AccountActivity::CREATE
|
||||
a.log_pricelist_id.should == @pricelist_reg_1_year.id
|
||||
end
|
||||
|
||||
it 'does not create a domain with invalid period' do
|
||||
old_balance = @registrar1.balance
|
||||
old_activities = @registrar1.cash_account.account_activities.count
|
||||
|
@ -450,6 +468,24 @@ describe 'EPP Domain', epp: true do
|
|||
@registrar1.cash_account.account_activities.count.should == old_activities
|
||||
end
|
||||
|
||||
it 'does not create a domain with invalid period unit' do
|
||||
xml = domain_create_xml({
|
||||
period: { value: '1', attrs: { unit: '' } }
|
||||
})
|
||||
|
||||
response = epp_plain_request(xml, validate_input: false)
|
||||
response[:results][0][:msg].should == 'Attribute is invalid: unit'
|
||||
response[:results][0][:result_code].should == '2306'
|
||||
|
||||
xml = domain_create_xml({
|
||||
period: { value: '1', attrs: { unit: 'bla' } }
|
||||
})
|
||||
|
||||
response = epp_plain_request(xml, validate_input: false)
|
||||
response[:results][0][:msg].should == 'Attribute is invalid: unit'
|
||||
response[:results][0][:result_code].should == '2306'
|
||||
end
|
||||
|
||||
it 'creates a domain with multiple dnskeys' do
|
||||
xml = domain_create_xml({}, {
|
||||
_anonymus: [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue