mirror of
https://github.com/internetee/registry.git
synced 2025-06-06 04:37:30 +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
2
Gemfile
2
Gemfile
|
@ -62,7 +62,7 @@ gem 'omniauth-tara', github: 'internetee/omniauth-tara'
|
|||
|
||||
|
||||
gem 'epp', github: 'internetee/epp', branch: :master
|
||||
gem 'epp-xml', '1.1.0', github: 'internetee/epp-xml', branch: 'update-paths-for-new-domain-schema'
|
||||
gem 'epp-xml', '1.2.0', github: 'internetee/epp-xml', branch: '11-flexible-paths-for-schemes'
|
||||
gem 'que'
|
||||
gem 'daemons-rails', '1.2.1'
|
||||
gem 'que-web'
|
||||
|
|
10
Gemfile.lock
10
Gemfile.lock
|
@ -28,10 +28,10 @@ GIT
|
|||
|
||||
GIT
|
||||
remote: https://github.com/internetee/epp-xml.git
|
||||
revision: 687514dc239d22b29d0138d83c909d70d19dc06d
|
||||
branch: update-paths-for-new-domain-schema
|
||||
revision: b821c16a002722709a0fdf3d1aa23606ed7d62ff
|
||||
branch: 11-flexible-paths-for-schemes
|
||||
specs:
|
||||
epp-xml (1.1.0)
|
||||
epp-xml (1.2.0)
|
||||
activesupport (>= 4.1)
|
||||
builder (~> 3.2)
|
||||
|
||||
|
@ -541,7 +541,7 @@ DEPENDENCIES
|
|||
domain_name
|
||||
e_invoice!
|
||||
epp!
|
||||
epp-xml (= 1.1.0)!
|
||||
epp-xml (= 1.2.0)!
|
||||
figaro (~> 1.2)
|
||||
haml (~> 5.0)
|
||||
isikukood
|
||||
|
@ -584,4 +584,4 @@ DEPENDENCIES
|
|||
wkhtmltopdf-binary (~> 0.12.5.1)
|
||||
|
||||
BUNDLED WITH
|
||||
2.2.19
|
||||
2.2.20
|
||||
|
|
|
@ -32,7 +32,7 @@ module Depp
|
|||
|
||||
def initialize(args = {})
|
||||
self.current_user = args[:current_user]
|
||||
self.epp_xml = EppXml::Domain.new(cl_trid_prefix: current_user.tag)
|
||||
self.epp_xml = EppXml::Domain.new(cl_trid_prefix: current_user.tag, schema_prefix: 'domain-ee', schema_version: '1.1')
|
||||
end
|
||||
|
||||
def info(domain_name)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -28,12 +28,61 @@ class EppDomainInfoBaseTest < EppTestCase
|
|||
|
||||
assert_epp_response :completed_successfully
|
||||
assert assert_schema_is_bigger(response_xml, 'domain-ee', 1.1)
|
||||
assert_equal 'shop.test', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}").text
|
||||
assert_equal 'ok', response_xml.at_xpath('//domain:status', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}")['s']
|
||||
assert_equal 'john-001', response_xml.at_xpath('//domain:registrant', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}").text
|
||||
assert_equal '2010-07-05T00:00:00+03:00', response_xml.at_xpath('//domain:crDate', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}").text
|
||||
assert_equal '2010-07-06T00:00:00+03:00', response_xml.at_xpath('//domain:upDate', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}").text
|
||||
assert_equal '2010-07-07T00:00:00+03:00', response_xml.at_xpath('//domain:exDate', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}").text
|
||||
assert_equal 'shop.test',
|
||||
response_xml.at_xpath('//domain:name',
|
||||
'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee').to_s).text
|
||||
assert_equal 'ok',
|
||||
response_xml.at_xpath('//domain:status',
|
||||
'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee').to_s)['s']
|
||||
assert_equal 'john-001',
|
||||
response_xml.at_xpath('//domain:registrant',
|
||||
'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee').to_s).text
|
||||
assert_equal '2010-07-05T00:00:00+03:00',
|
||||
response_xml.at_xpath('//domain:crDate',
|
||||
'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee').to_s).text
|
||||
assert_equal '2010-07-06T00:00:00+03:00',
|
||||
response_xml.at_xpath('//domain:upDate',
|
||||
'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee').to_s).text
|
||||
assert_equal '2010-07-07T00:00:00+03:00',
|
||||
response_xml.at_xpath('//domain:exDate',
|
||||
'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee').to_s).text
|
||||
end
|
||||
|
||||
def test_returns_valid_response_if_schema_version_is_previous
|
||||
dispute = disputes(:expired)
|
||||
dispute.update!(starts_at: Time.zone.now, expires_at: Time.zone.now + 5.days, closed: nil)
|
||||
|
||||
domain = domains(:shop)
|
||||
domain.update_columns(statuses: [DomainStatus::DISPUTED],
|
||||
created_at: Time.zone.parse('2010-07-05'),
|
||||
updated_at: Time.zone.parse('2010-07-06'),
|
||||
creator_str: 'test',
|
||||
valid_to: Time.zone.parse('2010-07-07'))
|
||||
|
||||
domain.versions.destroy_all
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee')}">
|
||||
<command>
|
||||
<info>
|
||||
<domain:info xmlns:domain="#{Xsd::Schema.filename(for_prefix: 'domain-eis')}">
|
||||
<domain:name>shop.test</domain:name>
|
||||
</domain:info>
|
||||
</info>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post epp_info_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_epp_response :completed_successfully
|
||||
schema = EPP_ALL_SCHEMA
|
||||
|
||||
schema_validation_errors = schema.validate(response_xml)
|
||||
assert_equal 0, schema_validation_errors.size
|
||||
end
|
||||
|
||||
def test_returns_valid_response_if_disputed
|
||||
|
@ -70,7 +119,6 @@ class EppDomainInfoBaseTest < EppTestCase
|
|||
schema = EPP_ALL_SCHEMA
|
||||
|
||||
schema_validation_errors = schema.validate(response_xml)
|
||||
p schema_validation_errors
|
||||
assert_equal 0, schema_validation_errors.size
|
||||
end
|
||||
|
||||
|
@ -125,7 +173,9 @@ class EppDomainInfoBaseTest < EppTestCase
|
|||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '65078d5', response_xml.at_xpath('//domain:authInfo/domain:pw', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}").text
|
||||
assert_equal '65078d5',
|
||||
response_xml.at_xpath('//domain:authInfo/domain:pw',
|
||||
'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee').to_s).text
|
||||
end
|
||||
|
||||
# Transfer code is the only info we conceal from other registrars, hence a bit oddly-looking
|
||||
|
@ -153,7 +203,9 @@ class EppDomainInfoBaseTest < EppTestCase
|
|||
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '65078d5', response_xml.at_xpath('//domain:authInfo/domain:pw', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}").text
|
||||
assert_equal '65078d5',
|
||||
response_xml.at_xpath('//domain:authInfo/domain:pw',
|
||||
'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee').to_s).text
|
||||
end
|
||||
|
||||
def test_conceals_transfer_code_when_domain_is_not_owned_by_current_user
|
||||
|
@ -178,6 +230,6 @@ class EppDomainInfoBaseTest < EppTestCase
|
|||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_nil response_xml.at_xpath('//domain:authInfo/domain:pw',
|
||||
'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}")
|
||||
'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee').to_s)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue