request and response have the same domain schema

This commit is contained in:
Oleg Hasjanov 2021-06-22 12:59:56 +03:00
parent 230fb301a7
commit 6f431232f4
7 changed files with 28 additions and 8 deletions

View file

@ -4,6 +4,7 @@ module Epp
before_action :find_domain, only: %i[info renew update transfer delete]
before_action :find_password, only: %i[info update transfer delete]
before_action :set_paper_trail_whodunnit
before_action :parse_schemas_prefix_and_version
def info
authorize! :info, @domain
@ -243,5 +244,14 @@ module Epp
end
true
end
def parse_schemas_prefix_and_version
return unless params[:frame]
xml = params[:frame].gsub!(/(?<=>)(.*?)(?=<)/, &:strip).to_s
res = xml.match(/xmlns:domain=\"https:\/\/epp.tld.ee\/schema\/(?<prefix>\w+-\w+)-(?<version>\w.\w).xsd/)
@schema_version = res[:version]
@schema_prefix = res[:prefix]
end
end
end

View file

@ -5,7 +5,8 @@ xml.epp_head do
end
xml.resData do
xml.tag!('domain:chkData', 'xmlns:domain' => Xsd::Schema.filename(for_prefix: 'domain-ee')) do
xml.tag!('domain:chkData',
'xmlns:domain' => Xsd::Schema.filename(for_prefix: @schema_prefix)) do
@domains.each do |x|
xml.tag!('domain:cd') do
xml.tag!('domain:name', x[:name], 'avail' => x[:avail])

View file

@ -5,7 +5,8 @@ xml.epp_head do
end
xml.resData do
xml.tag!('domain:creData', 'xmlns:domain' => Xsd::Schema.filename(for_prefix: 'domain-ee')) do
xml.tag!('domain:creData',
'xmlns:domain' => Xsd::Schema.filename(for_prefix: @schema_prefix)) do
xml.tag!('domain:name', @domain.name)
xml.tag!('domain:crDate', @domain.created_at.try(:iso8601))
xml.tag!('domain:exDate', @domain.valid_to.iso8601)

View file

@ -5,7 +5,8 @@ xml.epp_head do
end
xml.resData do
xml.tag! 'domain:infData', 'xmlns:domain' => Xsd::Schema.filename(for_prefix: 'domain-ee') do
xml.tag! 'domain:infData',
'xmlns:domain' => Xsd::Schema.filename(for_prefix: @schema_prefix) do
xml.tag!('domain:name', @domain.name)
xml.tag!('domain:roid', @domain.roid)
@domain.statuses.each do |s|

View file

@ -5,7 +5,8 @@ xml.epp_head do
end
xml.resData do
xml.tag!('domain:renData', 'xmlns:domain' => Xsd::Schema.filename(for_prefix: 'domain-ee')) do
xml.tag!('domain:renData',
'xmlns:domain' => Xsd::Schema.filename(for_prefix: @schema_prefix)) do
xml.tag!('domain:name', @domain[:name])
xml.tag!('domain:exDate', @domain.valid_to.iso8601)
end