mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 04:37:30 +02:00
make supporting version for schema
This commit is contained in:
parent
4917a2cb00
commit
1665e6e71e
11 changed files with 48 additions and 14 deletions
|
@ -5,7 +5,7 @@ xml.epp_head do
|
|||
end
|
||||
|
||||
xml.resData do
|
||||
xml.tag!('contact:infData', 'xmlns:contact' => Xsd::Schema.filename(for_prefix: 'contact-ee')) do
|
||||
xml.tag!('contact:infData', 'xmlns:contact' => Xsd::Schema.filename(for_prefix: 'contact-ee', for_version: '1.1')) do
|
||||
xml.tag!('contact:id', @contact.code)
|
||||
xml.tag!('contact:roid', @contact.roid)
|
||||
|
||||
|
@ -78,7 +78,7 @@ xml.epp_head do
|
|||
end
|
||||
if can? :view_full_info, @contact, @password
|
||||
xml.tag!('extension') do
|
||||
xml.tag!('eis:extdata', 'xmlns:eis' => Xsd::Schema.filename(for_prefix: 'eis')) do
|
||||
xml.tag!('eis:extdata', 'xmlns:eis' => Xsd::Schema.filename(for_prefix: 'eis', for_version: '1.0')) do
|
||||
xml.tag!('eis:ident', @contact.ident,
|
||||
type: @contact.ident_type, cc: @contact.ident_country_code)
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ xml.epp_head do
|
|||
|
||||
xml.resData do
|
||||
xml.tag!('domain:chkData',
|
||||
'xmlns:domain' => Xsd::Schema.filename(for_prefix: @schema_prefix)) do
|
||||
'xmlns:domain' => Xsd::Schema.filename(for_prefix: @schema_prefix, for_version: @schema_version)) do
|
||||
@domains.each do |x|
|
||||
xml.tag!('domain:cd') do
|
||||
xml.tag!('domain:name', x[:name], 'avail' => x[:avail])
|
||||
|
|
|
@ -6,7 +6,7 @@ xml.epp_head do
|
|||
|
||||
xml.resData do
|
||||
xml.tag!('domain:creData',
|
||||
'xmlns:domain' => Xsd::Schema.filename(for_prefix: @schema_prefix)) do
|
||||
'xmlns:domain' => Xsd::Schema.filename(for_prefix: @schema_prefix, for_version: @schema_version)) do
|
||||
xml.tag!('domain:name', @domain.name)
|
||||
xml.tag!('domain:crDate', @domain.created_at.try(:iso8601))
|
||||
xml.tag!('domain:exDate', @domain.valid_to.iso8601)
|
||||
|
|
|
@ -6,7 +6,7 @@ xml.epp_head do
|
|||
|
||||
xml.resData do
|
||||
xml.tag! 'domain:infData',
|
||||
'xmlns:domain' => Xsd::Schema.filename(for_prefix: @schema_prefix) do
|
||||
'xmlns:domain' => Xsd::Schema.filename(for_prefix: @schema_prefix, for_version: @schema_version) do
|
||||
xml.tag!('domain:name', @domain.name)
|
||||
xml.tag!('domain:roid', @domain.roid)
|
||||
@domain.statuses.each do |s|
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
builder.tag!('domain:trnData', 'xmlns:domain' => Xsd::Schema.filename(for_prefix: 'domain-ee')) do
|
||||
builder.tag!('domain:trnData', 'xmlns:domain' => Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: @schema_version)) do
|
||||
builder.tag!('domain:name', dt.domain_name)
|
||||
builder.tag!('domain:trStatus', dt.status)
|
||||
builder.tag!('domain:reID', dt.new_registrar.code)
|
||||
|
|
|
@ -6,7 +6,7 @@ xml.epp_head do
|
|||
|
||||
xml.resData do
|
||||
xml.tag!('domain:renData',
|
||||
'xmlns:domain' => Xsd::Schema.filename(for_prefix: @schema_prefix)) do
|
||||
'xmlns:domain' => Xsd::Schema.filename(for_prefix: @schema_prefix, for_version: @schema_version)) do
|
||||
xml.tag!('domain:name', @domain[:name])
|
||||
xml.tag!('domain:exDate', @domain.valid_to.iso8601)
|
||||
end
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
class EppConstraint
|
||||
OBJECT_TYPES = {
|
||||
domain: [
|
||||
{ domain: Xsd::Schema.filename(for_prefix: 'domain-ee') },
|
||||
{ domain: Xsd::Schema.filename(for_prefix: 'domain-eis') },
|
||||
{ domain: Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1') },
|
||||
{ domain: Xsd::Schema.filename(for_prefix: 'domain-eis', for_version: '1.0') },
|
||||
],
|
||||
contact: { contact: Xsd::Schema.filename(for_prefix: 'contact-ee') },
|
||||
}.freeze
|
||||
|
|
|
@ -19,11 +19,12 @@ module Xsd
|
|||
secDNS
|
||||
].freeze
|
||||
|
||||
attr_reader :xsd_schemas, :for_prefix
|
||||
attr_reader :xsd_schemas, :for_prefix, :for_version
|
||||
|
||||
def initialize(params)
|
||||
schema_path = params.fetch(:schema_path, SCHEMA_PATH)
|
||||
@for_prefix = params.fetch(:for_prefix)
|
||||
@for_version = params.fetch(:for_version, '1.1')
|
||||
@xsd_schemas = Dir.entries(schema_path).select { |f| File.file? File.join(schema_path, f) }
|
||||
end
|
||||
|
||||
|
@ -38,8 +39,40 @@ module Xsd
|
|||
|
||||
private
|
||||
|
||||
# xml = response.gsub!(/(?<=>)(.*?)(?=<)/, &:strip)
|
||||
# xml.to_s.match(/xmlns:domain=\"https:\/\/epp.tld.ee\/schema\/(?<prefix>\w+-\w+)-(?<version>\w.\w).xsd/)
|
||||
# The prefix and version of the response are returned are these variants - res[:prefix] res[:version]
|
||||
|
||||
def latest(prefix)
|
||||
schemas_by_name[prefix].last
|
||||
schemas = schemas_by_name[prefix]
|
||||
|
||||
actual_schema = ''
|
||||
|
||||
schemas.each do |schema|
|
||||
result = return_some(schema)
|
||||
|
||||
if result[:version] == @for_version
|
||||
actual_schema = schema
|
||||
end
|
||||
|
||||
if result[:prefix] == 'epp-ee'
|
||||
actual_schema = 'epp-ee-1.0.xsd'
|
||||
end
|
||||
|
||||
if result[:prefix] == 'eis'
|
||||
actual_schema = 'eis-1.0.xsd'
|
||||
end
|
||||
end
|
||||
|
||||
actual_schema
|
||||
end
|
||||
|
||||
def return_some(data)
|
||||
res = data.to_s.match(/(?<prefix>\w+-\w+)-(?<version>\w.\w).xsd/)
|
||||
|
||||
res = data.to_s.match(/(?<prefix>\w+)-(?<version>\w.\w).xsd/) if res.nil?
|
||||
|
||||
res
|
||||
end
|
||||
|
||||
def basename(filename)
|
||||
|
|
|
@ -38,6 +38,7 @@ class EppDomainCreateBaseTest < EppTestCase
|
|||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
assert_no_difference 'Domain.count' do
|
||||
post epp_create_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
|
|
|
@ -66,7 +66,7 @@ class EppDomainInfoBaseTest < EppTestCase
|
|||
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee')}">
|
||||
<command>
|
||||
<info>
|
||||
<domain:info xmlns:domain="#{Xsd::Schema.filename(for_prefix: 'domain-eis')}">
|
||||
<domain:info xmlns:domain="#{Xsd::Schema.filename(for_prefix: 'domain-eis', for_version: '1.0')}">
|
||||
<domain:name>shop.test</domain:name>
|
||||
</domain:info>
|
||||
</info>
|
||||
|
|
|
@ -8,13 +8,13 @@ class XsdSchemaTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_single_part_name
|
||||
filename = Xsd::Schema.filename(schema_path: @schema_path, for_prefix: 'abcde')
|
||||
filename = Xsd::Schema.filename(schema_path: @schema_path, for_prefix: 'abcde', for_version: '1.2')
|
||||
|
||||
assert_equal Xsd::Schema::BASE_URL + 'abcde-1.2.xsd', filename
|
||||
end
|
||||
|
||||
def test_double_part_name
|
||||
filename = Xsd::Schema.filename(schema_path: @schema_path, for_prefix: 'abcde-fghij')
|
||||
filename = Xsd::Schema.filename(schema_path: @schema_path, for_prefix: 'abcde-fghij', for_version: '1.3')
|
||||
|
||||
assert_equal Xsd::Schema::BASE_URL + 'abcde-fghij-1.3.xsd', filename
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue