mirror of
https://github.com/internetee/registry.git
synced 2025-06-04 03:37:28 +02:00
updated respons for wrong path
This commit is contained in:
parent
60ad69fc5b
commit
ad23a7cbd2
3 changed files with 25 additions and 1 deletions
|
@ -127,6 +127,7 @@ module Epp
|
||||||
# VALIDATION
|
# VALIDATION
|
||||||
def validate_request
|
def validate_request
|
||||||
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)
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ class Registrar
|
||||||
def create
|
def create
|
||||||
begin
|
begin
|
||||||
@result = depp_current_user.server.request(params[:payload])
|
@result = depp_current_user.server.request(params[:payload])
|
||||||
|
checking_schema_valid_path(params[:payload])
|
||||||
rescue
|
rescue
|
||||||
@result = 'CONNECTION ERROR - Is the EPP server running?'
|
@result = 'CONNECTION ERROR - Is the EPP server running?'
|
||||||
end
|
end
|
||||||
|
@ -20,6 +21,29 @@ class Registrar
|
||||||
xml = File.read("#{xml_dir_path}/#{params[:obj]}/#{params[:epp_action]}.xml")
|
xml = File.read("#{xml_dir_path}/#{params[:obj]}/#{params[:epp_action]}.xml")
|
||||||
xml.gsub!('<clTRID>ABC-12345</clTRID>', "<clTRID>#{cl_trid}</clTRID>")
|
xml.gsub!('<clTRID>ABC-12345</clTRID>', "<clTRID>#{cl_trid}</clTRID>")
|
||||||
render plain: xml
|
render plain: xml
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def checking_schema_valid_path(payload)
|
||||||
|
path = regex_to_find_domain_schema(payload)
|
||||||
|
|
||||||
|
@result = template_wrong_path unless array_valid_paths.include? path
|
||||||
|
end
|
||||||
|
|
||||||
|
def array_valid_paths
|
||||||
|
Xsd::Schema::PREFIXES.map{|prefix| Xsd::Schema.filename(for_prefix: prefix)}
|
||||||
|
end
|
||||||
|
|
||||||
|
def template_wrong_path
|
||||||
|
'Wrong schema path'
|
||||||
|
end
|
||||||
|
|
||||||
|
def regex_to_find_domain_schema(payload)
|
||||||
|
domain_schema_tag = payload.scan(/xmlns:domain[\S]+/)
|
||||||
|
schema_path = domain_schema_tag.to_s.match(/https?:\/\/[\S]+/)[0]
|
||||||
|
path = schema_path.split('\\')[0]
|
||||||
|
path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,6 @@ module Xsd
|
||||||
domain-eis
|
domain-eis
|
||||||
all-ee
|
all-ee
|
||||||
changePoll
|
changePoll
|
||||||
airport
|
|
||||||
contact
|
contact
|
||||||
contact-ee
|
contact-ee
|
||||||
contact-eis
|
contact-eis
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue