Introduce custom assertion

This commit is contained in:
Artur Beljajev 2019-09-03 18:15:58 +03:00
parent 5939da366e
commit 348e6e5d7a
54 changed files with 378 additions and 389 deletions

View file

@ -1,7 +1,7 @@
# encoding: UTF-8
require 'test_helper'
class EppDomainCreateAuctionIdnTest < ApplicationIntegrationTest
class EppDomainCreateAuctionIdnTest < EppTestCase
def setup
super
@ -46,11 +46,7 @@ class EppDomainCreateAuctionIdnTest < ApplicationIntegrationTest
@idn_auction.reload
refute @idn_auction.domain_registered?
response_xml = Nokogiri::XML(response.body)
assert_equal '2003', response_xml.at_css('result')[:code]
assert_equal 'Required parameter missing; reserved>pw element is required',
response_xml.at_css('result msg').text
assert_epp_response :required_parameter_missing
end
def test_domain_with_unicode_idn_cannot_be_registered_without_registration_code
@ -84,11 +80,7 @@ class EppDomainCreateAuctionIdnTest < ApplicationIntegrationTest
@idn_auction.reload
refute @idn_auction.domain_registered?
response_xml = Nokogiri::XML(response.body)
assert_equal '2003', response_xml.at_css('result')[:code]
assert_equal 'Required parameter missing; reserved>pw element is required',
response_xml.at_css('result msg').text
assert_epp_response :required_parameter_missing
end
def test_domain_with_ascii_idn_cannot_be_registered_without_winning_the_auction
@ -121,11 +113,7 @@ class EppDomainCreateAuctionIdnTest < ApplicationIntegrationTest
@idn_auction.reload
refute @idn_auction.domain_registered?
response_xml = Nokogiri::XML(response.body)
assert_equal '2306', response_xml.at_css('result')[:code]
assert_equal 'Parameter value policy error: domain is at auction',
response_xml.at_css('result msg').text
assert_epp_response :parameter_value_policy_error
end
def test_domain_with_unicode_idn_cannot_be_registered_without_winning_the_auction
@ -195,11 +183,7 @@ class EppDomainCreateAuctionIdnTest < ApplicationIntegrationTest
@idn_auction.reload
refute @idn_auction.domain_registered?
response_xml = Nokogiri::XML(response.body)
assert_equal '2306', response_xml.at_css('result')[:code]
assert_equal 'Parameter value policy error: domain is at auction',
response_xml.at_css('result msg').text
assert_epp_response :parameter_value_policy_error
end
def test_registers_unicode_domain_with_correct_registration_code_when_payment_is_received
@ -235,10 +219,7 @@ class EppDomainCreateAuctionIdnTest < ApplicationIntegrationTest
@idn_auction.reload
assert @idn_auction.domain_registered?
assert Domain.where(name: @idn_auction.domain).exists?
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
assert_epp_response :completed_successfully
end
def test_registers_ascii_domain_with_correct_registration_code_when_payment_is_received
@ -274,9 +255,6 @@ class EppDomainCreateAuctionIdnTest < ApplicationIntegrationTest
@idn_auction.reload
assert @idn_auction.domain_registered?
assert Domain.where(name: @idn_auction.domain).exists?
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
assert_epp_response :completed_successfully
end
end

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppDomainCreateAuctionTest < ApplicationIntegrationTest
class EppDomainCreateAuctionTest < EppTestCase
setup do
@auction = auctions(:one)
Domain.release_to_auction = true
@ -33,9 +33,7 @@ class EppDomainCreateAuctionTest < ApplicationIntegrationTest
assert_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
end
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
assert_epp_response :completed_successfully
end
def test_registers_domain_with_correct_registration_code_after_another_auction_when_payment_is_received
@ -72,9 +70,7 @@ class EppDomainCreateAuctionTest < ApplicationIntegrationTest
assert_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
end
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
assert_epp_response :completed_successfully
end
def test_registers_domain_with_correct_registration_code_when_payment_is_received
@ -109,10 +105,7 @@ class EppDomainCreateAuctionTest < ApplicationIntegrationTest
@auction.reload
assert @auction.domain_registered?
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
assert_epp_response :completed_successfully
end
def test_domain_cannot_be_registered_without_registration_code
@ -141,10 +134,7 @@ class EppDomainCreateAuctionTest < ApplicationIntegrationTest
assert_no_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
end
response_xml = Nokogiri::XML(response.body)
assert_equal '2003', response_xml.at_css('result')[:code]
assert_equal 'Required parameter missing; reserved>pw element is required',
response_xml.at_css('result msg').text
assert_epp_response :required_parameter_missing
end
def test_domain_cannot_be_registered_with_wrong_registration_code
@ -176,10 +166,7 @@ class EppDomainCreateAuctionTest < ApplicationIntegrationTest
assert_no_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
end
response_xml = Nokogiri::XML(response.body)
assert_equal '2202', response_xml.at_css('result')[:code]
assert_equal 'Invalid authorization information; invalid reserved>pw value',
response_xml.at_css('result msg').text
assert_epp_response :invalid_authorization_information
end
def test_domain_cannot_be_registered_when_payment_is_not_received
@ -210,10 +197,7 @@ class EppDomainCreateAuctionTest < ApplicationIntegrationTest
assert_no_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
end
response_xml = Nokogiri::XML(response.body)
assert_equal '2003', response_xml.at_css('result')[:code]
assert_equal 'Required parameter missing; reserved>pw element required for reserved domains',
response_xml.at_css('result msg').text
assert_epp_response :required_parameter_missing
end
def test_domain_cannot_be_registered_when_at_auction
@ -240,9 +224,6 @@ class EppDomainCreateAuctionTest < ApplicationIntegrationTest
assert_no_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
end
response_xml = Nokogiri::XML(response.body)
assert_equal '2306', response_xml.at_css('result')[:code]
assert_equal 'Parameter value policy error: domain is at auction',
response_xml.at_css('result msg').text
assert_epp_response :parameter_value_policy_error
end
end

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppDomainCreateBaseTest < ApplicationIntegrationTest
class EppDomainCreateBaseTest < EppTestCase
def test_domain_can_be_registered_with_required_attributes_only
request_xml = <<-XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
@ -28,9 +28,6 @@ class EppDomainCreateBaseTest < ApplicationIntegrationTest
domain = Domain.last
assert_equal 'new.test', domain.name
assert_equal contacts(:john).becomes(Registrant), domain.registrant
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
assert_epp_response :completed_successfully
end
end

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppDomainCreateNameserversTest < ApplicationIntegrationTest
class EppDomainCreateNameserversTest < EppTestCase
# Glue record requirement
def test_nameserver_ip_address_is_required_if_hostname_is_under_the_same_domain
request_xml = <<-XML
@ -30,6 +30,6 @@ class EppDomainCreateNameserversTest < ApplicationIntegrationTest
assert_no_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
end
assert_equal '2003', Nokogiri::XML(response.body).at_css('result')[:code]
assert_epp_response :required_parameter_missing
end
end

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppDomainCreateReservedTest < ApplicationIntegrationTest
class EppDomainCreateReservedTest < EppTestCase
setup do
@reserved_domain = reserved_domains(:one)
end
@ -34,10 +34,7 @@ class EppDomainCreateReservedTest < ApplicationIntegrationTest
assert_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
end
response_xml = Nokogiri::XML(response.body)
assert_equal '1000', response_xml.at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
assert_epp_response :completed_successfully
end
def test_registering_reserved_domain_regenerates_registration_code
@ -101,11 +98,7 @@ class EppDomainCreateReservedTest < ApplicationIntegrationTest
assert_no_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
end
response_xml = Nokogiri::XML(response.body)
assert_equal '2202', response_xml.at_css('result')[:code]
assert_equal 'Invalid authorization information; invalid reserved>pw value',
response_xml.at_css('result msg').text
assert_epp_response :invalid_authorization_information
end
def test_domain_cannot_be_registered_without_registration_code
@ -133,10 +126,6 @@ class EppDomainCreateReservedTest < ApplicationIntegrationTest
assert_no_difference 'Domain.count' do
post '/epp/command/create', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
end
response_xml = Nokogiri::XML(response.body)
assert_equal '2003', response_xml.at_css('result')[:code]
assert_equal 'Required parameter missing; reserved>pw element required for reserved domains',
response_xml.at_css('result msg').text
assert_epp_response :required_parameter_missing
end
end

View file

@ -1,6 +1,6 @@
require 'test_helper'
class EppDomainCreateTransferCodeTest < ApplicationIntegrationTest
class EppDomainCreateTransferCodeTest < EppTestCase
setup do
travel_to Time.zone.parse('2010-07-05')
end
@ -28,8 +28,7 @@ class EppDomainCreateTransferCodeTest < ApplicationIntegrationTest
post '/epp/command/create', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
refute_empty Domain.find_by(name: 'brandnew.test').transfer_code
assert_equal '1000', Nokogiri::XML(response.body).at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
assert_epp_response :completed_successfully
end
def test_honors_custom
@ -58,7 +57,6 @@ class EppDomainCreateTransferCodeTest < ApplicationIntegrationTest
post '/epp/command/create', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
assert_equal '1058ad73', Domain.find_by(name: 'brandnew.test').transfer_code
assert_equal '1000', Nokogiri::XML(response.body).at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
assert_epp_response :completed_successfully
end
end