internetee-registry/test/integration/epp/domain/info/base_test.rb

184 lines
7.3 KiB
Ruby

require 'test_helper'
class EppDomainInfoBaseTest < EppTestCase
def test_returns_valid_response
assert_equal 'john-001', contacts(:john).code
domains(:shop).update_columns(statuses: [DomainStatus::OK],
created_at: Time.zone.parse('2010-07-05'),
updated_at: Time.zone.parse('2010-07-06'),
valid_to: Time.zone.parse('2010-07-07'))
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)
schema_version = return_xml_domain_schema_version(response_xml)
assert_epp_response :completed_successfully
assert schema_version >= 1.1
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 'john-001', response_xml.at_xpath('//domain:registrant', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text
assert_equal '2010-07-05T00:00:00+03:00', response_xml.at_xpath('//domain:crDate', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text
assert_equal '2010-07-06T00:00:00+03:00', response_xml.at_xpath('//domain:upDate', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text
assert_equal '2010-07-07T00:00:00+03:00', response_xml.at_xpath('//domain:exDate', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text
end
def test_returns_valid_response_if_disputed
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_release_prohibited
domain = domains(:shop)
domain.update_columns(statuses: [DomainStatus::SERVER_RELEASE_PROHIBITED],
created_at: Time.now - 5.days,
creator_str: 'test',
delete_date: Time.now - 1.day)
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_reveals_transfer_code_when_domain_is_owned_by_current_user
assert_equal '65078d5', domains(:shop).transfer_code
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_equal '65078d5', response_xml.at_xpath('//domain:authInfo/domain:pw', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}").text
end
# Transfer code is the only info we conceal from other registrars, hence a bit oddly-looking
# test name
def test_reveals_transfer_code_when_domain_is_not_owned_by_current_user_and_transfer_code_is_provided
assert_equal '65078d5', domains(:shop).transfer_code
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:authInfo>
<domain:pw>65078d5</domain:pw>
</domain:authInfo>
</domain:info>
</info>
</command>
</epp>
XML
post epp_info_path, params: { frame: request_xml },
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-eis')}").text
end
def test_conceals_transfer_code_when_domain_is_not_owned_by_current_user
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:authInfo>
<domain:pw></domain:pw>
</domain:authInfo>
</domain:info>
</info>
</command>
</epp>
XML
post epp_info_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_goodnames' }
response_xml = Nokogiri::XML(response.body)
assert_nil response_xml.at_xpath('//domain:authInfo/domain:pw',
'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-eis')}")
end
end