mirror of
https://github.com/internetee/registry.git
synced 2025-06-12 07:34:45 +02:00
Introduce custom assertion
This commit is contained in:
parent
5939da366e
commit
348e6e5d7a
54 changed files with 378 additions and 389 deletions
|
@ -1,22 +1,27 @@
|
|||
module EPP
|
||||
module Epp
|
||||
class Response
|
||||
attr_accessor :results
|
||||
attr_reader :results
|
||||
|
||||
def self.from_xml(xml)
|
||||
def self.xml(xml)
|
||||
xml_doc = Nokogiri::XML(xml)
|
||||
response = new
|
||||
|
||||
result_elements = xml_doc.css('result')
|
||||
results = []
|
||||
|
||||
result_elements.each do |result_element|
|
||||
response.results << Result.new(result_element[:code].to_s, result_element.text.strip)
|
||||
code_value = result_element[:code]
|
||||
code = Result::Code.new(code_value)
|
||||
results << Result.new(code: code)
|
||||
end
|
||||
|
||||
response
|
||||
new(results: results)
|
||||
end
|
||||
|
||||
def initialize
|
||||
@results = []
|
||||
def initialize(results:)
|
||||
@results = results
|
||||
end
|
||||
|
||||
def code?(code)
|
||||
results.any? { |result| result.code == code }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,27 +1,10 @@
|
|||
module EPP
|
||||
module Epp
|
||||
class Response
|
||||
class Result
|
||||
CODE_TO_TYPE = {
|
||||
'1000' => :success,
|
||||
'1001' => :success_pending,
|
||||
'1300' => :success_empty_queue,
|
||||
'1301' => :success_dequeue,
|
||||
'2001' => :syntax_error,
|
||||
'2003' => :required_param_missing,
|
||||
'2005' => :param_syntax_error,
|
||||
'2308' => :data_management_policy_violation
|
||||
}
|
||||
attr_reader :code
|
||||
|
||||
attr_accessor :code
|
||||
attr_accessor :message
|
||||
|
||||
def initialize(code, message)
|
||||
def initialize(code:)
|
||||
@code = code
|
||||
@message = message
|
||||
end
|
||||
|
||||
def self.codes
|
||||
CODE_TO_TYPE
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
81
app/models/epp/response/result/code.rb
Normal file
81
app/models/epp/response/result/code.rb
Normal file
|
@ -0,0 +1,81 @@
|
|||
module Epp
|
||||
class Response
|
||||
class Result
|
||||
class Code
|
||||
attr_reader :value
|
||||
|
||||
KEY_TO_VALUE = {
|
||||
completed_successfully: 1000,
|
||||
completed_successfully_action_pending: 1001,
|
||||
completed_successfully_no_messages: 1300,
|
||||
completed_successfully_ack_to_dequeue: 1301,
|
||||
completed_successfully_ending_session: 1500,
|
||||
unknown_command: 2000,
|
||||
syntax_error: 2001,
|
||||
use_error: 2002,
|
||||
required_parameter_missing: 2003,
|
||||
parameter_value_range_error: 2004,
|
||||
parameter_value_syntax_error: 2005,
|
||||
billing_failure: 2104,
|
||||
object_is_not_eligible_for_renewal: 2105,
|
||||
authorization_error: 2201,
|
||||
invalid_authorization_information: 2202,
|
||||
object_does_not_exist: 2303,
|
||||
object_status_prohibits_operation: 2304,
|
||||
object_association_prohibits_operation: 2305,
|
||||
parameter_value_policy_error: 2306,
|
||||
data_management_policy_violation: 2308,
|
||||
authentication_error_server_closing_connection: 2501,
|
||||
}.freeze
|
||||
private_constant :KEY_TO_VALUE
|
||||
|
||||
DEFAULT_DESCRIPTIONS = {
|
||||
1000 => 'Command completed successfully',
|
||||
1001 => 'Command completed successfully; action pending',
|
||||
1300 => 'Command completed successfully; no messages',
|
||||
1301 => 'Command completed successfully; ack to dequeue',
|
||||
1500 => 'Command completed successfully; ending session',
|
||||
2000 => 'Unknown command',
|
||||
2001 => 'Command syntax error',
|
||||
2002 => 'Command use error',
|
||||
2003 => 'Required parameter missing',
|
||||
2004 => 'Parameter value range error',
|
||||
2005 => 'Parameter value syntax error',
|
||||
2104 => 'Billing failure',
|
||||
2105 => 'Object is not eligible for renewal',
|
||||
2201 => 'Authorization error',
|
||||
2202 => 'Invalid authorization information',
|
||||
2303 => 'Object does not exist',
|
||||
2304 => 'Object status prohibits operation',
|
||||
2305 => 'Object association prohibits operation',
|
||||
2306 => 'Parameter value policy error',
|
||||
2308 => 'Data management policy violation',
|
||||
2501 => 'Authentication error; server closing connection',
|
||||
}.freeze
|
||||
private_constant :DEFAULT_DESCRIPTIONS
|
||||
|
||||
def self.codes
|
||||
KEY_TO_VALUE
|
||||
end
|
||||
|
||||
def self.default_descriptions
|
||||
DEFAULT_DESCRIPTIONS
|
||||
end
|
||||
|
||||
def self.key(key)
|
||||
new(KEY_TO_VALUE[key])
|
||||
end
|
||||
|
||||
def initialize(value)
|
||||
value = value.to_i
|
||||
raise ArgumentError, "Invalid value: #{value}" unless KEY_TO_VALUE.value?(value)
|
||||
@value = value
|
||||
end
|
||||
|
||||
def ==(other)
|
||||
value == other.value
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,21 +0,0 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe EPP::Response::Result, db: false do
|
||||
# https://tools.ietf.org/html/rfc5730#section-3
|
||||
describe '::codes' do
|
||||
it 'returns codes' do
|
||||
codes = {
|
||||
'1000' => :success,
|
||||
'1001' => :success_pending,
|
||||
'1300' => :success_empty_queue,
|
||||
'1301' => :success_dequeue,
|
||||
'2001' => :syntax_error,
|
||||
'2003' => :required_param_missing,
|
||||
'2005' => :param_syntax_error,
|
||||
'2308' => :data_management_policy_violation
|
||||
}
|
||||
|
||||
expect(described_class.codes).to eq(codes)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -8,8 +8,6 @@ require 'support/requests/session_helpers'
|
|||
require 'support/requests/epp_helpers'
|
||||
require 'support/features/session_helpers'
|
||||
require 'support/matchers/alias_attribute'
|
||||
require 'support/matchers/epp/code'
|
||||
require 'support/matchers/epp/have_result'
|
||||
|
||||
require 'support/capybara'
|
||||
require 'support/devise'
|
||||
|
@ -30,7 +28,6 @@ RSpec.configure do |config|
|
|||
config.include AbstractController::Translation, type: :feature
|
||||
config.include AbstractController::Translation, type: :mailer
|
||||
config.include Requests::EPPHelpers, epp: true
|
||||
config.include Matchers::EPP, epp: true
|
||||
config.include Devise::Test::IntegrationHelpers, type: :feature
|
||||
config.include Devise::Test::IntegrationHelpers, type: :request
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ RSpec.describe 'EPP contact:create' do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(epp_response).to have_result(:success)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -86,8 +86,7 @@ RSpec.describe 'EPP contact:create' do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(epp_response).to have_result(:required_param_missing,
|
||||
'Required parameter missing: extension > extdata > ident [ident]')
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:required_parameter_missing))).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -130,9 +129,7 @@ RSpec.describe 'EPP contact:create' do
|
|||
|
||||
specify do
|
||||
request
|
||||
|
||||
message = 'Ident code does not conform to national identification number format of Germany'
|
||||
expect(epp_response).to have_result(:param_syntax_error, message)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:parameter_value_syntax_error))).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -174,8 +171,7 @@ RSpec.describe 'EPP contact:create' do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(epp_response).to have_result(:param_syntax_error,
|
||||
'Ident code does not conform to registration number format of Germany')
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:parameter_value_syntax_error))).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -209,8 +205,7 @@ RSpec.describe 'EPP contact:create' do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(epp_response).to have_result(:required_param_missing,
|
||||
'Required ident attribute missing: cc')
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:required_parameter_missing))).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -244,7 +239,7 @@ RSpec.describe 'EPP contact:create' do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(epp_response).to have_result(:syntax_error)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:syntax_error))).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -285,8 +280,7 @@ RSpec.describe 'EPP contact:create' do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(epp_response).to have_result(:param_syntax_error,
|
||||
'Ident type "priv" is invalid for Germany')
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:parameter_value_syntax_error))).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ RSpec.shared_examples 'EPP contact phone' do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(1000)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -13,7 +13,7 @@ RSpec.shared_examples 'EPP contact phone' do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(2005)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:parameter_value_syntax_error))).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -22,7 +22,7 @@ RSpec.shared_examples 'EPP contact phone' do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(2005)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:parameter_value_syntax_error))).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -45,7 +45,7 @@ RSpec.describe 'EPP contact:update' do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(epp_response).to have_result(:success)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -78,9 +78,7 @@ RSpec.describe 'EPP contact:update' do
|
|||
|
||||
specify do
|
||||
request
|
||||
|
||||
expect(epp_response).to have_result(:data_management_policy_violation,
|
||||
t('epp.contacts.errors.valid_ident'))
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:data_management_policy_violation))).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -138,7 +136,7 @@ RSpec.describe 'EPP contact:update' do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(epp_response).to have_result(:success)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -190,9 +188,7 @@ RSpec.describe 'EPP contact:update' do
|
|||
|
||||
specify do
|
||||
request
|
||||
|
||||
expect(epp_response).to have_result(:data_management_policy_violation,
|
||||
t('epp.contacts.errors.ident_update'))
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:data_management_policy_violation))).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -49,7 +49,7 @@ RSpec.describe 'EPP domain:create', settings: false do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(1000)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -62,7 +62,7 @@ RSpec.describe 'EPP domain:create', settings: false do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(2104)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:billing_failure))).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -54,7 +54,7 @@ RSpec.describe 'EPP domain:create', settings: false do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(1000)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -64,7 +64,7 @@ RSpec.describe 'EPP domain:create', settings: false do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(2308)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:data_management_policy_violation))).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -103,7 +103,7 @@ RSpec.describe 'EPP domain:create', settings: false do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(1000)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -57,7 +57,7 @@ RSpec.describe 'EPP domain:create', settings: false do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(1000)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -103,7 +103,7 @@ RSpec.describe 'EPP domain:create', settings: false do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(1000)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -50,7 +50,7 @@ RSpec.describe 'EPP domain:create', settings: false do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(1000)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -61,7 +61,7 @@ RSpec.describe 'EPP domain:create', settings: false do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(2104)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:billing_failure))).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -61,7 +61,7 @@ RSpec.describe 'EPP domain:create', settings: false do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(1000)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -93,7 +93,7 @@ RSpec.describe 'EPP domain:create', settings: false do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(2003)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:required_parameter_missing))).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -51,7 +51,7 @@ RSpec.describe 'EPP domain:renew' do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(1000)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -86,7 +86,7 @@ RSpec.describe 'EPP domain:renew' do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(2104)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:billing_failure))).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -50,7 +50,7 @@ RSpec.describe 'EPP domain:renew', settings: false do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(1000)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -51,7 +51,7 @@ RSpec.describe 'EPP domain:renew' do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(1000)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -83,7 +83,7 @@ RSpec.describe 'EPP domain:renew' do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(2306)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:parameter_value_policy_error))).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -51,7 +51,7 @@ RSpec.describe 'EPP domain:renew', settings: false do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(1000)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -88,7 +88,7 @@ RSpec.describe 'EPP domain:renew', settings: false do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(1000)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -51,7 +51,7 @@ RSpec.describe 'EPP domain:renew', settings: false do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(1000)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -62,7 +62,7 @@ RSpec.describe 'EPP domain:renew', settings: false do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(2104)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:billing_failure))).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -42,7 +42,7 @@ RSpec.describe 'EPP domain:update' do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(1000)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
||||
end
|
||||
|
||||
it 'keeps same registrant' do
|
||||
|
@ -87,7 +87,7 @@ RSpec.describe 'EPP domain:update' do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(1001)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully_action_pending))).to be_truthy
|
||||
end
|
||||
|
||||
it 'does not change registrant without confirmation' do
|
||||
|
@ -143,7 +143,7 @@ RSpec.describe 'EPP domain:update' do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(1000)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
||||
end
|
||||
|
||||
it 'keeps same registrant' do
|
||||
|
@ -188,7 +188,7 @@ RSpec.describe 'EPP domain:update' do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(1000)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
||||
end
|
||||
|
||||
it 'changes registrant without confirmation' do
|
||||
|
|
|
@ -43,7 +43,7 @@ RSpec.describe 'EPP domain:update' do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(1000)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
||||
end
|
||||
|
||||
it 'changes registrant' do
|
||||
|
@ -86,7 +86,7 @@ RSpec.describe 'EPP domain:update' do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(1001)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully_action_pending))).to be_truthy
|
||||
end
|
||||
|
||||
it 'does not change registrant' do
|
||||
|
@ -135,7 +135,7 @@ RSpec.describe 'EPP domain:update' do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(1000)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
||||
end
|
||||
|
||||
it 'changes registrant' do
|
||||
|
@ -178,7 +178,7 @@ RSpec.describe 'EPP domain:update' do
|
|||
|
||||
specify do
|
||||
request
|
||||
expect(response).to have_code_of(1000)
|
||||
expect(Epp::Response.xml(response.body).code?(Epp::Response::Result::Code.key(:completed_successfully))).to be_truthy
|
||||
end
|
||||
|
||||
it 'changes registrant' do
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
module Matchers
|
||||
module EPP
|
||||
class Code
|
||||
def initialize(expected)
|
||||
@expected = expected
|
||||
end
|
||||
|
||||
def matches?(response)
|
||||
@xml = response.body
|
||||
actual == expected
|
||||
end
|
||||
|
||||
def failure_message
|
||||
"Expected EPP code of #{expected}, got #{actual} (#{code_description})"
|
||||
end
|
||||
|
||||
def description
|
||||
"should have EPP code of #{expected}"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
attr_reader :xml
|
||||
attr_reader :expected
|
||||
|
||||
def actual
|
||||
xml_document.xpath('//xmlns:result').first['code'].to_i
|
||||
end
|
||||
|
||||
def code_description
|
||||
xml_document.css('result msg').text
|
||||
end
|
||||
|
||||
def xml_document
|
||||
@xml_document ||= Nokogiri::XML(xml)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,37 +0,0 @@
|
|||
module Matchers
|
||||
module EPP
|
||||
class HaveResultMatcher
|
||||
def initialize(expected)
|
||||
@expected = expected
|
||||
end
|
||||
|
||||
def matches?(target)
|
||||
@target = target
|
||||
|
||||
if @expected.message.present?
|
||||
@target.results.any? { |result| result.code == @expected.code && result.message == @expected.message }
|
||||
else
|
||||
@target.results.any? { |result| result.code == @expected.code }
|
||||
end
|
||||
end
|
||||
|
||||
def failure_message
|
||||
"expected #{@target.results} to have result #{@expected.inspect}"
|
||||
end
|
||||
|
||||
def failure_message_when_negated
|
||||
"expected #{@target.results} not to have result #{@expected.inspect}"
|
||||
end
|
||||
|
||||
def description
|
||||
"should have EPP code of #{@expected}"
|
||||
end
|
||||
end
|
||||
|
||||
def have_result(type, message = nil)
|
||||
code = ::EPP::Response::Result.codes.key(type)
|
||||
result = ::EPP::Response::Result.new(code, message)
|
||||
HaveResultMatcher.new(result)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,15 +1,7 @@
|
|||
module Requests
|
||||
module EPPHelpers
|
||||
def have_code_of(*args)
|
||||
Matchers::EPP::Code.new(*args)
|
||||
end
|
||||
|
||||
def valid_legal_document
|
||||
Base64.encode64('a' * 5000)
|
||||
end
|
||||
|
||||
def epp_response
|
||||
EPP::Response.from_xml(response.body)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppContactCheckBaseTest < ActionDispatch::IntegrationTest
|
||||
class EppContactCheckBaseTest < EppTestCase
|
||||
setup do
|
||||
@contact = contacts(:john)
|
||||
end
|
||||
|
@ -24,8 +24,7 @@ class EppContactCheckBaseTest < ActionDispatch::IntegrationTest
|
|||
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '1000', response_xml.at_css('result')[:code]
|
||||
assert_equal 1, response_xml.css('result').size
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal 'john-001', response_xml.at_xpath('//contact:id', contact: xml_schema).text
|
||||
end
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppContactCreateBaseTest < ActionDispatch::IntegrationTest
|
||||
class EppContactCreateBaseTest < EppTestCase
|
||||
def test_creates_new_contact_with_minimum_required_parameters
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
@ -28,9 +28,7 @@ class EppContactCreateBaseTest < ActionDispatch::IntegrationTest
|
|||
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_epp_response :completed_successfully
|
||||
contact = Contact.last
|
||||
assert_not_empty contact.code
|
||||
assert_equal 'New', contact.name
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppContactDeleteBaseTest < ActionDispatch::IntegrationTest
|
||||
class EppContactDeleteBaseTest < EppTestCase
|
||||
def test_deletes_contact
|
||||
contact = deletable_contact
|
||||
|
||||
|
@ -23,9 +23,7 @@ class EppContactDeleteBaseTest < ActionDispatch::IntegrationTest
|
|||
assert_difference 'Contact.count', -1 do
|
||||
post '/epp/command/delete', { 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, response_xml.css('result').size
|
||||
assert_epp_response :completed_successfully
|
||||
end
|
||||
|
||||
def test_undeletable_cannot_be_deleted
|
||||
|
@ -51,8 +49,7 @@ class EppContactDeleteBaseTest < ActionDispatch::IntegrationTest
|
|||
assert_no_difference 'Contact.count' do
|
||||
post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
end
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '2305', response_xml.at_css('result')[:code]
|
||||
assert_epp_response :object_association_prohibits_operation
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppContactInfoBaseTest < ActionDispatch::IntegrationTest
|
||||
class EppContactInfoBaseTest < EppTestCase
|
||||
setup do
|
||||
@contact = contacts(:john)
|
||||
end
|
||||
|
@ -32,8 +32,7 @@ class EppContactInfoBaseTest < ActionDispatch::IntegrationTest
|
|||
post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '1000', response_xml.at_css('result')[:code]
|
||||
assert_equal 1, response_xml.css('result').size
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal 'JOHN-001', response_xml.at_xpath('//contact:id', contact: xml_schema).text
|
||||
assert_equal 'ok', response_xml.at_xpath('//contact:status', contact: xml_schema)['s']
|
||||
assert_equal 'john@inbox.test', response_xml.at_xpath('//contact:email', contact: xml_schema)
|
||||
|
@ -62,8 +61,7 @@ class EppContactInfoBaseTest < ActionDispatch::IntegrationTest
|
|||
|
||||
post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '2303', response_xml.at_css('result')[:code]
|
||||
assert_epp_response :object_does_not_exist
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppContactUpdateBaseTest < ActionDispatch::IntegrationTest
|
||||
class EppContactUpdateBaseTest < EppTestCase
|
||||
include ActionMailer::TestHelper
|
||||
|
||||
setup do
|
||||
|
@ -40,9 +40,7 @@ class EppContactUpdateBaseTest < ActionDispatch::IntegrationTest
|
|||
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
@contact.reload
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '1000', response_xml.at_css('result')[:code]
|
||||
assert_equal 1, response_xml.css('result').size
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal 'new name', @contact.name
|
||||
assert_equal 'new-email@inbox.test', @contact.email
|
||||
assert_equal '+123.4', @contact.phone
|
||||
|
@ -158,8 +156,7 @@ class EppContactUpdateBaseTest < ActionDispatch::IntegrationTest
|
|||
|
||||
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '2303', response_xml.at_css('result')[:code]
|
||||
assert_epp_response :object_does_not_exist
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# encoding: UTF-8
|
||||
require 'test_helper'
|
||||
|
||||
class EppDomainCheckAuctionTest < ApplicationIntegrationTest
|
||||
class EppDomainCheckAuctionTest < EppTestCase
|
||||
setup do
|
||||
@auction = auctions(:one)
|
||||
@idn_auction = auctions(:idn)
|
||||
|
@ -31,8 +31,7 @@ class EppDomainCheckAuctionTest < ApplicationIntegrationTest
|
|||
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '1000', response_xml.at_css('result')[:code]
|
||||
assert_equal 1, response_xml.css('result').size
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['avail']
|
||||
assert_equal 'Domain is at auction', response_xml.at_xpath('//domain:reason', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
|
||||
end
|
||||
|
@ -56,8 +55,7 @@ class EppDomainCheckAuctionTest < ApplicationIntegrationTest
|
|||
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '1000', response_xml.at_css('result')[:code]
|
||||
assert_equal 1, response_xml.css('result').size
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['avail']
|
||||
assert_equal 'Domain is at auction', response_xml.at_xpath('//domain:reason', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
|
||||
end
|
||||
|
@ -81,8 +79,7 @@ class EppDomainCheckAuctionTest < ApplicationIntegrationTest
|
|||
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '1000', response_xml.at_css('result')[:code]
|
||||
assert_equal 1, response_xml.css('result').size
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['avail']
|
||||
assert_equal 'Domain is at auction', response_xml.at_xpath('//domain:reason', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
|
||||
end
|
||||
|
@ -106,8 +103,7 @@ class EppDomainCheckAuctionTest < ApplicationIntegrationTest
|
|||
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '1000', response_xml.at_css('result')[:code]
|
||||
assert_equal 1, response_xml.css('result').size
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['avail']
|
||||
assert_equal 'Awaiting payment', response_xml.at_xpath('//domain:reason', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
|
||||
end
|
||||
|
@ -131,8 +127,7 @@ class EppDomainCheckAuctionTest < ApplicationIntegrationTest
|
|||
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '1000', response_xml.at_css('result')[:code]
|
||||
assert_equal 1, response_xml.css('result').size
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal '1', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['avail']
|
||||
assert_nil response_xml.at_xpath('//domain:reason', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainCheckBaseTest < ApplicationIntegrationTest
|
||||
class EppDomainCheckBaseTest < EppTestCase
|
||||
def test_returns_valid_response
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
@ -18,8 +18,7 @@ class EppDomainCheckBaseTest < ApplicationIntegrationTest
|
|||
post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '1000', response_xml.at_css('result')[:code]
|
||||
assert_equal 1, response_xml.css('result').size
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal 'some.test', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
|
||||
end
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainDeleteBaseTest < ActionDispatch::IntegrationTest
|
||||
class EppDomainDeleteBaseTest < EppTestCase
|
||||
include ActionMailer::TestHelper
|
||||
|
||||
setup do
|
||||
|
@ -36,8 +36,7 @@ class EppDomainDeleteBaseTest < ActionDispatch::IntegrationTest
|
|||
|
||||
post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
assert_includes Domain.find_by(name: 'invalid.test').statuses, DomainStatus::PENDING_DELETE_CONFIRMATION
|
||||
assert_equal '1001', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
assert_equal 1, Nokogiri::XML(response.body).css('result').size
|
||||
assert_epp_response :completed_successfully_action_pending
|
||||
end
|
||||
|
||||
def test_discarded_domain_cannot_be_deleted
|
||||
|
@ -65,7 +64,7 @@ class EppDomainDeleteBaseTest < ActionDispatch::IntegrationTest
|
|||
assert_no_difference 'Domain.count' do
|
||||
post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
end
|
||||
assert_equal '2105', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
assert_epp_response :object_is_not_eligible_for_renewal
|
||||
end
|
||||
|
||||
def test_requests_registrant_confirmation_when_required
|
||||
|
@ -96,8 +95,7 @@ class EppDomainDeleteBaseTest < ActionDispatch::IntegrationTest
|
|||
assert @domain.registrant_verification_asked?
|
||||
assert @domain.pending_delete_confirmation?
|
||||
assert_emails 1
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '1001', response_xml.at_css('result')[:code]
|
||||
assert_epp_response :completed_successfully_action_pending
|
||||
end
|
||||
|
||||
def test_skips_registrant_confirmation_when_not_required
|
||||
|
@ -128,8 +126,7 @@ class EppDomainDeleteBaseTest < ActionDispatch::IntegrationTest
|
|||
assert_not @domain.registrant_verification_asked?
|
||||
assert_not @domain.pending_delete_confirmation?
|
||||
assert_no_emails
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '1000', response_xml.at_css('result')[:code]
|
||||
assert_epp_response :completed_successfully
|
||||
end
|
||||
|
||||
def test_skips_registrant_confirmation_when_required_but_already_verified_by_registrar
|
||||
|
@ -160,8 +157,7 @@ class EppDomainDeleteBaseTest < ActionDispatch::IntegrationTest
|
|||
assert_not @domain.registrant_verification_asked?
|
||||
assert_not @domain.pending_delete_confirmation?
|
||||
assert_no_emails
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '1000', response_xml.at_css('result')[:code]
|
||||
assert_epp_response :completed_successfully
|
||||
end
|
||||
|
||||
def test_legal_document_is_required
|
||||
|
@ -182,10 +178,7 @@ class EppDomainDeleteBaseTest < ActionDispatch::IntegrationTest
|
|||
|
||||
post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '2003', response_xml.at_css('result')[:code]
|
||||
assert_equal 'Required parameter missing: extension > extdata > legalDocument [legal_document]',
|
||||
response_xml.at_css('result msg').text
|
||||
assert_epp_response :required_parameter_missing
|
||||
end
|
||||
|
||||
def test_domain_cannot_be_deleted_when_explicitly_prohibited_by_registrar
|
||||
|
@ -212,9 +205,7 @@ class EppDomainDeleteBaseTest < ActionDispatch::IntegrationTest
|
|||
|
||||
post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '2304', response_xml.at_css('result')[:code]
|
||||
assert_equal 'Domain status prohibits operation', response_xml.at_css('result msg').text
|
||||
assert_epp_response :object_status_prohibits_operation
|
||||
end
|
||||
|
||||
def test_domain_not_found
|
||||
|
@ -240,8 +231,6 @@ class EppDomainDeleteBaseTest < ActionDispatch::IntegrationTest
|
|||
|
||||
post '/epp/command/delete', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '2303', response_xml.at_css('result')[:code]
|
||||
assert_equal 'Domain not found', response_xml.at_css('result msg').text
|
||||
assert_epp_response :object_does_not_exist
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainRenewTest < ApplicationIntegrationTest
|
||||
class EppDomainRenewTest < EppTestCase
|
||||
self.use_transactional_fixtures = false
|
||||
|
||||
setup do
|
||||
|
@ -26,7 +26,6 @@ class EppDomainRenewTest < ApplicationIntegrationTest
|
|||
assert_no_changes -> { domains(:invalid).valid_to } do
|
||||
post '/epp/command/renew', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
end
|
||||
assert_equal '2304', Nokogiri::XML(response.body).at_css('result')[:code],
|
||||
Nokogiri::XML(response.body).css('result').text
|
||||
assert_epp_response :object_status_prohibits_operation
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainUpdateTest < ApplicationIntegrationTest
|
||||
class EppDomainUpdateTest < EppTestCase
|
||||
def setup
|
||||
@domain = domains(:shop)
|
||||
end
|
||||
|
@ -27,8 +27,7 @@ class EppDomainUpdateTest < ApplicationIntegrationTest
|
|||
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
@domain.reload
|
||||
assert_equal 'f0ff7d17b0', @domain.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_discarded_domain_cannot_be_updated
|
||||
|
@ -48,6 +47,6 @@ class EppDomainUpdateTest < ApplicationIntegrationTest
|
|||
XML
|
||||
|
||||
post '/epp/command/update', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
assert_equal '2105', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
assert_epp_response :object_is_not_eligible_for_renewal
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainInfoBaseTest < ApplicationIntegrationTest
|
||||
class EppDomainInfoBaseTest < EppTestCase
|
||||
def test_returns_valid_response
|
||||
assert_equal 'john-001', contacts(:john).code
|
||||
domains(:shop).update_columns(statuses: [DomainStatus::OK],
|
||||
|
@ -24,8 +24,7 @@ class EppDomainInfoBaseTest < ApplicationIntegrationTest
|
|||
post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '1000', response_xml.at_css('result')[:code]
|
||||
assert_equal 1, response_xml.css('result').size
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal 'shop.test', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
|
||||
assert_equal 'ok', response_xml.at_xpath('//domain:status', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['s']
|
||||
assert_equal 'john-001', response_xml.at_xpath('//domain:registrant', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
|
||||
|
@ -125,8 +124,6 @@ class EppDomainInfoBaseTest < ApplicationIntegrationTest
|
|||
|
||||
post '/epp/command/info', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_equal '2303', response_xml.at_css('result')[:code]
|
||||
assert_equal 'Domain not found', response_xml.at_css('result msg').text
|
||||
assert_epp_response :object_does_not_exist
|
||||
end
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainTransferBaseTest < ApplicationIntegrationTest
|
||||
class EppDomainTransferBaseTest < EppTestCase
|
||||
def test_non_existent_domain
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
@ -19,6 +19,7 @@ class EppDomainTransferBaseTest < ApplicationIntegrationTest
|
|||
XML
|
||||
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
assert_equal '2303', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
|
||||
assert_epp_response :object_does_not_exist
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainTransferQueryTest < ApplicationIntegrationTest
|
||||
class EppDomainTransferQueryTest < EppTestCase
|
||||
def test_returns_domain_transfer_details
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
xml_doc = Nokogiri::XML(response.body)
|
||||
assert_equal '1000', xml_doc.at_css('result')[:code]
|
||||
assert_equal 1, xml_doc.css('result').size
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal 'shop.test', xml_doc.xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
|
||||
assert_equal 'serverApproved', xml_doc.xpath('//domain:trStatus', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
|
||||
assert_equal 'goodnames', xml_doc.xpath('//domain:reID', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
|
||||
|
@ -30,13 +29,15 @@ class EppDomainTransferQueryTest < ApplicationIntegrationTest
|
|||
XML
|
||||
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
assert_equal '2201', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
|
||||
# https://github.com/internetee/registry/issues/686
|
||||
assert_epp_response :authorization_error
|
||||
end
|
||||
|
||||
def test_no_domain_transfer
|
||||
domains(:shop).transfers.delete_all
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
assert_equal '2303', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
assert_epp_response :object_does_not_exist
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppDomainTransferRequestTest < ApplicationIntegrationTest
|
||||
class EppDomainTransferRequestTest < EppTestCase
|
||||
def setup
|
||||
@domain = domains(:shop)
|
||||
@new_registrar = registrars(:goodnames)
|
||||
|
@ -14,8 +14,7 @@ class EppDomainTransferRequestTest < ApplicationIntegrationTest
|
|||
|
||||
def test_transfers_domain_at_once
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
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_creates_new_domain_transfer
|
||||
|
@ -77,7 +76,7 @@ class EppDomainTransferRequestTest < ApplicationIntegrationTest
|
|||
domains(:shop).reload
|
||||
|
||||
assert_equal registrars(:bestnames), domains(:shop).registrar
|
||||
assert_equal '2304', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
assert_epp_response :object_status_prohibits_operation
|
||||
end
|
||||
|
||||
def test_discarded_domain_cannot_be_transferred
|
||||
|
@ -87,15 +86,14 @@ class EppDomainTransferRequestTest < ApplicationIntegrationTest
|
|||
@domain.reload
|
||||
|
||||
assert_equal registrars(:bestnames), @domain.registrar
|
||||
assert_equal '2105', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
assert_epp_response :object_is_not_eligible_for_renewal
|
||||
end
|
||||
|
||||
def test_same_registrar
|
||||
assert_no_difference -> { @domain.transfers.size } do
|
||||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
|
||||
assert_equal '2002', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
assert_epp_response :use_error
|
||||
end
|
||||
|
||||
def test_wrong_transfer_code
|
||||
|
@ -118,7 +116,9 @@ class EppDomainTransferRequestTest < ApplicationIntegrationTest
|
|||
post '/epp/command/transfer', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_goodnames' }
|
||||
@domain.reload
|
||||
refute_equal @new_registrar, @domain.registrar
|
||||
assert_equal '2201', Nokogiri::XML(response.body).at_css('result')[:code]
|
||||
|
||||
# https://github.com/internetee/registry/issues/686
|
||||
assert_epp_response :authorization_error
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppLoginCredentialsTest < ApplicationIntegrationTest
|
||||
class EppLoginCredentialsTest < EppTestCase
|
||||
def test_correct_credentials
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
@ -27,8 +27,7 @@ class EppLoginCredentialsTest < ApplicationIntegrationTest
|
|||
post '/epp/session/login', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=new_session_id' }
|
||||
assert EppSession.find_by(session_id: 'new_session_id')
|
||||
assert_equal users(:api_bestnames), EppSession.find_by(session_id: 'new_session_id').user
|
||||
assert Nokogiri::XML(response.body).at_css('result[code="1000"]')
|
||||
assert_equal 1, Nokogiri::XML(response.body).css('result').size
|
||||
assert_epp_response :completed_successfully
|
||||
end
|
||||
|
||||
def test_already_logged_in
|
||||
|
@ -58,7 +57,8 @@ class EppLoginCredentialsTest < ApplicationIntegrationTest
|
|||
</epp>
|
||||
XML
|
||||
|
||||
post '/epp/session/login', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=any_random_string' }
|
||||
assert Nokogiri::XML(response.body).at_css('result[code="2501"]')
|
||||
post '/epp/session/login', { frame: request_xml }, 'HTTP_COOKIE' => 'session=any_random_string'
|
||||
|
||||
assert_epp_response :authentication_error_server_closing_connection
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppLoginPasswordChangeTest < ActionDispatch::IntegrationTest
|
||||
class EppLoginPasswordChangeTest < EppTestCase
|
||||
def test_password_change
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
|
@ -27,7 +27,6 @@ class EppLoginPasswordChangeTest < ActionDispatch::IntegrationTest
|
|||
|
||||
post '/epp/session/login', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=new_session_id' }
|
||||
assert_equal 'new-password', users(:api_bestnames).plain_text_password
|
||||
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
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppLoginSessionLimitTest < ApplicationIntegrationTest
|
||||
class EppLoginSessionLimitTest < EppTestCase
|
||||
setup do
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
EppSession.delete_all
|
||||
|
@ -16,9 +16,7 @@ class EppLoginSessionLimitTest < ApplicationIntegrationTest
|
|||
assert_difference 'EppSession.count' do
|
||||
post '/epp/session/login', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=new_session_id' }
|
||||
end
|
||||
|
||||
assert Nokogiri::XML(response.body).at_css('result[code="1000"]')
|
||||
assert_equal 1, Nokogiri::XML(response.body).css('result').size
|
||||
assert_epp_response :completed_successfully
|
||||
end
|
||||
|
||||
def test_reached
|
||||
|
@ -31,8 +29,7 @@ class EppLoginSessionLimitTest < ApplicationIntegrationTest
|
|||
assert_no_difference 'EppSession.count' do
|
||||
post '/epp/session/login', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=new_session_id' }
|
||||
end
|
||||
|
||||
assert Nokogiri::XML(response.body).at_css('result[code="2501"]')
|
||||
assert_epp_response :authentication_error_server_closing_connection
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppLogoutTest < ApplicationIntegrationTest
|
||||
class EppLogoutTest < EppTestCase
|
||||
def test_success_response
|
||||
post '/epp/session/logout', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
assert Nokogiri::XML(response.body).at_css('result[code="1500"]')
|
||||
assert_equal 1, Nokogiri::XML(response.body).css('result').size
|
||||
assert_epp_response :completed_successfully_ending_session
|
||||
end
|
||||
|
||||
def test_ends_current_session
|
||||
|
@ -19,7 +18,7 @@ class EppLogoutTest < ApplicationIntegrationTest
|
|||
|
||||
def test_anonymous_user
|
||||
post '/epp/session/logout', { frame: request_xml }, { 'HTTP_COOKIE' => 'session=non-existent' }
|
||||
assert Nokogiri::XML(response.body).at_css('result[code="2201"]')
|
||||
assert_epp_response :authorization_error
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppPollTest < ApplicationIntegrationTest
|
||||
class EppPollTest < EppTestCase
|
||||
setup do
|
||||
@notification = notifications(:complete)
|
||||
end
|
||||
|
@ -18,8 +18,7 @@ class EppPollTest < ApplicationIntegrationTest
|
|||
post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
xml_doc = Nokogiri::XML(response.body)
|
||||
assert_equal 1301.to_s, xml_doc.at_css('result')[:code]
|
||||
assert_equal 1, xml_doc.css('result').size
|
||||
assert_epp_response :completed_successfully_ack_to_dequeue
|
||||
assert_equal 2.to_s, xml_doc.at_css('msgQ')[:count]
|
||||
assert_equal @notification.id.to_s, xml_doc.at_css('msgQ')[:id]
|
||||
assert_equal Time.zone.parse('2010-07-05').utc.xmlschema, xml_doc.at_css('msgQ qDate').text
|
||||
|
@ -63,9 +62,7 @@ class EppPollTest < ApplicationIntegrationTest
|
|||
XML
|
||||
post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
xml_doc = Nokogiri::XML(response.body)
|
||||
assert_equal 1300.to_s, xml_doc.at_css('result')[:code]
|
||||
assert_equal 1, xml_doc.css('result').size
|
||||
assert_epp_response :completed_successfully_no_messages
|
||||
end
|
||||
|
||||
def test_mark_as_read
|
||||
|
@ -85,8 +82,7 @@ class EppPollTest < ApplicationIntegrationTest
|
|||
|
||||
xml_doc = Nokogiri::XML(response.body)
|
||||
assert notification.read?
|
||||
assert_equal 1000.to_s, xml_doc.at_css('result')[:code]
|
||||
assert_equal 1, xml_doc.css('result').size
|
||||
assert_epp_response :completed_successfully
|
||||
assert_equal 1.to_s, xml_doc.at_css('msgQ')[:count]
|
||||
assert_equal notification.id.to_s, xml_doc.at_css('msgQ')[:id]
|
||||
end
|
||||
|
@ -105,9 +101,8 @@ class EppPollTest < ApplicationIntegrationTest
|
|||
post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
notification.reload
|
||||
|
||||
xml_doc = Nokogiri::XML(response.body)
|
||||
assert notification.unread?
|
||||
assert_equal 2303.to_s, xml_doc.at_css('result')[:code]
|
||||
assert_epp_response :object_does_not_exist
|
||||
end
|
||||
|
||||
def test_notification_not_found
|
||||
|
@ -121,7 +116,6 @@ class EppPollTest < ApplicationIntegrationTest
|
|||
XML
|
||||
post '/epp/command/poll', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'
|
||||
|
||||
xml_doc = Nokogiri::XML(response.body)
|
||||
assert_equal 2303.to_s, xml_doc.at_css('result')[:code]
|
||||
assert_epp_response :object_does_not_exist
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
84
test/models/epp/response/result/code_test.rb
Normal file
84
test/models/epp/response/result/code_test.rb
Normal file
|
@ -0,0 +1,84 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppResponseResultCodeTest < ActiveSupport::TestCase
|
||||
def test_creates_code_by_key
|
||||
key = :completed_successfully
|
||||
assert_includes Epp::Response::Result::Code.codes.keys, key
|
||||
|
||||
assert_kind_of Epp::Response::Result::Code, Epp::Response::Result::Code.key(key)
|
||||
end
|
||||
|
||||
def test_creates_new_code_by_string_value
|
||||
code_value = Epp::Response::Result::Code.codes.values.first
|
||||
code = Epp::Response::Result::Code.new(code_value.to_s)
|
||||
assert_equal code_value, code.value
|
||||
end
|
||||
|
||||
def test_invalid_code_value
|
||||
invalid_code_value = 0000
|
||||
refute_includes Epp::Response::Result::Code.codes.values, invalid_code_value
|
||||
|
||||
e = assert_raises ArgumentError do
|
||||
Epp::Response::Result::Code.new(invalid_code_value)
|
||||
end
|
||||
assert_equal "Invalid value: #{invalid_code_value}", e.message
|
||||
end
|
||||
|
||||
def test_returns_code_values
|
||||
codes = {
|
||||
completed_successfully: 1000,
|
||||
completed_successfully_action_pending: 1001,
|
||||
completed_successfully_no_messages: 1300,
|
||||
completed_successfully_ack_to_dequeue: 1301,
|
||||
completed_successfully_ending_session: 1500,
|
||||
unknown_command: 2000,
|
||||
syntax_error: 2001,
|
||||
use_error: 2002,
|
||||
required_parameter_missing: 2003,
|
||||
parameter_value_range_error: 2004,
|
||||
parameter_value_syntax_error: 2005,
|
||||
billing_failure: 2104,
|
||||
object_is_not_eligible_for_renewal: 2105,
|
||||
authorization_error: 2201,
|
||||
invalid_authorization_information: 2202,
|
||||
object_does_not_exist: 2303,
|
||||
object_status_prohibits_operation: 2304,
|
||||
object_association_prohibits_operation: 2305,
|
||||
parameter_value_policy_error: 2306,
|
||||
data_management_policy_violation: 2308,
|
||||
authentication_error_server_closing_connection: 2501,
|
||||
}
|
||||
assert_equal codes, Epp::Response::Result::Code.codes
|
||||
end
|
||||
|
||||
def test_returns_default_descriptions
|
||||
descriptions = {
|
||||
1000 => 'Command completed successfully',
|
||||
1001 => 'Command completed successfully; action pending',
|
||||
1300 => 'Command completed successfully; no messages',
|
||||
1301 => 'Command completed successfully; ack to dequeue',
|
||||
1500 => 'Command completed successfully; ending session',
|
||||
2000 => 'Unknown command',
|
||||
2001 => 'Command syntax error',
|
||||
2002 => 'Command use error',
|
||||
2003 => 'Required parameter missing',
|
||||
2004 => 'Parameter value range error',
|
||||
2005 => 'Parameter value syntax error',
|
||||
2104 => 'Billing failure',
|
||||
2105 => 'Object is not eligible for renewal',
|
||||
2201 => 'Authorization error',
|
||||
2202 => 'Invalid authorization information',
|
||||
2303 => 'Object does not exist',
|
||||
2304 => 'Object status prohibits operation',
|
||||
2305 => 'Object association prohibits operation',
|
||||
2306 => 'Parameter value policy error',
|
||||
2308 => 'Data management policy violation',
|
||||
2501 => 'Authentication error; server closing connection',
|
||||
}
|
||||
assert_equal descriptions, Epp::Response::Result::Code.default_descriptions
|
||||
end
|
||||
|
||||
def test_equality
|
||||
assert_equal Epp::Response::Result::Code.new(1000), Epp::Response::Result::Code.new(1000)
|
||||
end
|
||||
end
|
5
test/models/epp/response/result_test.rb
Normal file
5
test/models/epp/response/result_test.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppResponseResultTest < ActiveSupport::TestCase
|
||||
|
||||
end
|
29
test/models/epp/response_test.rb
Normal file
29
test/models/epp/response_test.rb
Normal file
|
@ -0,0 +1,29 @@
|
|||
require 'test_helper'
|
||||
|
||||
class EppResponseTest < ActiveSupport::TestCase
|
||||
def test_creates_new_response_from_xml_doc
|
||||
xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="lib/schemas/epp-ee-1.0.xsd">
|
||||
<response>
|
||||
<result code="1000">
|
||||
<msg>any</msg>
|
||||
</result>
|
||||
</response>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
assert_kind_of Epp::Response, Epp::Response.xml(xml)
|
||||
end
|
||||
|
||||
def test_code_predicate
|
||||
present_code = Epp::Response::Result::Code.key(:completed_successfully)
|
||||
absent_code = Epp::Response::Result::Code.key(:required_parameter_missing)
|
||||
|
||||
result = Epp::Response::Result.new(code: present_code)
|
||||
response = Epp::Response.new(results: [result])
|
||||
|
||||
assert response.code?(present_code)
|
||||
assert_not response.code?(absent_code)
|
||||
end
|
||||
end
|
14
test/support/assertions/epp_assertions.rb
Normal file
14
test/support/assertions/epp_assertions.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
module Assertions
|
||||
module EppAssertions
|
||||
def assert_epp_response(code_key, message = nil)
|
||||
assert epp_response.code?(Epp::Response::Result::Code.key(code_key)), message
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def epp_response
|
||||
@epp_response = Epp::Response.xml(response.body) unless @epp_response
|
||||
@epp_response
|
||||
end
|
||||
end
|
||||
end
|
|
@ -11,6 +11,7 @@ require 'capybara/rails'
|
|||
require 'capybara/minitest'
|
||||
require 'webmock/minitest'
|
||||
require 'support/rails5_assertions' # Remove once upgraded to Rails 5
|
||||
require 'support/assertions/epp_assertions'
|
||||
|
||||
Setting.address_processing = false
|
||||
Setting.registry_country_code = 'US'
|
||||
|
@ -57,3 +58,7 @@ class ApplicationIntegrationTest < ActionDispatch::IntegrationTest
|
|||
Capybara.use_default_driver
|
||||
end
|
||||
end
|
||||
|
||||
class EppTestCase < ActionDispatch::IntegrationTest
|
||||
include Assertions::EppAssertions
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue