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', 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 'que'
|
||||||
gem 'daemons-rails', '1.2.1'
|
gem 'daemons-rails', '1.2.1'
|
||||||
gem 'que-web'
|
gem 'que-web'
|
||||||
|
|
10
Gemfile.lock
10
Gemfile.lock
|
@ -28,10 +28,10 @@ GIT
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: https://github.com/internetee/epp-xml.git
|
remote: https://github.com/internetee/epp-xml.git
|
||||||
revision: 687514dc239d22b29d0138d83c909d70d19dc06d
|
revision: b821c16a002722709a0fdf3d1aa23606ed7d62ff
|
||||||
branch: update-paths-for-new-domain-schema
|
branch: 11-flexible-paths-for-schemes
|
||||||
specs:
|
specs:
|
||||||
epp-xml (1.1.0)
|
epp-xml (1.2.0)
|
||||||
activesupport (>= 4.1)
|
activesupport (>= 4.1)
|
||||||
builder (~> 3.2)
|
builder (~> 3.2)
|
||||||
|
|
||||||
|
@ -541,7 +541,7 @@ DEPENDENCIES
|
||||||
domain_name
|
domain_name
|
||||||
e_invoice!
|
e_invoice!
|
||||||
epp!
|
epp!
|
||||||
epp-xml (= 1.1.0)!
|
epp-xml (= 1.2.0)!
|
||||||
figaro (~> 1.2)
|
figaro (~> 1.2)
|
||||||
haml (~> 5.0)
|
haml (~> 5.0)
|
||||||
isikukood
|
isikukood
|
||||||
|
@ -584,4 +584,4 @@ DEPENDENCIES
|
||||||
wkhtmltopdf-binary (~> 0.12.5.1)
|
wkhtmltopdf-binary (~> 0.12.5.1)
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
2.2.19
|
2.2.20
|
||||||
|
|
|
@ -32,7 +32,7 @@ module Depp
|
||||||
|
|
||||||
def initialize(args = {})
|
def initialize(args = {})
|
||||||
self.current_user = args[:current_user]
|
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
|
end
|
||||||
|
|
||||||
def info(domain_name)
|
def info(domain_name)
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
class EppConstraint
|
class EppConstraint
|
||||||
OBJECT_TYPES = {
|
OBJECT_TYPES = {
|
||||||
domain: { domain: Xsd::Schema.filename(for_prefix: 'domain-ee') },
|
domain: [
|
||||||
contact: { contact: Xsd::Schema.filename(for_prefix: 'contact-ee') },
|
{ 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
|
}.freeze
|
||||||
|
|
||||||
def initialize(type)
|
def initialize(type)
|
||||||
|
@ -13,13 +16,25 @@ class EppConstraint
|
||||||
# TODO: Maybe move this to controller to keep params clean
|
# TODO: Maybe move this to controller to keep params clean
|
||||||
return redirect_to_error_controller(request) if request.params[:action] == 'wrong_schema'
|
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[:nokogiri_frame] ||= Nokogiri::XML(request.params[:raw_frame] || request.params[:frame])
|
||||||
request.params[:parsed_frame] ||= request.params[:nokogiri_frame].dup.remove_namespaces!
|
request.params[:parsed_frame] ||= request.params[:nokogiri_frame].dup.remove_namespaces!
|
||||||
|
|
||||||
unless %i[poll session].include?(@type)
|
unless %i[poll session].include?(@type)
|
||||||
element = "//#{@type}:#{request.params[:action]}"
|
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
|
end
|
||||||
|
|
||||||
request.params[:epp_object_type] = @type
|
request.params[:epp_object_type] = @type
|
||||||
|
|
|
@ -22,18 +22,67 @@ class EppDomainInfoBaseTest < EppTestCase
|
||||||
XML
|
XML
|
||||||
|
|
||||||
post epp_info_path, params: { frame: request_xml },
|
post epp_info_path, params: { frame: request_xml },
|
||||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||||
|
|
||||||
response_xml = Nokogiri::XML(response.body)
|
response_xml = Nokogiri::XML(response.body)
|
||||||
|
|
||||||
assert_epp_response :completed_successfully
|
assert_epp_response :completed_successfully
|
||||||
assert assert_schema_is_bigger(response_xml, 'domain-ee', 1.1)
|
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 'shop.test',
|
||||||
assert_equal 'ok', response_xml.at_xpath('//domain:status', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}")['s']
|
response_xml.at_xpath('//domain:name',
|
||||||
assert_equal 'john-001', response_xml.at_xpath('//domain:registrant', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}").text
|
'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')}").text
|
assert_equal 'ok',
|
||||||
assert_equal '2010-07-06T00:00:00+03:00', response_xml.at_xpath('//domain:upDate', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}").text
|
response_xml.at_xpath('//domain:status',
|
||||||
assert_equal '2010-07-07T00:00:00+03:00', response_xml.at_xpath('//domain:exDate', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee')}").text
|
'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
|
end
|
||||||
|
|
||||||
def test_returns_valid_response_if_disputed
|
def test_returns_valid_response_if_disputed
|
||||||
|
@ -63,14 +112,13 @@ class EppDomainInfoBaseTest < EppTestCase
|
||||||
XML
|
XML
|
||||||
|
|
||||||
post epp_info_path, params: { frame: request_xml },
|
post epp_info_path, params: { frame: request_xml },
|
||||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||||
|
|
||||||
response_xml = Nokogiri::XML(response.body)
|
response_xml = Nokogiri::XML(response.body)
|
||||||
assert_epp_response :completed_successfully
|
assert_epp_response :completed_successfully
|
||||||
schema = EPP_ALL_SCHEMA
|
schema = EPP_ALL_SCHEMA
|
||||||
|
|
||||||
schema_validation_errors = schema.validate(response_xml)
|
schema_validation_errors = schema.validate(response_xml)
|
||||||
p schema_validation_errors
|
|
||||||
assert_equal 0, schema_validation_errors.size
|
assert_equal 0, schema_validation_errors.size
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -95,7 +143,7 @@ class EppDomainInfoBaseTest < EppTestCase
|
||||||
XML
|
XML
|
||||||
|
|
||||||
post epp_info_path, params: { frame: request_xml },
|
post epp_info_path, params: { frame: request_xml },
|
||||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||||
|
|
||||||
response_xml = Nokogiri::XML(response.body)
|
response_xml = Nokogiri::XML(response.body)
|
||||||
assert_epp_response :completed_successfully
|
assert_epp_response :completed_successfully
|
||||||
|
@ -122,10 +170,12 @@ class EppDomainInfoBaseTest < EppTestCase
|
||||||
XML
|
XML
|
||||||
|
|
||||||
post epp_info_path, params: { frame: request_xml },
|
post epp_info_path, params: { frame: request_xml },
|
||||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||||
|
|
||||||
response_xml = Nokogiri::XML(response.body)
|
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
|
end
|
||||||
|
|
||||||
# Transfer code is the only info we conceal from other registrars, hence a bit oddly-looking
|
# Transfer code is the only info we conceal from other registrars, hence a bit oddly-looking
|
||||||
|
@ -150,10 +200,12 @@ class EppDomainInfoBaseTest < EppTestCase
|
||||||
XML
|
XML
|
||||||
|
|
||||||
post epp_info_path, params: { frame: request_xml },
|
post epp_info_path, params: { frame: request_xml },
|
||||||
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||||
|
|
||||||
response_xml = Nokogiri::XML(response.body)
|
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
|
end
|
||||||
|
|
||||||
def test_conceals_transfer_code_when_domain_is_not_owned_by_current_user
|
def test_conceals_transfer_code_when_domain_is_not_owned_by_current_user
|
||||||
|
@ -174,10 +226,10 @@ class EppDomainInfoBaseTest < EppTestCase
|
||||||
XML
|
XML
|
||||||
|
|
||||||
post epp_info_path, params: { frame: request_xml },
|
post epp_info_path, params: { frame: request_xml },
|
||||||
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||||
|
|
||||||
response_xml = Nokogiri::XML(response.body)
|
response_xml = Nokogiri::XML(response.body)
|
||||||
assert_nil response_xml.at_xpath('//domain:authInfo/domain:pw',
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue