mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 20:55:44 +02:00
refactoring
This commit is contained in:
parent
93f9eff20d
commit
539cebe7ec
4 changed files with 34 additions and 10 deletions
|
@ -3,6 +3,22 @@ module Xsd
|
||||||
SCHEMA_PATH = 'lib/schemas/'.freeze
|
SCHEMA_PATH = 'lib/schemas/'.freeze
|
||||||
BASE_URL = 'https://epp.tld.ee/schema/'.freeze
|
BASE_URL = 'https://epp.tld.ee/schema/'.freeze
|
||||||
|
|
||||||
|
PREFIXES = %w[
|
||||||
|
domain-eis
|
||||||
|
all-ee
|
||||||
|
changePoll
|
||||||
|
airport
|
||||||
|
contact
|
||||||
|
contact-ee
|
||||||
|
contact-eis
|
||||||
|
eis
|
||||||
|
epp
|
||||||
|
epp-ee
|
||||||
|
eppcom
|
||||||
|
host
|
||||||
|
secDNS
|
||||||
|
].freeze
|
||||||
|
|
||||||
attr_reader :xsd_schemas, :for_prefix
|
attr_reader :xsd_schemas, :for_prefix
|
||||||
|
|
||||||
def initialize(params)
|
def initialize(params)
|
||||||
|
|
|
@ -26,10 +26,8 @@ class EppDomainInfoBaseTest < EppTestCase
|
||||||
|
|
||||||
response_xml = Nokogiri::XML(response.body)
|
response_xml = Nokogiri::XML(response.body)
|
||||||
|
|
||||||
schema_version = return_xml_domain_schema_version(response_xml)
|
|
||||||
|
|
||||||
assert_epp_response :completed_successfully
|
assert_epp_response :completed_successfully
|
||||||
assert schema_version >= 1.1
|
assert assert_schema_is_bigger(response_xml, 'domain-eis', 1.1)
|
||||||
assert_equal 'shop.test', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text
|
assert_equal 'shop.test', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text
|
||||||
assert_equal 'ok', response_xml.at_xpath('//domain:status', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}")['s']
|
assert_equal 'ok', response_xml.at_xpath('//domain:status', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}")['s']
|
||||||
assert_equal 'john-001', response_xml.at_xpath('//domain:registrant', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text
|
assert_equal 'john-001', response_xml.at_xpath('//domain:registrant', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text
|
||||||
|
|
|
@ -18,5 +18,4 @@ class XsdSchemaTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
assert_equal Xsd::Schema::BASE_URL + 'abcde-fghij-1.3.xsd', filename
|
assert_equal Xsd::Schema::BASE_URL + 'abcde-fghij-1.3.xsd', filename
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -69,12 +69,23 @@ end
|
||||||
class EppTestCase < ActionDispatch::IntegrationTest
|
class EppTestCase < ActionDispatch::IntegrationTest
|
||||||
include Assertions::EppAssertions
|
include Assertions::EppAssertions
|
||||||
|
|
||||||
def return_xml_domain_schema_version(response_xml)
|
def assert_schema_is_bigger(response_xml, prefix, version)
|
||||||
version_regex = /-\d+\S\d+/
|
schema_version = prefix_schema_tag(prefix, response_xml)
|
||||||
domain_schema_tag = response_xml.to_s.scan(/xmlns:domain\S+/)
|
|
||||||
schema_path = domain_schema_tag.to_s.match(%r{https?://\S+})[0]
|
|
||||||
version = schema_path.to_s.match(version_regex)[0]
|
|
||||||
|
|
||||||
-version.to_f
|
assert schema_version >= version
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def prefix_schema_tag(prefix, response_xml)
|
||||||
|
if Xsd::Schema::PREFIXES.include? prefix
|
||||||
|
version_regex = /-\d+\S\d+/
|
||||||
|
domain_schema_tag = response_xml.to_s.scan(%r{https://epp.tld.ee/schema/#{prefix}\S+})
|
||||||
|
version = domain_schema_tag.to_s.match(version_regex)[0]
|
||||||
|
|
||||||
|
-version.to_f
|
||||||
|
else
|
||||||
|
raise Exception.new('Wrong prefix')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue