internetee-registry/test/integration/epp/domain/create/transfer_code_test.rb
Maciej Szlosarczyk 526a9ccd58
Change test structure to follow closer newer Rails 5 rules
* Create new class called ApplicationIntegrationTest, so we don't have
  to override ActionDispatch::IntegrationTest
* Move UI tests to inherit from ApplicationSystemTestCase
* Existing REST API or EPP tests inherit from
  ApplicationIntegrationTest.
* Move `require 'application_system_test_case'` at the end of
  `test_helper`

I don't particularly agree with the Rails' convention of treating UI
tests as system tests and API tests as integration tests, but I see no
benefit in actively fighting against it.
2018-07-27 09:36:27 +03:00

64 lines
2.4 KiB
Ruby

require 'test_helper'
class EppDomainCreateTransferCodeTest < ApplicationIntegrationTest
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_equal '1000', Nokogiri::XML(response.body).at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
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_equal '1000', Nokogiri::XML(response.body).at_css('result')[:code]
assert_equal 1, Nokogiri::XML(response.body).css('result').size
end
end