require 'test_helper'
class EppDomainDeleteTest < ActionDispatch::IntegrationTest
def test_bypasses_domain_and_registrant_and_contacts_validation
request_xml = <<-XML
invalid.test
dGVzdCBmYWlsCg==
XML
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
end
def test_discarded_domain_cannot_be_deleted
domains(:shop).discard
request_xml = <<-XML
shop.test
dGVzdCBmYWlsCg==
XML
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]
end
end