mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 14:44:47 +02:00
commit
ab9c7fa351
160 changed files with 1962 additions and 7650 deletions
4
test/fixtures/billing/prices.yml
vendored
4
test/fixtures/billing/prices.yml
vendored
|
@ -1,5 +1,5 @@
|
|||
create_one_month:
|
||||
duration: 1 month
|
||||
duration: 3 mons
|
||||
price_cents: 100
|
||||
operation_category: create
|
||||
valid_from: 2010-07-05
|
||||
|
@ -7,7 +7,7 @@ create_one_month:
|
|||
zone: one
|
||||
|
||||
renew_one_month:
|
||||
duration: 1 month
|
||||
duration: 1 mons
|
||||
price_cents: 100
|
||||
operation_category: renew
|
||||
valid_from: 2010-07-05
|
||||
|
|
1
test/fixtures/users.yml
vendored
1
test/fixtures/users.yml
vendored
|
@ -19,6 +19,7 @@ api_goodnames:
|
|||
|
||||
admin:
|
||||
username: test
|
||||
email: test@registry.test
|
||||
encrypted_password: <%= Devise::Encryptor.digest(AdminUser, 'testtest') %>
|
||||
type: AdminUser
|
||||
country_code: US
|
||||
|
|
27
test/integration/admin_area/zones_test.rb
Normal file
27
test/integration/admin_area/zones_test.rb
Normal file
|
@ -0,0 +1,27 @@
|
|||
require 'test_helper'
|
||||
|
||||
class AdminAreaZonesIntegrationTest < ApplicationIntegrationTest
|
||||
setup do
|
||||
@zone = dns_zones(:one)
|
||||
sign_in users(:admin)
|
||||
end
|
||||
|
||||
def test_updates_zone
|
||||
new_master_nameserver = 'new.test'
|
||||
assert_not_equal new_master_nameserver, @zone.master_nameserver
|
||||
|
||||
patch admin_zone_path(@zone), zone: { master_nameserver: new_master_nameserver }
|
||||
@zone.reload
|
||||
|
||||
assert_equal new_master_nameserver, @zone.master_nameserver
|
||||
end
|
||||
|
||||
def test_downloads_zone_file
|
||||
post admin_zonefiles_path(origin: @zone.origin)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 'text/plain', response.headers['Content-Type']
|
||||
assert_equal 'attachment; filename="test.txt"', response.headers['Content-Disposition']
|
||||
assert_not_empty response.body
|
||||
end
|
||||
end
|
|
@ -1,7 +1,11 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppContactCreateBaseTest < EppTestCase
|
||||
def test_creates_new_contact_with_minimum_required_parameters
|
||||
def test_creates_new_contact_with_required_attributes
|
||||
name = 'new'
|
||||
email = 'new@registrar.test'
|
||||
phone = '+1.2'
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
|
@ -9,7 +13,76 @@ class EppContactCreateBaseTest < EppTestCase
|
|||
<create>
|
||||
<contact:create xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
||||
<contact:postalInfo>
|
||||
<contact:name>New</contact:name>
|
||||
<contact:name>#{name}</contact:name>
|
||||
</contact:postalInfo>
|
||||
<contact:voice>#{phone}</contact:voice>
|
||||
<contact:email>#{email}</contact:email>
|
||||
</contact:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:ident type="priv" cc="US">any</eis:ident>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
assert_difference 'Contact.count' do
|
||||
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
end
|
||||
|
||||
assert_epp_response :completed_successfully
|
||||
contact = Contact.find_by(name: name)
|
||||
assert_equal name, contact.name
|
||||
assert_equal email, contact.email
|
||||
assert_equal phone, contact.phone
|
||||
assert_not_empty contact.code
|
||||
end
|
||||
|
||||
def test_respects_custom_code
|
||||
name = 'new'
|
||||
code = 'custom-id'
|
||||
session = epp_sessions(:api_bestnames)
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<contact:create xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
||||
<contact:id>#{code}</contact:id>
|
||||
<contact:postalInfo>
|
||||
<contact:name>#{name}</contact:name>
|
||||
</contact:postalInfo>
|
||||
<contact:voice>+1.2</contact:voice>
|
||||
<contact:email>any@any.test</contact:email>
|
||||
</contact:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:ident type="priv" cc="US">any</eis:ident>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session.session_id}"
|
||||
|
||||
contact = Contact.find_by(name: name)
|
||||
assert_equal "#{session.user.registrar.code}:#{code}".upcase, contact.code
|
||||
end
|
||||
|
||||
def test_fails_when_required_attributes_are_missing
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<contact:create xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
||||
<contact:postalInfo>
|
||||
<contact:name>\s</contact:name>
|
||||
</contact:postalInfo>
|
||||
<contact:voice>+123.4</contact:voice>
|
||||
<contact:email>new@inbox.test</contact:email>
|
||||
|
@ -24,15 +97,9 @@ class EppContactCreateBaseTest < EppTestCase
|
|||
</epp>
|
||||
XML
|
||||
|
||||
assert_difference 'Contact.count' do
|
||||
assert_no_difference 'Contact.count' do
|
||||
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
end
|
||||
|
||||
assert_epp_response :completed_successfully
|
||||
contact = Contact.last
|
||||
assert_not_empty contact.code
|
||||
assert_equal 'New', contact.name
|
||||
assert_equal 'new@inbox.test', contact.email
|
||||
assert_equal '+123.4', contact.phone
|
||||
assert_epp_response :required_parameter_missing
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -133,6 +133,98 @@ class EppContactUpdateBaseTest < EppTestCase
|
|||
assert_no_emails
|
||||
end
|
||||
|
||||
def test_non_existing_contact
|
||||
assert_nil Contact.find_by(code: 'non-existing')
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<update>
|
||||
<contact:update xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
||||
<contact:id>non-existing</contact:id>
|
||||
<contact:chg>
|
||||
<contact:postalInfo>
|
||||
<contact:name>any</contact:name>
|
||||
</contact:postalInfo>
|
||||
</contact:chg>
|
||||
</contact:update>
|
||||
</update>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
assert_epp_response :object_does_not_exist
|
||||
end
|
||||
|
||||
def test_ident_code_cannot_be_updated
|
||||
new_ident_code = '12345'
|
||||
assert_not_equal new_ident_code, @contact.ident
|
||||
|
||||
# https://github.com/internetee/registry/issues/415
|
||||
@contact.update_columns(code: @contact.code.upcase)
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<update>
|
||||
<contact:update xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
||||
<contact:id>#{@contact.code}</contact:id>
|
||||
<contact:chg>
|
||||
<contact:postalInfo>
|
||||
</contact:postalInfo>
|
||||
</contact:chg>
|
||||
</contact:update>
|
||||
</update>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:ident cc="#{@contact.ident_country_code}" type="#{@contact.ident_type}">#{new_ident_code}</eis:ident>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
assert_no_changes -> { @contact.updated_at } do
|
||||
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
end
|
||||
assert_epp_response :data_management_policy_violation
|
||||
end
|
||||
|
||||
# https://github.com/internetee/registry/issues/576
|
||||
def test_ident_type_and_ident_country_code_can_be_updated_when_absent
|
||||
@contact.update_columns(ident: 'test', ident_type: nil, ident_country_code: nil)
|
||||
|
||||
# https://github.com/internetee/registry/issues/415
|
||||
@contact.update_columns(code: @contact.code.upcase)
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<update>
|
||||
<contact:update xmlns:contact="https://epp.tld.ee/schema/contact-ee-1.1.xsd">
|
||||
<contact:id>#{@contact.code}</contact:id>
|
||||
<contact:chg>
|
||||
<contact:postalInfo/>
|
||||
</contact:chg>
|
||||
</contact:update>
|
||||
</update>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:ident cc="US" type="priv">#{@contact.ident}</eis:ident>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
assert_epp_response :completed_successfully
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def make_contact_free_of_domains_where_it_acts_as_a_registrant(contact)
|
||||
|
@ -140,4 +232,4 @@ class EppContactUpdateBaseTest < EppTestCase
|
|||
assert_not_equal other_contact, contact
|
||||
Domain.update_all(registrant_id: other_contact)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,15 +1,20 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainCreateBaseTest < EppTestCase
|
||||
def test_domain_can_be_registered_with_required_attributes_only
|
||||
def test_registers_new_domain_with_required_attributes
|
||||
now = Time.zone.parse('2010-07-05')
|
||||
travel_to now
|
||||
name = "new.#{dns_zones(:one).origin}"
|
||||
registrant = contacts(:john).becomes(Registrant)
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>new.test</domain:name>
|
||||
<domain:registrant>john-001</domain:registrant>
|
||||
<domain:name>#{name}</domain:name>
|
||||
<domain:registrant>#{registrant.code}</domain:registrant>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
|
@ -25,9 +30,223 @@ class EppDomainCreateBaseTest < EppTestCase
|
|||
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
end
|
||||
|
||||
domain = Domain.last
|
||||
assert_equal 'new.test', domain.name
|
||||
assert_equal contacts(:john).becomes(Registrant), domain.registrant
|
||||
assert_epp_response :completed_successfully
|
||||
|
||||
domain = Domain.find_by(name: name)
|
||||
assert_equal name, domain.name
|
||||
assert_equal registrant, domain.registrant
|
||||
assert_not_empty domain.transfer_code
|
||||
|
||||
default_registration_period = 1.year + 1.day
|
||||
assert_equal now + default_registration_period, domain.expire_time
|
||||
end
|
||||
|
||||
def test_registers_reserved_domain_with_registration_code
|
||||
reserved_domain = reserved_domains(:one)
|
||||
registration_code = reserved_domain.registration_code
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>#{reserved_domain.name}</domain:name>
|
||||
<domain:registrant>#{contacts(:john).code}</domain:registrant>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
<eis:reserved>
|
||||
<eis:pw>#{registration_code}</eis:pw>
|
||||
</eis:reserved>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
assert_difference 'Domain.count' do
|
||||
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
end
|
||||
assert_epp_response :completed_successfully
|
||||
|
||||
reserved_domain.reload
|
||||
assert_not_equal registration_code, reserved_domain.registration_code
|
||||
end
|
||||
|
||||
def test_respects_custom_transfer_code
|
||||
name = "new.#{dns_zones(:one).origin}"
|
||||
transfer_code = 'custom-transfer-code'
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>#{name}</domain:name>
|
||||
<domain:registrant>#{contacts(:john).code}</domain:registrant>
|
||||
<domain:authInfo>
|
||||
<domain:pw>#{transfer_code}</domain:pw>
|
||||
</domain:authInfo>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal transfer_code, Domain.find_by(name: name).transfer_code
|
||||
end
|
||||
|
||||
def test_blocked_domain_cannot_be_registered
|
||||
blocked_domain = 'blocked.test'
|
||||
assert BlockedDomain.find_by(name: blocked_domain)
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>#{blocked_domain}</domain:name>
|
||||
<domain:registrant>#{contacts(:john).code}</domain:registrant>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
assert_no_difference 'Domain.count' do
|
||||
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
end
|
||||
assert_epp_response :data_management_policy_violation
|
||||
end
|
||||
|
||||
def test_reserved_domain_cannot_be_registered_with_wrong_registration_code
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>#{reserved_domains(:one).name}</domain:name>
|
||||
<domain:registrant>#{contacts(:john).code}</domain:registrant>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
<eis:reserved>
|
||||
<eis:pw>wrong</eis:pw>
|
||||
</eis:reserved>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
assert_no_difference 'Domain.count' do
|
||||
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
end
|
||||
assert_epp_response :invalid_authorization_information
|
||||
end
|
||||
|
||||
def test_reserved_domain_cannot_be_registered_without_registration_code
|
||||
reserved_domain = reserved_domains(:one)
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>#{reserved_domain.name}</domain:name>
|
||||
<domain:registrant>#{contacts(:john).code}</domain:registrant>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
assert_no_difference 'Domain.count' do
|
||||
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
end
|
||||
assert_epp_response :required_parameter_missing
|
||||
end
|
||||
|
||||
def test_insufficient_funds
|
||||
session = epp_sessions(:api_bestnames)
|
||||
session.user.registrar.accounts.first.update!(balance: 0)
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>new.test</domain:name>
|
||||
<domain:registrant>#{contacts(:john).code}</domain:registrant>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
assert_no_difference 'Domain.count' do
|
||||
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => "session=#{session.session_id}"
|
||||
end
|
||||
assert_epp_response :billing_failure
|
||||
end
|
||||
|
||||
def test_no_price
|
||||
assert_nil Billing::Price.find_by(duration: '2 months')
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>new.test</domain:name>
|
||||
<domain:period unit="m">2</domain:period>
|
||||
<domain:registrant>john-001</domain:registrant>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
assert_no_difference 'Domain.count' do
|
||||
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
end
|
||||
assert_epp_response :billing_failure
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,131 +0,0 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainCreateReservedTest < EppTestCase
|
||||
setup do
|
||||
@reserved_domain = reserved_domains(:one)
|
||||
end
|
||||
|
||||
def test_registers_reserved_domain_with_correct_registration_code
|
||||
assert_equal 'reserved.test', @reserved_domain.name
|
||||
assert_equal 'reserved-001', @reserved_domain.registration_code
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>reserved.test</domain:name>
|
||||
<domain:registrant>john-001</domain:registrant>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
<eis:reserved>
|
||||
<eis:pw>reserved-001</eis:pw>
|
||||
</eis:reserved>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
assert_difference 'Domain.count' do
|
||||
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
end
|
||||
assert_epp_response :completed_successfully
|
||||
end
|
||||
|
||||
def test_registering_reserved_domain_regenerates_registration_code
|
||||
assert_equal 'reserved.test', @reserved_domain.name
|
||||
assert_equal 'reserved-001', @reserved_domain.registration_code
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>reserved.test</domain:name>
|
||||
<domain:registrant>john-001</domain:registrant>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
<eis:reserved>
|
||||
<eis:pw>reserved-001</eis:pw>
|
||||
</eis:reserved>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
@reserved_domain.reload
|
||||
|
||||
assert_not_equal 'reserved-001', @reserved_domain.registration_code
|
||||
end
|
||||
|
||||
def test_domain_cannot_be_registered_with_wrong_registration_code
|
||||
assert_equal 'reserved.test', @reserved_domain.name
|
||||
assert_equal 'reserved-001', @reserved_domain.registration_code
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>reserved.test</domain:name>
|
||||
<domain:registrant>john-001</domain:registrant>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
<eis:reserved>
|
||||
<eis:pw>wrong</eis:pw>
|
||||
</eis:reserved>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
assert_no_difference 'Domain.count' do
|
||||
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
end
|
||||
assert_epp_response :invalid_authorization_information
|
||||
end
|
||||
|
||||
def test_domain_cannot_be_registered_without_registration_code
|
||||
assert_equal 'reserved.test', @reserved_domain.name
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>reserved.test</domain:name>
|
||||
<domain:registrant>john-001</domain:registrant>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
assert_no_difference 'Domain.count' do
|
||||
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
end
|
||||
assert_epp_response :required_parameter_missing
|
||||
end
|
||||
end
|
|
@ -1,62 +0,0 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainCreateTransferCodeTest < EppTestCase
|
||||
setup do
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
end
|
||||
|
||||
def test_generates_default
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>brandnew.test</domain:name>
|
||||
<domain:period unit="y">1</domain:period>
|
||||
<domain:registrant>john-001</domain:registrant>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/create', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
refute_empty Domain.find_by(name: 'brandnew.test').transfer_code
|
||||
assert_epp_response :completed_successfully
|
||||
end
|
||||
|
||||
def test_honors_custom
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<create>
|
||||
<domain:create xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>brandnew.test</domain:name>
|
||||
<domain:period unit="y">1</domain:period>
|
||||
<domain:registrant>john-001</domain:registrant>
|
||||
<domain:authInfo>
|
||||
<domain:pw>1058ad73</domain:pw>
|
||||
</domain:authInfo>
|
||||
</domain:create>
|
||||
</create>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/create', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
assert_equal '1058ad73', Domain.find_by(name: 'brandnew.test').transfer_code
|
||||
assert_epp_response :completed_successfully
|
||||
end
|
||||
end
|
|
@ -1,52 +0,0 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainUpdateTest < EppTestCase
|
||||
def setup
|
||||
@domain = domains(:shop)
|
||||
end
|
||||
|
||||
def test_update_domain
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<update>
|
||||
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>shop.test</domain:name>
|
||||
<domain:chg>
|
||||
<domain:authInfo>
|
||||
<domain:pw>f0ff7d17b0</domain:pw>
|
||||
</domain:authInfo>
|
||||
</domain:chg>
|
||||
</domain:update>
|
||||
</update>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
@domain.reload
|
||||
assert_equal 'f0ff7d17b0', @domain.transfer_code
|
||||
assert_epp_response :completed_successfully
|
||||
end
|
||||
|
||||
def test_discarded_domain_cannot_be_updated
|
||||
@domain.update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<update>
|
||||
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>shop.test</domain:name>
|
||||
</domain:update>
|
||||
</update>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
assert_epp_response :object_status_prohibits_operation
|
||||
end
|
||||
end
|
295
test/integration/epp/domain/update/base_test.rb
Normal file
295
test/integration/epp/domain/update/base_test.rb
Normal file
|
@ -0,0 +1,295 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainUpdateBaseTest < EppTestCase
|
||||
include ActionMailer::TestHelper
|
||||
|
||||
def setup
|
||||
@domain = domains(:shop)
|
||||
ActionMailer::Base.deliveries.clear
|
||||
end
|
||||
|
||||
def test_update_domain
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<update>
|
||||
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>shop.test</domain:name>
|
||||
<domain:chg>
|
||||
<domain:authInfo>
|
||||
<domain:pw>f0ff7d17b0</domain:pw>
|
||||
</domain:authInfo>
|
||||
</domain:chg>
|
||||
</domain:update>
|
||||
</update>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
@domain.reload
|
||||
assert_equal 'f0ff7d17b0', @domain.transfer_code
|
||||
assert_epp_response :completed_successfully
|
||||
end
|
||||
|
||||
def test_discarded_domain_cannot_be_updated
|
||||
@domain.update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<update>
|
||||
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>shop.test</domain:name>
|
||||
</domain:update>
|
||||
</update>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
assert_epp_response :object_status_prohibits_operation
|
||||
end
|
||||
|
||||
def test_does_not_return_server_delete_prohibited_status_when_pending_update_status_is_set
|
||||
@domain.update!(statuses: [DomainStatus::SERVER_DELETE_PROHIBITED,
|
||||
DomainStatus::PENDING_UPDATE])
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<update>
|
||||
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>#{@domain.name}</domain:name>
|
||||
</domain:update>
|
||||
</update>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
assert_epp_response :object_status_prohibits_operation
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal DomainStatus::PENDING_UPDATE, response_xml.at_xpath('//domain:status', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
|
||||
end
|
||||
|
||||
def test_requires_verification_from_current_registrant_when_provided_registrant_is_a_new_one
|
||||
Setting.request_confrimation_on_registrant_change_enabled = true
|
||||
new_registrant = contacts(:william).becomes(Registrant)
|
||||
assert_not_equal new_registrant, @domain.registrant
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<update>
|
||||
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>#{@domain.name}</domain:name>
|
||||
<domain:chg>
|
||||
<domain:registrant>#{new_registrant.code}</domain:registrant>
|
||||
</domain:chg>
|
||||
</domain:update>
|
||||
</update>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
@domain.reload
|
||||
|
||||
assert_epp_response :completed_successfully_action_pending
|
||||
assert_not_equal new_registrant, @domain.registrant
|
||||
assert @domain.registrant_verification_asked?
|
||||
assert_includes @domain.statuses, DomainStatus::PENDING_UPDATE
|
||||
assert_verification_and_notification_emails
|
||||
end
|
||||
|
||||
def test_requires_verification_from_current_registrant_when_not_yet_verified_by_registrar
|
||||
Setting.request_confrimation_on_registrant_change_enabled = true
|
||||
new_registrant = contacts(:william)
|
||||
assert_not_equal new_registrant, @domain.registrant
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<update>
|
||||
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>#{@domain.name}</domain:name>
|
||||
<domain:chg>
|
||||
<domain:registrant verified="no">#{new_registrant.code}</domain:registrant>
|
||||
</domain:chg>
|
||||
</domain:update>
|
||||
</update>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
@domain.reload
|
||||
|
||||
assert_epp_response :completed_successfully_action_pending
|
||||
assert_not_equal new_registrant, @domain.registrant
|
||||
assert @domain.registrant_verification_asked?
|
||||
assert_includes @domain.statuses, DomainStatus::PENDING_UPDATE
|
||||
assert_verification_and_notification_emails
|
||||
end
|
||||
|
||||
def test_skips_verification_when_provided_registrant_is_the_same_as_current_one
|
||||
Setting.request_confrimation_on_registrant_change_enabled = true
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<update>
|
||||
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>#{@domain.name}</domain:name>
|
||||
<domain:chg>
|
||||
<domain:registrant>#{@domain.registrant.code}</domain:registrant>
|
||||
</domain:chg>
|
||||
</domain:update>
|
||||
</update>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
@domain.reload
|
||||
|
||||
assert_epp_response :completed_successfully
|
||||
assert_not @domain.registrant_verification_asked?
|
||||
refute_includes @domain.statuses, DomainStatus::PENDING_UPDATE
|
||||
assert_no_emails
|
||||
end
|
||||
|
||||
def test_skips_verification_when_disabled
|
||||
Setting.request_confrimation_on_registrant_change_enabled = false
|
||||
new_registrant = contacts(:william).becomes(Registrant)
|
||||
assert_not_equal new_registrant, @domain.registrant
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<update>
|
||||
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>#{@domain.name}</domain:name>
|
||||
<domain:chg>
|
||||
<domain:registrant>#{new_registrant.code}</domain:registrant>
|
||||
</domain:chg>
|
||||
</domain:update>
|
||||
</update>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
@domain.reload
|
||||
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal new_registrant, @domain.registrant
|
||||
assert_not @domain.registrant_verification_asked?
|
||||
refute_includes @domain.statuses, DomainStatus::PENDING_UPDATE
|
||||
assert_no_emails
|
||||
end
|
||||
|
||||
def test_skips_verification_from_current_registrant_when_already_verified_by_registrar
|
||||
Setting.request_confrimation_on_registrant_change_enabled = true
|
||||
new_registrant = contacts(:william).becomes(Registrant)
|
||||
assert_not_equal new_registrant, @domain.registrant
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<update>
|
||||
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>#{@domain.name}</domain:name>
|
||||
<domain:chg>
|
||||
<domain:registrant verified="yes">#{new_registrant.code}</domain:registrant>
|
||||
</domain:chg>
|
||||
</domain:update>
|
||||
</update>
|
||||
<extension>
|
||||
<eis:extdata xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd">
|
||||
<eis:legalDocument type="pdf">#{'test' * 2000}</eis:legalDocument>
|
||||
</eis:extdata>
|
||||
</extension>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
@domain.reload
|
||||
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal new_registrant, @domain.registrant
|
||||
assert_not @domain.registrant_verification_asked?
|
||||
refute_includes @domain.statuses, DomainStatus::PENDING_UPDATE
|
||||
assert_no_emails
|
||||
end
|
||||
|
||||
def test_deactivates_domain_when_all_name_servers_are_removed
|
||||
assert @domain.active?
|
||||
assert_equal 2, @domain.nameservers.count
|
||||
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<update>
|
||||
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>#{@domain.name}</domain:name>
|
||||
<domain:rem>
|
||||
<domain:ns>
|
||||
<domain:hostAttr>
|
||||
<domain:hostName>#{nameservers(:shop_ns1).hostname}</domain:hostName>
|
||||
</domain:hostAttr>
|
||||
<domain:hostAttr>
|
||||
<domain:hostName>#{nameservers(:shop_ns2).hostname}</domain:hostName>
|
||||
</domain:hostAttr>
|
||||
</domain:ns>
|
||||
</domain:rem>
|
||||
</domain:update>
|
||||
</update>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
@domain.reload
|
||||
|
||||
assert_epp_response :completed_successfully
|
||||
assert @domain.inactive?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assert_verification_and_notification_emails
|
||||
assert_emails 2
|
||||
end
|
||||
end
|
142
test/models/admin_user_test.rb
Normal file
142
test/models/admin_user_test.rb
Normal file
|
@ -0,0 +1,142 @@
|
|||
require 'test_helper'
|
||||
|
||||
class AdminUserTest < ActiveSupport::TestCase
|
||||
def test_valid_user_fixture_is_valid
|
||||
assert valid_user.valid?, proc { valid_user.errors.full_messages }
|
||||
end
|
||||
|
||||
def test_invalid_without_username
|
||||
user = valid_user
|
||||
user.username = ''
|
||||
assert user.invalid?
|
||||
end
|
||||
|
||||
def test_invalid_without_password_and_password_confirmation_when_creating
|
||||
user = valid_non_persisted_user
|
||||
|
||||
user.password = ''
|
||||
user.password_confirmation = ''
|
||||
assert user.invalid?
|
||||
|
||||
user.password = valid_password
|
||||
user.password_confirmation = user.password
|
||||
assert user.valid?
|
||||
end
|
||||
|
||||
def test_validates_password_format
|
||||
user = valid_non_persisted_user
|
||||
|
||||
user.password = 'a' * (Devise.password_length.min.pred)
|
||||
user.password_confirmation = user.password
|
||||
assert user.invalid?
|
||||
|
||||
user.password = 'a' * (Devise.password_length.max.next)
|
||||
user.password_confirmation = user.password
|
||||
assert user.invalid?
|
||||
|
||||
user.password = 'a' * Devise.password_length.min
|
||||
user.password_confirmation = user.password
|
||||
assert user.valid?
|
||||
|
||||
user.password = 'a' * Devise.password_length.max
|
||||
user.password_confirmation = user.password
|
||||
assert user.valid?
|
||||
end
|
||||
|
||||
def test_requires_password_confirmation
|
||||
user = valid_non_persisted_user
|
||||
user.password = valid_password
|
||||
|
||||
user.password_confirmation = ''
|
||||
assert user.invalid?
|
||||
|
||||
user.password_confirmation = 'another'
|
||||
assert user.invalid?
|
||||
|
||||
user.password_confirmation = user.password
|
||||
assert user.valid?, proc { user.errors.full_messages }
|
||||
end
|
||||
|
||||
def test_invalid_without_email
|
||||
user = valid_user
|
||||
user.email = ''
|
||||
assert user.invalid?
|
||||
end
|
||||
|
||||
def test_validates_email_format
|
||||
user = valid_user
|
||||
|
||||
user.email = 'invalid'
|
||||
assert user.invalid?
|
||||
|
||||
user.email = 'valid@registry.test'
|
||||
assert user.valid?
|
||||
end
|
||||
|
||||
def test_invalid_when_email_is_already_taken
|
||||
another_user = valid_user
|
||||
user = valid_non_persisted_user
|
||||
|
||||
user.email = another_user.email
|
||||
assert user.invalid?
|
||||
|
||||
user.email = 'new-user@registry.test'
|
||||
assert user.valid?, proc { user.errors.full_messages }
|
||||
end
|
||||
|
||||
def test_invalid_without_country_code
|
||||
user = valid_user
|
||||
user.country_code = ''
|
||||
assert user.invalid?
|
||||
end
|
||||
|
||||
def test_invalid_without_roles
|
||||
user = valid_user
|
||||
user.roles = []
|
||||
assert user.invalid?
|
||||
end
|
||||
|
||||
def test_valid_without_identity_code
|
||||
user = valid_user
|
||||
user.identity_code = ''
|
||||
assert user.valid?
|
||||
end
|
||||
|
||||
def test_invalid_without_identity_code_when_country_code_is_estonia
|
||||
user = valid_user
|
||||
user.country_code = 'EE'
|
||||
|
||||
user.identity_code = ''
|
||||
|
||||
assert user.invalid?
|
||||
end
|
||||
|
||||
# https://en.wikipedia.org/wiki/National_identification_number#Estonia
|
||||
def test_validates_identity_code_format_when_country_code_is_estonia
|
||||
user = valid_user
|
||||
user.country_code = 'EE'
|
||||
|
||||
user.identity_code = '47101010030'
|
||||
assert user.invalid?
|
||||
|
||||
user.identity_code = '47101010033'
|
||||
assert user.valid?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def valid_user
|
||||
users(:admin)
|
||||
end
|
||||
|
||||
def valid_non_persisted_user
|
||||
user = valid_user.dup
|
||||
user.password = user.password_confirmation = valid_password
|
||||
user.email = 'another@registry.test'
|
||||
user
|
||||
end
|
||||
|
||||
def valid_password
|
||||
'a' * Devise.password_length.min
|
||||
end
|
||||
end
|
|
@ -5,6 +5,53 @@ class ApiUserTest < ActiveSupport::TestCase
|
|||
@user = users(:api_bestnames)
|
||||
end
|
||||
|
||||
def test_valid_user_fixture_is_valid
|
||||
assert valid_user.valid?, proc { valid_user.errors.full_messages }
|
||||
end
|
||||
|
||||
def test_invalid_without_username
|
||||
user = valid_user
|
||||
user.username = ''
|
||||
assert user.invalid?
|
||||
end
|
||||
|
||||
def test_invalid_when_username_is_already_taken
|
||||
user = valid_user
|
||||
another_user = user.dup
|
||||
|
||||
assert another_user.invalid?
|
||||
|
||||
another_user.username = 'another'
|
||||
assert another_user.valid?
|
||||
end
|
||||
|
||||
def test_invalid_without_password
|
||||
user = valid_user
|
||||
user.plain_text_password = ''
|
||||
assert user.invalid?
|
||||
end
|
||||
|
||||
def test_validates_password_format
|
||||
user = valid_user
|
||||
min_length = ApiUser.min_password_length
|
||||
|
||||
user.plain_text_password = 'a' * (min_length.pred)
|
||||
assert user.invalid?
|
||||
|
||||
user.plain_text_password = 'a' * min_length
|
||||
assert user.valid?
|
||||
end
|
||||
|
||||
def test_invalid_without_roles
|
||||
user = valid_user
|
||||
user.roles = []
|
||||
assert user.invalid?
|
||||
end
|
||||
|
||||
def test_active_by_default
|
||||
assert ApiUser.new.active?
|
||||
end
|
||||
|
||||
def test_finds_user_by_id_card
|
||||
id_card = IdCard.new
|
||||
id_card.personal_code = 'one'
|
||||
|
@ -15,4 +62,10 @@ class ApiUserTest < ActiveSupport::TestCase
|
|||
@user.update!(identity_code: 'another')
|
||||
assert_nil ApiUser.find_by_id_card(id_card)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def valid_user
|
||||
users(:api_bestnames)
|
||||
end
|
||||
end
|
||||
|
|
106
test/models/billing/price_test.rb
Normal file
106
test/models/billing/price_test.rb
Normal file
|
@ -0,0 +1,106 @@
|
|||
require 'test_helper'
|
||||
|
||||
class Billing::PriceTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@user = users(:api_bestnames)
|
||||
end
|
||||
|
||||
def test_valid_price_fixture_is_valid
|
||||
assert valid_price.valid?, proc { valid_price.errors.full_messages }
|
||||
end
|
||||
|
||||
def test_invalid_without_price
|
||||
price = valid_price
|
||||
price.price = ''
|
||||
assert price.invalid?
|
||||
end
|
||||
|
||||
def test_validates_price_format
|
||||
price = valid_price
|
||||
|
||||
price.price = -1
|
||||
assert price.invalid?
|
||||
|
||||
price.price = 0
|
||||
assert price.valid?, proc { price.errors.full_messages }
|
||||
|
||||
price.price = "1#{I18n.t('number.currency.format.separator')}1"
|
||||
assert price.valid?
|
||||
|
||||
price.price = 1
|
||||
assert price.valid?
|
||||
end
|
||||
|
||||
def test_invalid_without_effective_date
|
||||
price = valid_price
|
||||
price.valid_from = ''
|
||||
assert price.invalid?
|
||||
end
|
||||
|
||||
def test_invalid_without_operation_category
|
||||
price = valid_price
|
||||
price.operation_category = ''
|
||||
assert price.invalid?
|
||||
end
|
||||
|
||||
def test_validates_operation_category_format
|
||||
price = valid_price
|
||||
|
||||
price.operation_category = 'invalid'
|
||||
assert price.invalid?
|
||||
|
||||
price.operation_category = Billing::Price.operation_categories.first
|
||||
assert price.valid?
|
||||
end
|
||||
|
||||
def test_invalid_without_duration
|
||||
price = valid_price
|
||||
price.duration = ''
|
||||
assert price.invalid?
|
||||
end
|
||||
|
||||
def test_validates_duration_format
|
||||
price = valid_price
|
||||
|
||||
price.duration = 'invalid'
|
||||
assert price.invalid?
|
||||
|
||||
price.duration = Billing::Price.durations.first
|
||||
assert price.valid?
|
||||
end
|
||||
|
||||
def test_returns_operation_categories
|
||||
operation_categories = %w[create renew]
|
||||
assert_equal operation_categories, Billing::Price.operation_categories
|
||||
end
|
||||
|
||||
def test_returns_durations
|
||||
durations = [
|
||||
'3 mons',
|
||||
'6 mons',
|
||||
'9 mons',
|
||||
'1 year',
|
||||
'2 years',
|
||||
'3 years',
|
||||
'4 years',
|
||||
'5 years',
|
||||
'6 years',
|
||||
'7 years',
|
||||
'8 years',
|
||||
'9 years',
|
||||
'10 years',
|
||||
]
|
||||
assert_equal durations, Billing::Price.durations
|
||||
end
|
||||
|
||||
def test_returns_statuses
|
||||
statuses = %w[upcoming effective expired]
|
||||
assert_equal statuses, Billing::Price.statuses
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def valid_price
|
||||
billing_prices(:create_one_month)
|
||||
end
|
||||
end
|
128
test/models/contact/ident_test.rb
Normal file
128
test/models/contact/ident_test.rb
Normal file
|
@ -0,0 +1,128 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ContactIdentTest < ActiveSupport::TestCase
|
||||
def test_valid_ident_is_valid
|
||||
assert valid_ident.valid?, proc { valid_ident.errors.full_messages }
|
||||
end
|
||||
|
||||
def test_invalid_without_code
|
||||
ident = valid_ident
|
||||
ident.code = ''
|
||||
assert ident.invalid?
|
||||
end
|
||||
|
||||
def test_validates_date_of_birth
|
||||
ident = valid_ident
|
||||
ident.type = 'birthday'
|
||||
|
||||
ident.code = '2010-07-05'
|
||||
assert ident.valid?
|
||||
|
||||
ident.code = '2010-07-0'
|
||||
assert ident.invalid?
|
||||
end
|
||||
|
||||
# https://en.wikipedia.org/wiki/National_identification_number#Estonia
|
||||
def test_country_specific_national_id_format_validation
|
||||
country = Country.new('EE')
|
||||
ident = valid_ident
|
||||
ident.type = 'priv'
|
||||
ident.country_code = country.alpha2
|
||||
|
||||
ident.code = 'invalid'
|
||||
assert ident.invalid?
|
||||
assert_includes ident.errors.full_messages, "Code does not conform to national identification number format of #{country}"
|
||||
|
||||
ident.code = '47101010033'
|
||||
assert ident.valid?
|
||||
|
||||
ident.country_code = 'US'
|
||||
ident.code = 'any'
|
||||
assert ident.valid?
|
||||
end
|
||||
|
||||
def test_country_specific_company_registration_number_format_validation
|
||||
country = Country.new('EE')
|
||||
ident = valid_ident
|
||||
ident.type = 'org'
|
||||
ident.country_code = country.alpha2
|
||||
allowed_length = 8
|
||||
|
||||
ident.code = '1' * allowed_length.pred
|
||||
assert ident.invalid?
|
||||
assert_includes ident.errors.full_messages, "Code does not conform to registration number format of #{country}"
|
||||
|
||||
ident.code = '1' * allowed_length.next
|
||||
assert ident.invalid?
|
||||
|
||||
ident.code = '1' * allowed_length
|
||||
assert ident.valid?
|
||||
|
||||
ident.country_code = 'US'
|
||||
ident.code = 'any'
|
||||
assert ident.valid?
|
||||
end
|
||||
|
||||
def test_invalid_without_type
|
||||
ident = valid_ident
|
||||
ident.type = ''
|
||||
assert ident.invalid?
|
||||
end
|
||||
|
||||
def test_validates_type
|
||||
assert_not_includes Contact::Ident.types, 'invalid'
|
||||
ident = valid_ident
|
||||
ident.type = 'invalid'
|
||||
|
||||
assert ident.invalid?
|
||||
end
|
||||
|
||||
def test_invalid_without_country_code
|
||||
ident = valid_ident
|
||||
ident.country_code = ''
|
||||
assert ident.invalid?
|
||||
end
|
||||
|
||||
def test_validates_country_code_format
|
||||
ident = valid_ident
|
||||
|
||||
ident.country_code = 'invalid'
|
||||
assert ident.invalid?
|
||||
|
||||
ident.country_code = 'US'
|
||||
assert ident.valid?
|
||||
end
|
||||
|
||||
def test_validates_for_mismatches
|
||||
ident = valid_ident
|
||||
mismatch = Contact::Ident::MismatchValidator.mismatches.first
|
||||
ident.type = mismatch.type
|
||||
ident.country_code = mismatch.country.alpha2
|
||||
|
||||
assert ident.invalid?
|
||||
assert_includes ident.errors.full_messages, %(Ident type "#{ident.type}" is invalid for #{ident.country})
|
||||
end
|
||||
|
||||
def test_returns_types
|
||||
assert_equal %w[org priv birthday], Contact::Ident.types
|
||||
end
|
||||
|
||||
def test_returns_country
|
||||
country_code = 'US'
|
||||
ident = Contact::Ident.new(country_code: country_code)
|
||||
assert_equal Country.new(country_code), ident.country
|
||||
end
|
||||
|
||||
def test_equality
|
||||
assert_equal Contact::Ident.new(code: 'code', type: 'type', country_code: 'US'),
|
||||
Contact::Ident.new(code: 'code', type: 'type', country_code: 'US')
|
||||
assert_not_equal Contact::Ident.new(code: 'code', type: 'type', country_code: 'US'),
|
||||
Contact::Ident.new(code: 'code', type: 'type', country_code: 'GB')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def valid_ident
|
||||
Contact::Ident.new(code: '1234', type: 'priv', country_code: 'US')
|
||||
end
|
||||
end
|
|
@ -5,8 +5,8 @@ class ContactTest < ActiveSupport::TestCase
|
|||
@contact = contacts(:john)
|
||||
end
|
||||
|
||||
def test_valid_fixture_is_valid
|
||||
assert @contact.valid?, proc { @contact.errors.full_messages }
|
||||
def test_valid_contact_fixture_is_valid
|
||||
assert valid_contact.valid?, proc { valid_contact.errors.full_messages }
|
||||
end
|
||||
|
||||
def test_invalid_fixture_is_invalid
|
||||
|
@ -21,30 +21,106 @@ class ContactTest < ActiveSupport::TestCase
|
|||
assert_equal 'org', Contact::ORG
|
||||
end
|
||||
|
||||
def test_invalid_without_email
|
||||
@contact.email = ''
|
||||
assert @contact.invalid?
|
||||
def test_invalid_without_name
|
||||
contact = valid_contact
|
||||
contact.name = ''
|
||||
assert contact.invalid?
|
||||
end
|
||||
|
||||
def test_email_format_validation
|
||||
@contact.email = 'invalid'
|
||||
assert @contact.invalid?
|
||||
def test_validates_code_format
|
||||
contact = valid_contact.dup
|
||||
max_length = 100
|
||||
|
||||
@contact.email = 'test@bestmail.test'
|
||||
assert @contact.valid?
|
||||
contact.code = '!invalid'
|
||||
assert contact.invalid?
|
||||
|
||||
contact.code = 'a' * max_length.next
|
||||
assert contact.invalid?
|
||||
|
||||
contact.code = 'foo:bar'
|
||||
assert contact.valid?
|
||||
|
||||
contact.code = 'a' * max_length
|
||||
assert contact.valid?
|
||||
end
|
||||
|
||||
def test_invalid_when_code_is_already_taken
|
||||
another_contact = valid_contact
|
||||
contact = another_contact.dup
|
||||
|
||||
contact.code = another_contact.code
|
||||
assert contact.invalid?
|
||||
|
||||
contact.regenerate_code
|
||||
assert contact.valid?
|
||||
end
|
||||
|
||||
def test_invalid_without_email
|
||||
contact = valid_contact
|
||||
contact.email = ''
|
||||
assert contact.invalid?
|
||||
end
|
||||
|
||||
def test_validates_email_format
|
||||
contact = valid_contact
|
||||
|
||||
contact.email = 'invalid'
|
||||
assert contact.invalid?
|
||||
|
||||
contact.email = 'valid@registrar.test'
|
||||
assert contact.valid?
|
||||
end
|
||||
|
||||
def test_invalid_without_phone
|
||||
@contact.email = ''
|
||||
assert @contact.invalid?
|
||||
contact = valid_contact
|
||||
contact.phone = ''
|
||||
assert contact.invalid?
|
||||
end
|
||||
|
||||
def test_phone_format_validation
|
||||
@contact.phone = '+123.'
|
||||
assert @contact.invalid?
|
||||
# https://en.wikipedia.org/wiki/E.164
|
||||
def test_validates_phone_format
|
||||
contact = valid_contact
|
||||
|
||||
@contact.phone = '+123.4'
|
||||
assert @contact.valid?
|
||||
contact.phone = '+.1'
|
||||
assert contact.invalid?
|
||||
|
||||
contact.phone = '+123.'
|
||||
assert contact.invalid?
|
||||
|
||||
contact.phone = '+1.123456789123456'
|
||||
assert contact.invalid?
|
||||
|
||||
contact.phone = '+134.1234567891234'
|
||||
assert contact.invalid?
|
||||
|
||||
contact.phone = '+000.1'
|
||||
assert contact.invalid?
|
||||
|
||||
contact.phone = '+123.0'
|
||||
assert contact.invalid?
|
||||
|
||||
contact.phone = '+1.2'
|
||||
assert contact.valid?
|
||||
|
||||
contact.phone = '+123.4'
|
||||
assert contact.valid?
|
||||
|
||||
contact.phone = '+1.12345678912345'
|
||||
assert contact.valid?
|
||||
|
||||
contact.phone = '+134.123456789123'
|
||||
assert contact.valid?
|
||||
end
|
||||
|
||||
def test_valid_without_address_when_address_processing_id_disabled
|
||||
contact = valid_contact
|
||||
|
||||
contact.street = ''
|
||||
contact.city = ''
|
||||
contact.zip = ''
|
||||
contact.country_code = ''
|
||||
|
||||
assert contact.valid?
|
||||
end
|
||||
|
||||
def test_address
|
||||
|
@ -133,6 +209,45 @@ class ContactTest < ActiveSupport::TestCase
|
|||
assert_not @contact.deletable?
|
||||
end
|
||||
|
||||
def test_normalizes_country_code
|
||||
contact = Contact.new(country_code: 'us')
|
||||
contact.validate
|
||||
assert_equal 'US', contact.country_code
|
||||
end
|
||||
|
||||
def test_normalizes_ident_country_code
|
||||
contact = Contact.new(ident_country_code: 'us')
|
||||
contact.validate
|
||||
assert_equal 'US', contact.ident_country_code
|
||||
end
|
||||
|
||||
def test_generates_code
|
||||
contact = Contact.new(registrar: registrars(:bestnames))
|
||||
assert_nil contact.code
|
||||
|
||||
contact.generate_code
|
||||
|
||||
assert_not_empty contact.code
|
||||
end
|
||||
|
||||
def test_prohibits_code_change
|
||||
assert_no_changes -> { @contact.code } do
|
||||
@contact.code = 'new'
|
||||
@contact.save!
|
||||
@contact.reload
|
||||
end
|
||||
end
|
||||
|
||||
def test_removes_duplicate_statuses
|
||||
contact = Contact.new(statuses: %w[ok ok])
|
||||
assert_equal %w[ok], contact.statuses
|
||||
end
|
||||
|
||||
def test_default_status
|
||||
contact = Contact.new
|
||||
assert_equal %w[ok], contact.statuses
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def make_contact_free_of_domains_where_it_acts_as_a_registrant(contact)
|
||||
|
@ -146,4 +261,8 @@ class ContactTest < ActiveSupport::TestCase
|
|||
DomainContact.delete_all
|
||||
contacts(:john)
|
||||
end
|
||||
end
|
||||
|
||||
def valid_contact
|
||||
contacts(:john)
|
||||
end
|
||||
end
|
||||
|
|
132
test/models/dns/zone_test.rb
Normal file
132
test/models/dns/zone_test.rb
Normal file
|
@ -0,0 +1,132 @@
|
|||
require 'test_helper'
|
||||
|
||||
class DNS::ZoneTest < ActiveSupport::TestCase
|
||||
def test_valid_zone_fixture_is_valid
|
||||
assert valid_zone.valid?, proc { valid_zone.errors.full_messages }
|
||||
end
|
||||
|
||||
def test_invalid_without_origin
|
||||
zone = valid_zone
|
||||
zone.origin = ''
|
||||
assert zone.invalid?
|
||||
end
|
||||
|
||||
def test_invalid_when_origin_is_already_taken
|
||||
zone = valid_zone
|
||||
another_zone = zone.dup
|
||||
assert another_zone.invalid?
|
||||
end
|
||||
|
||||
def test_invalid_without_ttl
|
||||
zone = valid_zone
|
||||
zone.ttl = ''
|
||||
assert zone.invalid?
|
||||
end
|
||||
|
||||
def test_validates_ttl_format
|
||||
zone = valid_zone
|
||||
|
||||
zone.ttl = 'text'
|
||||
assert zone.invalid?
|
||||
|
||||
zone.ttl = '1.1'
|
||||
assert zone.invalid?
|
||||
|
||||
zone.ttl = '1'
|
||||
assert zone.valid?
|
||||
end
|
||||
|
||||
def test_invalid_without_refresh
|
||||
zone = valid_zone
|
||||
zone.refresh = ''
|
||||
assert zone.invalid?
|
||||
end
|
||||
|
||||
def test_validates_refresh_format
|
||||
zone = valid_zone
|
||||
|
||||
zone.refresh = 'text'
|
||||
assert zone.invalid?
|
||||
|
||||
zone.refresh = '1.1'
|
||||
assert zone.invalid?
|
||||
|
||||
zone.refresh = '1'
|
||||
assert zone.valid?
|
||||
end
|
||||
|
||||
def test_invalid_without_retry
|
||||
zone = valid_zone
|
||||
zone.retry = ''
|
||||
assert zone.invalid?
|
||||
end
|
||||
|
||||
def test_validates_retry_format
|
||||
zone = valid_zone
|
||||
|
||||
zone.retry = 'text'
|
||||
assert zone.invalid?
|
||||
|
||||
zone.retry = '1.1'
|
||||
assert zone.invalid?
|
||||
|
||||
zone.retry = '1'
|
||||
assert zone.valid?
|
||||
end
|
||||
|
||||
def test_invalid_without_expire
|
||||
zone = valid_zone
|
||||
zone.expire = ''
|
||||
assert zone.invalid?
|
||||
end
|
||||
|
||||
def test_validates_expire_format
|
||||
zone = valid_zone
|
||||
|
||||
zone.expire = 'text'
|
||||
assert zone.invalid?
|
||||
|
||||
zone.expire = '1.1'
|
||||
assert zone.invalid?
|
||||
|
||||
zone.expire = '1'
|
||||
assert zone.valid?
|
||||
end
|
||||
|
||||
def test_invalid_without_minimum_ttl
|
||||
zone = valid_zone
|
||||
zone.minimum_ttl = ''
|
||||
assert zone.invalid?
|
||||
end
|
||||
|
||||
def test_validates_minimum_ttl_format
|
||||
zone = valid_zone
|
||||
|
||||
zone.minimum_ttl = 'text'
|
||||
assert zone.invalid?
|
||||
|
||||
zone.minimum_ttl = '1.1'
|
||||
assert zone.invalid?
|
||||
|
||||
zone.minimum_ttl = '1'
|
||||
assert zone.valid?
|
||||
end
|
||||
|
||||
def test_invalid_without_email
|
||||
zone = valid_zone
|
||||
zone.email = ''
|
||||
assert zone.invalid?
|
||||
end
|
||||
|
||||
def test_invalid_without_master_nameserver
|
||||
zone = valid_zone
|
||||
zone.master_nameserver = ''
|
||||
assert zone.invalid?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def valid_zone
|
||||
dns_zones(:one)
|
||||
end
|
||||
end
|
|
@ -3,16 +3,271 @@ require 'test_helper'
|
|||
class DomainTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@domain = domains(:shop)
|
||||
|
||||
@original_nameserver_required = Setting.nameserver_required
|
||||
@original_min_admin_contact_count = Setting.admin_contacts_min_count
|
||||
@original_max_admin_contact_count = Setting.admin_contacts_max_count
|
||||
@original_min_tech_contact_count = Setting.tech_contacts_min_count
|
||||
@original_max_tech_contact_count = Setting.tech_contacts_max_count
|
||||
end
|
||||
|
||||
def test_valid_fixture_is_valid
|
||||
assert @domain.valid?
|
||||
teardown do
|
||||
Setting.nameserver_required = @original_nameserver_required
|
||||
Setting.admin_contacts_min_count = @original_min_admin_contact_count
|
||||
Setting.admin_contacts_max_count = @original_max_admin_contact_count
|
||||
Setting.tech_contacts_min_count = @original_min_tech_contact_count
|
||||
Setting.tech_contacts_max_count = @original_max_tech_contact_count
|
||||
end
|
||||
|
||||
def test_valid_domain_is_valid
|
||||
assert valid_domain.valid?, proc { valid_domain.errors.full_messages }
|
||||
end
|
||||
|
||||
def test_invalid_fixture_is_invalid
|
||||
assert domains(:invalid).invalid?
|
||||
end
|
||||
|
||||
# https://www.internet.ee/domeenid/ee-domeenireeglid#domeeninimede-registreerimine
|
||||
def test_validates_name_format
|
||||
assert_equal dns_zones(:one).origin, 'test'
|
||||
domain = valid_domain
|
||||
subdomain_min_length = 2
|
||||
subdomain_max_length = 63
|
||||
|
||||
domain.name = '!invalid'
|
||||
assert domain.invalid?
|
||||
|
||||
domain.name = 'aa--a.test'
|
||||
assert domain.invalid?
|
||||
|
||||
domain.name = '-example.test'
|
||||
assert domain.invalid?
|
||||
|
||||
domain.name = 'example-.test'
|
||||
assert domain.invalid?
|
||||
|
||||
domain.name = "#{'a' * subdomain_min_length.pred}.test"
|
||||
assert domain.invalid?
|
||||
|
||||
domain.name = "#{'a' * subdomain_max_length.next}.test"
|
||||
assert domain.invalid?
|
||||
|
||||
domain.name = 'рф.test'
|
||||
assert domain.invalid?
|
||||
|
||||
domain.name = "#{'a' * subdomain_min_length}.test"
|
||||
assert domain.valid?
|
||||
|
||||
domain.name = "#{'a' * subdomain_max_length}.test"
|
||||
assert domain.valid?
|
||||
|
||||
domain.name = 'example-1-2.test'
|
||||
assert domain.valid?
|
||||
|
||||
domain.name = 'EXAMPLE.test'
|
||||
assert domain.valid?
|
||||
|
||||
domain.name = 'äõöüšž.test'
|
||||
assert domain.valid?
|
||||
|
||||
domain.name = 'xn--mnchen-3ya.test'
|
||||
assert domain.valid?
|
||||
end
|
||||
|
||||
def test_invalid_when_name_is_already_taken
|
||||
Setting.admin_contacts_min_count = Setting.tech_contacts_min_count = 0
|
||||
another_domain = valid_domain
|
||||
domain = another_domain.dup
|
||||
|
||||
domain.name = another_domain.name
|
||||
assert domain.invalid?
|
||||
|
||||
domain.name = "new.#{dns_zones(:one).origin}"
|
||||
assert domain.valid?, proc { domain.errors.full_messages }
|
||||
end
|
||||
|
||||
def test_invalid_when_name_is_zone
|
||||
name = dns_zones(:one).origin
|
||||
domain = valid_domain
|
||||
|
||||
domain.name = name
|
||||
|
||||
assert domain.invalid?
|
||||
assert_includes domain.errors.full_messages, 'Data management policy violation:' \
|
||||
' Domain name is blocked [name]'
|
||||
end
|
||||
|
||||
def test_invalid_without_transfer_code
|
||||
domain = valid_domain
|
||||
domain.transfer_code = ''
|
||||
assert domain.invalid?
|
||||
end
|
||||
|
||||
def test_invalid_when_domain_is_reserved
|
||||
reserved_domain = reserved_domains(:one)
|
||||
domain = valid_domain.dup
|
||||
domain.name = reserved_domain.name
|
||||
|
||||
assert domain.invalid?
|
||||
assert_includes domain.errors.full_messages, 'Required parameter missing; reserved>' \
|
||||
'pw element required for reserved domains'
|
||||
end
|
||||
|
||||
def test_invalid_without_registration_period
|
||||
domain = valid_domain
|
||||
domain.period = ''
|
||||
assert domain.invalid?
|
||||
end
|
||||
|
||||
def test_validates_registration_period_format
|
||||
domain = valid_domain
|
||||
|
||||
domain.period = 'invalid'
|
||||
assert domain.invalid?
|
||||
|
||||
domain.period = 1.1
|
||||
assert domain.invalid?
|
||||
|
||||
domain.period = 1
|
||||
assert domain.valid?
|
||||
end
|
||||
|
||||
def test_invalid_when_the_same_admin_contact_is_linked_twice
|
||||
domain = valid_domain
|
||||
contact = contacts(:john)
|
||||
|
||||
domain.admin_contacts << contact
|
||||
domain.admin_contacts << contact
|
||||
|
||||
assert domain.invalid?
|
||||
end
|
||||
|
||||
def test_invalid_when_the_same_tech_contact_is_linked_twice
|
||||
domain = valid_domain
|
||||
contact = contacts(:john)
|
||||
|
||||
domain.tech_contacts << contact
|
||||
domain.tech_contacts << contact
|
||||
|
||||
assert domain.invalid?
|
||||
end
|
||||
|
||||
def test_validates_name_server_count_when_name_servers_are_required
|
||||
nameserver_attributes = nameservers(:shop_ns1).dup.attributes
|
||||
domain = valid_domain
|
||||
Setting.nameserver_required = true
|
||||
min_count = 1
|
||||
max_count = 2
|
||||
Setting.ns_min_count = min_count
|
||||
Setting.ns_max_count = max_count
|
||||
|
||||
domain.nameservers.clear
|
||||
min_count.times { domain.nameservers.build(nameserver_attributes) }
|
||||
assert domain.valid?, proc { domain.errors.full_messages }
|
||||
|
||||
domain.nameservers.clear
|
||||
max_count.times do |i|
|
||||
domain.nameservers.build(nameserver_attributes.merge(hostname: "ns#{i}.test"))
|
||||
end
|
||||
assert domain.valid?, proc { domain.errors.full_messages }
|
||||
|
||||
domain.nameservers.clear
|
||||
assert domain.invalid?
|
||||
|
||||
domain.nameservers.clear
|
||||
max_count.next.times do |i|
|
||||
domain.nameservers.build(nameserver_attributes.merge(hostname: "ns#{i}.test"))
|
||||
end
|
||||
assert domain.invalid?
|
||||
end
|
||||
|
||||
def test_valid_without_name_servers_when_they_are_optional
|
||||
domain = valid_domain
|
||||
domain.nameservers.clear
|
||||
Setting.nameserver_required = false
|
||||
Setting.ns_min_count = 1
|
||||
|
||||
assert domain.valid?
|
||||
end
|
||||
|
||||
def test_validates_admin_contact_count
|
||||
domain_contact_attributes = domain_contacts(:shop_jane).dup.attributes
|
||||
domain = valid_domain
|
||||
min_count = 1
|
||||
max_count = 2
|
||||
Setting.admin_contacts_min_count = min_count
|
||||
Setting.admin_contacts_max_count = max_count
|
||||
|
||||
domain.admin_domain_contacts.clear
|
||||
min_count.times { domain.admin_domain_contacts.build(domain_contact_attributes) }
|
||||
assert domain.valid?, proc { domain.errors.full_messages }
|
||||
|
||||
domain.admin_domain_contacts.clear
|
||||
max_count.times { domain.admin_domain_contacts.build(domain_contact_attributes) }
|
||||
assert domain.valid?, proc { domain.errors.full_messages }
|
||||
|
||||
domain.admin_domain_contacts.clear
|
||||
assert domain.invalid?
|
||||
|
||||
domain.admin_domain_contacts.clear
|
||||
max_count.next.times { domain.admin_domain_contacts.build(domain_contact_attributes) }
|
||||
assert domain.invalid?
|
||||
end
|
||||
|
||||
def test_validates_tech_contact_count
|
||||
domain_contact_attributes = domain_contacts(:shop_william).dup.attributes
|
||||
domain = valid_domain
|
||||
min_count = 1
|
||||
max_count = 2
|
||||
Setting.tech_contacts_min_count = min_count
|
||||
Setting.tech_contacts_max_count = max_count
|
||||
|
||||
domain.tech_domain_contacts.clear
|
||||
min_count.times { domain.tech_domain_contacts.build(domain_contact_attributes) }
|
||||
assert domain.valid?, proc { domain.errors.full_messages }
|
||||
|
||||
domain.tech_domain_contacts.clear
|
||||
max_count.times { domain.tech_domain_contacts.build(domain_contact_attributes) }
|
||||
assert domain.valid?, proc { domain.errors.full_messages }
|
||||
|
||||
domain.tech_domain_contacts.clear
|
||||
assert domain.invalid?
|
||||
|
||||
domain.tech_domain_contacts.clear
|
||||
max_count.next.times { domain.tech_domain_contacts.build(domain_contact_attributes) }
|
||||
assert domain.invalid?
|
||||
end
|
||||
|
||||
def test_outzone_candidates_scope_returns_records_with_outzone_at_in_the_past
|
||||
travel_to Time.zone.parse('2010-07-05 08:00:00')
|
||||
domain1 = domains(:shop)
|
||||
domain1.update!(outzone_at: Time.zone.parse('2010-07-05 07:59:59'))
|
||||
domain2 = domains(:airport)
|
||||
domain2.update!(outzone_at: Time.zone.parse('2010-07-05 08:00:00'))
|
||||
domain3 = domains(:library)
|
||||
domain3.update!(outzone_at: Time.zone.parse('2010-07-05 08:00:01'))
|
||||
Domain.connection.disable_referential_integrity do
|
||||
Domain.delete_all("id NOT IN (#{[domain1.id, domain2.id, domain3.id].join(',')})")
|
||||
end
|
||||
|
||||
assert_equal [domain1.id], Domain.outzone_candidates.ids
|
||||
end
|
||||
|
||||
def test_expired_scope_returns_records_with_valid_to_in_the_past
|
||||
travel_to Time.zone.parse('2010-07-05 08:00:00')
|
||||
domain1 = domains(:shop)
|
||||
domain1.update!(valid_to: Time.zone.parse('2010-07-05 07:59:59'))
|
||||
domain2 = domains(:airport)
|
||||
domain2.update!(valid_to: Time.zone.parse('2010-07-05 08:00:00'))
|
||||
domain3 = domains(:library)
|
||||
domain3.update!(valid_to: Time.zone.parse('2010-07-05 08:00:01'))
|
||||
Domain.connection.disable_referential_integrity do
|
||||
Domain.delete_all("id NOT IN (#{[domain1.id, domain2.id, domain3.id].join(',')})")
|
||||
end
|
||||
|
||||
assert_equal [domain1.id, domain2.id], Domain.expired.ids
|
||||
end
|
||||
|
||||
def test_domain_name
|
||||
domain = Domain.new(name: 'shop.test')
|
||||
assert_equal 'shop.test', domain.domain_name.to_s
|
||||
|
@ -79,4 +334,87 @@ class DomainTest < ActiveSupport::TestCase
|
|||
|
||||
assert_equal %w[john@inbox.test william@inbox.test].sort, @domain.primary_contact_emails.sort
|
||||
end
|
||||
end
|
||||
|
||||
def test_normalizes_name
|
||||
unnormalized_name = ' Foo.test '
|
||||
domain = Domain.new(name: unnormalized_name)
|
||||
|
||||
assert_equal 'foo.test', domain.name
|
||||
assert_equal 'foo.test', domain.name_puny
|
||||
assert_equal unnormalized_name, domain.name_dirty
|
||||
end
|
||||
|
||||
def test_converts_name_to_punycode
|
||||
domain = Domain.new(name: 'münchen.test')
|
||||
assert_equal 'xn--mnchen-3ya.test', domain.name_puny
|
||||
end
|
||||
|
||||
def test_returns_new_registrant_id
|
||||
id = 1
|
||||
domain = Domain.new(pending_json: { new_registrant_id: id })
|
||||
|
||||
assert_equal id, domain.new_registrant_id
|
||||
end
|
||||
|
||||
def test_returns_new_registrant_email
|
||||
email = 'john@inbox.test'
|
||||
domain = Domain.new(pending_json: { new_registrant_email: email })
|
||||
|
||||
assert_equal email, domain.new_registrant_email
|
||||
end
|
||||
|
||||
def test_expiration
|
||||
now = Time.zone.parse('2010-07-05 08:00:00')
|
||||
travel_to now
|
||||
domain = Domain.new
|
||||
|
||||
domain.valid_to = now + 1.second
|
||||
assert domain.registered?
|
||||
assert_not domain.expired?
|
||||
|
||||
domain.valid_to = now
|
||||
assert domain.expired?
|
||||
assert_not domain.registered?
|
||||
|
||||
domain.valid_to = now - 1.second
|
||||
assert domain.expired?
|
||||
assert_not domain.registered?
|
||||
end
|
||||
|
||||
def test_activation
|
||||
domain = inactive_domain
|
||||
|
||||
assert domain.inactive?
|
||||
assert_not domain.active?
|
||||
|
||||
domain.activate
|
||||
|
||||
assert domain.active?
|
||||
assert_not domain.inactive?
|
||||
end
|
||||
|
||||
def test_deactivation
|
||||
domain = @domain
|
||||
|
||||
assert domain.active?
|
||||
assert_not domain.inactive?
|
||||
|
||||
domain.deactivate
|
||||
|
||||
assert domain.inactive?
|
||||
assert_not domain.active?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def valid_domain
|
||||
domains(:shop)
|
||||
end
|
||||
|
||||
def inactive_domain
|
||||
Setting.nameserver_required = true
|
||||
domain = @domain
|
||||
domain.update!(statuses: [DomainStatus::INACTIVE])
|
||||
domain
|
||||
end
|
||||
end
|
||||
|
|
54
test/models/white_ip_test.rb
Normal file
54
test/models/white_ip_test.rb
Normal file
|
@ -0,0 +1,54 @@
|
|||
require 'test_helper'
|
||||
|
||||
class WhiteIpTest < ActiveSupport::TestCase
|
||||
def test_either_ipv4_or_ipv6_is_required
|
||||
white_ip = valid_white_ip
|
||||
|
||||
white_ip.ipv4 = ''
|
||||
white_ip.ipv6 = ''
|
||||
assert white_ip.invalid?
|
||||
assert_includes white_ip.errors.full_messages, 'IPv4 or IPv6 must be present'
|
||||
|
||||
white_ip.ipv4 = valid_ipv4
|
||||
white_ip.ipv6 = ''
|
||||
assert white_ip.valid?
|
||||
|
||||
white_ip.ipv4 = ''
|
||||
white_ip.ipv6 = valid_ipv6
|
||||
assert white_ip.valid?
|
||||
end
|
||||
|
||||
def test_validates_ipv4_format
|
||||
white_ip = valid_white_ip
|
||||
|
||||
white_ip.ipv4 = 'invalid'
|
||||
assert white_ip.invalid?
|
||||
|
||||
white_ip.ipv4 = valid_ipv4
|
||||
assert white_ip.valid?
|
||||
end
|
||||
|
||||
def test_validates_ipv6_format
|
||||
white_ip = valid_white_ip
|
||||
|
||||
white_ip.ipv6 = 'invalid'
|
||||
assert white_ip.invalid?
|
||||
|
||||
white_ip.ipv6 = valid_ipv6
|
||||
assert white_ip.valid?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def valid_white_ip
|
||||
white_ips(:one)
|
||||
end
|
||||
|
||||
def valid_ipv4
|
||||
'192.0.2.1'
|
||||
end
|
||||
|
||||
def valid_ipv6
|
||||
'2001:db8::1'
|
||||
end
|
||||
end
|
47
test/system/admin_area/prices_test.rb
Normal file
47
test/system/admin_area/prices_test.rb
Normal file
|
@ -0,0 +1,47 @@
|
|||
require 'application_system_test_case'
|
||||
|
||||
class AdminAreaPricesTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in users(:admin)
|
||||
@price = billing_prices(:create_one_month)
|
||||
end
|
||||
|
||||
def test_adds_new_price_with_required_attributes
|
||||
effective_date = Date.parse('2010-07-06')
|
||||
assert_nil Billing::Price.find_by(valid_from: effective_date)
|
||||
|
||||
visit admin_prices_url
|
||||
click_on 'New price'
|
||||
|
||||
select dns_zones(:one).origin, from: 'Zone'
|
||||
select Billing::Price.operation_categories.first, from: 'Operation category'
|
||||
select '3 months', from: 'Duration'
|
||||
fill_in 'Price', with: '1'
|
||||
fill_in 'Valid from', with: effective_date
|
||||
click_on 'Create price'
|
||||
|
||||
assert_text 'Price has been created'
|
||||
assert_text I18n.localize(effective_date)
|
||||
end
|
||||
|
||||
def test_changes_price
|
||||
new_effective_date = Date.parse('2010-07-06')
|
||||
assert_not_equal new_effective_date, @price.valid_from
|
||||
|
||||
visit admin_prices_url
|
||||
find('.edit-price-btn').click
|
||||
fill_in 'Valid from', with: new_effective_date
|
||||
click_on 'Update price'
|
||||
|
||||
assert_text 'Price has been updated'
|
||||
assert_text I18n.localize(new_effective_date)
|
||||
end
|
||||
|
||||
def test_expires_price
|
||||
visit admin_prices_url
|
||||
find('.edit-price-btn').click
|
||||
click_on 'Expire'
|
||||
|
||||
assert_text 'Price has been expired'
|
||||
end
|
||||
end
|
13
test/system/admin_area/settings_test.rb
Normal file
13
test/system/admin_area/settings_test.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
require 'application_system_test_case'
|
||||
|
||||
class AdminAreaSettingsTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in users(:admin)
|
||||
end
|
||||
|
||||
def test_saves_settings
|
||||
visit admin_settings_url
|
||||
click_link_or_button 'Save'
|
||||
assert_text 'Settings have been successfully updated'
|
||||
end
|
||||
end
|
46
test/system/admin_area/zones_test.rb
Normal file
46
test/system/admin_area/zones_test.rb
Normal file
|
@ -0,0 +1,46 @@
|
|||
require 'application_system_test_case'
|
||||
|
||||
class AdminAreaZonesTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
sign_in users(:admin)
|
||||
@zone = dns_zones(:one)
|
||||
end
|
||||
|
||||
def test_creates_new_zone_with_required_attributes
|
||||
origin = 'com.test'
|
||||
assert_nil DNS::Zone.find_by(origin: origin)
|
||||
|
||||
visit admin_zones_url
|
||||
click_on 'New zone'
|
||||
|
||||
fill_in 'Origin', with: origin
|
||||
fill_in 'Ttl', with: '1'
|
||||
fill_in 'Refresh', with: '1'
|
||||
fill_in 'Retry', with: '1'
|
||||
fill_in 'Expire', with: '1'
|
||||
fill_in 'Minimum ttl', with: '1'
|
||||
fill_in 'Email', with: 'new.registry.test'
|
||||
fill_in 'Master nameserver', with: 'any.test'
|
||||
click_on 'Create zone'
|
||||
|
||||
assert_text 'Zone has been created'
|
||||
assert_text origin
|
||||
end
|
||||
|
||||
def test_changes_zone
|
||||
new_email = 'new@registry.test'
|
||||
assert_not_equal new_email, @zone.email
|
||||
|
||||
visit admin_zones_url
|
||||
click_on 'admin-edit-zone-btn'
|
||||
fill_in 'Email', with: new_email
|
||||
click_on 'Update zone'
|
||||
|
||||
assert_text 'Zone has been updated'
|
||||
end
|
||||
|
||||
def test_origin_is_not_editable
|
||||
visit edit_admin_zone_url(@zone)
|
||||
assert_no_field 'Origin'
|
||||
end
|
||||
end
|
33
test/system/registrar_area/base_test.rb
Normal file
33
test/system/registrar_area/base_test.rb
Normal file
|
@ -0,0 +1,33 @@
|
|||
require 'application_system_test_case'
|
||||
|
||||
class RegistrarAreaBaseTestTest < ApplicationSystemTestCase
|
||||
def test_user_cannot_access_without_ip_address_being_whitelisted
|
||||
Setting.registrar_ip_whitelist_enabled = true
|
||||
WhiteIp.delete_all
|
||||
|
||||
visit new_registrar_user_session_url
|
||||
|
||||
assert_text 'Access denied from IP 127.0.0.1'
|
||||
assert_no_button 'Login'
|
||||
end
|
||||
|
||||
def test_user_can_access_when_ip_is_whitelisted
|
||||
white_ips(:one).update!(ipv4: '127.0.0.1', interfaces: [WhiteIp::REGISTRAR])
|
||||
Setting.registrar_ip_whitelist_enabled = true
|
||||
|
||||
visit new_registrar_user_session_url
|
||||
|
||||
assert_no_text 'Access denied from IP 127.0.0.1'
|
||||
assert_button 'Login'
|
||||
end
|
||||
|
||||
def test_user_can_access_when_ip_is_not_whitelisted_and_whitelist_is_disabled
|
||||
Setting.registrar_ip_whitelist_enabled = false
|
||||
WhiteIp.delete_all
|
||||
|
||||
visit new_registrar_user_session_url
|
||||
|
||||
assert_no_text 'Access denied from IP 127.0.0.1'
|
||||
assert_button 'Login'
|
||||
end
|
||||
end
|
|
@ -1,6 +1,13 @@
|
|||
if ENV['COVERAGE']
|
||||
require 'simplecov'
|
||||
SimpleCov.command_name 'test'
|
||||
SimpleCov.start 'rails' do
|
||||
add_filter '/app/models/legacy/'
|
||||
add_filter '/app/models/version/'
|
||||
add_filter '/lib/action_controller/'
|
||||
add_filter '/lib/core_ext/'
|
||||
add_filter '/lib/daemons/'
|
||||
add_filter '/lib/gem_ext/'
|
||||
end
|
||||
end
|
||||
|
||||
ENV['RAILS_ENV'] ||= 'test'
|
||||
|
@ -29,8 +36,6 @@ CompanyRegister::Client = CompanyRegisterClientStub
|
|||
EInvoice.provider = EInvoice::Providers::TestProvider.new
|
||||
|
||||
class ActiveSupport::TestCase
|
||||
include FactoryBot::Syntax::Methods
|
||||
|
||||
ActiveRecord::Migration.check_pending!
|
||||
fixtures :all
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue