mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Validate legal doc type
This commit is contained in:
parent
00091c5502
commit
16df29ffc2
3 changed files with 38 additions and 1 deletions
|
@ -59,6 +59,13 @@ class EppController < ApplicationController
|
||||||
validation_method = "validate_#{params[:action]}"
|
validation_method = "validate_#{params[:action]}"
|
||||||
return unless respond_to?(validation_method, true)
|
return unless respond_to?(validation_method, true)
|
||||||
send(validation_method)
|
send(validation_method)
|
||||||
|
|
||||||
|
# validate legal document's type here because it may be in most of the requests
|
||||||
|
@prefix = nil
|
||||||
|
if element_count('extension > extdata > legalDocument') > 0
|
||||||
|
requires_attribute('extension > extdata > legalDocument', 'type', values: LegalDocument::TYPES)
|
||||||
|
end
|
||||||
|
|
||||||
handle_errors and return if epp_errors.any?
|
handle_errors and return if epp_errors.any?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
class LegalDocument < ActiveRecord::Base
|
class LegalDocument < ActiveRecord::Base
|
||||||
belongs_to :documentable, polymorphic: true
|
belongs_to :documentable, polymorphic: true
|
||||||
|
|
||||||
|
TYPES = %w(pdf bdoc ddoc zip rar gz tar 7z)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1420,6 +1420,35 @@ describe 'EPP Domain', epp: true do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'validates legal document type' do
|
||||||
|
xml = epp_xml.domain.info({
|
||||||
|
name: { value: domain.name }
|
||||||
|
}, {
|
||||||
|
_anonymus: [
|
||||||
|
legalDocument: {
|
||||||
|
value: 'JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0Zp==',
|
||||||
|
attrs: { type: 'jpg' }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
response = epp_plain_request(xml, :xml)
|
||||||
|
response[:msg].should == 'Attribute is invalid: type'
|
||||||
|
|
||||||
|
xml = epp_xml.domain.info({
|
||||||
|
name: { value: domain.name }
|
||||||
|
}, {
|
||||||
|
_anonymus: [
|
||||||
|
legalDocument: {
|
||||||
|
value: 'JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0Zp=='
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
response = epp_plain_request(xml, :xml)
|
||||||
|
response[:msg].should == 'Attribute is invalid: type'
|
||||||
|
end
|
||||||
|
|
||||||
### DELETE ###
|
### DELETE ###
|
||||||
it 'deletes domain' do
|
it 'deletes domain' do
|
||||||
response = epp_plain_request(epp_xml.domain.delete({
|
response = epp_plain_request(epp_xml.domain.delete({
|
||||||
|
@ -1537,7 +1566,6 @@ describe 'EPP Domain', epp: true do
|
||||||
name[:avail].should == '0'
|
name[:avail].should == '0'
|
||||||
reason.text.should == 'invalid format'
|
reason.text.should == 'invalid format'
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue