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
reserved.test
john-001
#{'test' * 2000}
reserved-001
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
reserved.test
john-001
#{'test' * 2000}
reserved-001
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
reserved.test
john-001
#{'test' * 2000}
wrong
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
reserved.test
john-001
#{'test' * 2000}
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