mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 12:47:29 +02:00
added test, connect epp-xml another branch in gemfile, made domain object as array
This commit is contained in:
parent
6b9c9754de
commit
b7c0a6c4c9
5 changed files with 94 additions and 27 deletions
|
@ -1,7 +1,10 @@
|
|||
class EppConstraint
|
||||
OBJECT_TYPES = {
|
||||
domain: { domain: Xsd::Schema.filename(for_prefix: 'domain-ee') },
|
||||
contact: { contact: Xsd::Schema.filename(for_prefix: 'contact-ee') },
|
||||
domain: [
|
||||
{ domain: Xsd::Schema.filename(for_prefix: 'domain-ee') },
|
||||
{ domain: Xsd::Schema.filename(for_prefix: 'domain-eis') }
|
||||
],
|
||||
contact: { contact: Xsd::Schema.filename(for_prefix: 'contact-ee') }
|
||||
}.freeze
|
||||
|
||||
def initialize(type)
|
||||
|
@ -13,13 +16,25 @@ class EppConstraint
|
|||
# TODO: Maybe move this to controller to keep params clean
|
||||
return redirect_to_error_controller(request) if request.params[:action] == 'wrong_schema'
|
||||
|
||||
request.params[:raw_frame] = request.params[:raw_frame].gsub!(/(?<=>)(.*?)(?=<)/) { |s| s.strip} if request.params[:raw_frame]
|
||||
if request.params[:raw_frame]
|
||||
request.params[:raw_frame] = request.params[:raw_frame].gsub!(/(?<=>)(.*?)(?=<)/) do |s|
|
||||
s.strip
|
||||
end
|
||||
end
|
||||
request.params[:nokogiri_frame] ||= Nokogiri::XML(request.params[:raw_frame] || request.params[:frame])
|
||||
request.params[:parsed_frame] ||= request.params[:nokogiri_frame].dup.remove_namespaces!
|
||||
|
||||
unless %i[poll session].include?(@type)
|
||||
element = "//#{@type}:#{request.params[:action]}"
|
||||
return false if request.params[:nokogiri_frame].xpath("#{element}", OBJECT_TYPES[@type]).none?
|
||||
|
||||
if @type == :domain
|
||||
OBJECT_TYPES[@type].each do |obj|
|
||||
return true unless request.params[:nokogiri_frame].xpath(element.to_s, obj).none?
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
return false if request.params[:nokogiri_frame].xpath(element.to_s, OBJECT_TYPES[@type]).none?
|
||||
end
|
||||
|
||||
request.params[:epp_object_type] = @type
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue