Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur Beljajev committed Jan 6, 2019
1 parent 4b2a53e commit 44bbc59
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 55 deletions.
9 changes: 4 additions & 5 deletions test/fixtures/billing/prices.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,27 @@ create_one_month:
operation_category: create
valid_from: 2010-07-05
valid_to: 2010-07-05
zone: test
zone: one

renew_one_month:
duration: 1 month
price_cents: 100
operation_category: renew
valid_from: 2010-07-05
valid_to: 2010-07-05
zone: test
zone: one

create_one_year:
duration: 1 year
price_cents: 1000
operation_category: create
valid_from: 2010-07-05
valid_to: 2010-07-05
zone: test
zone: one

renew_one_year:
duration: 1 year
price_cents: 1000
operation_category: renew
valid_from: 2010-07-05
valid_to: 2010-07-05
zone: test
zone: one
4 changes: 4 additions & 0 deletions test/fixtures/dns/zones.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# https://github.com/rails/rails/issues/9516 requires this file to be under "dns" folder

one:
origin: test
2 changes: 0 additions & 2 deletions test/fixtures/zones.yml

This file was deleted.

46 changes: 0 additions & 46 deletions test/integration/epp/domain/check/base_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,29 +65,6 @@ def test_domain_is_unavailable_when_format_is_invalid
assert_equal 'invalid format', response_xml.at_xpath('//domain:reason', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
end

def test_domain_is_unavailable_when_zone_with_the_same_origin_exists
zones(:one).update_columns(origin: 'sub.test')

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>
<check>
<domain:check xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>sub.test</domain:name>
</domain:check>
</check>
</command>
</epp>
XML

post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'

response_xml = Nokogiri::XML(response.body)
assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['avail']
assert_equal 'invalid format', response_xml.at_xpath('//domain:reason', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
end

def test_domain_is_unavailable_when_registered
assert_equal 'shop.test', domains(:shop).name

Expand All @@ -111,29 +88,6 @@ def test_domain_is_unavailable_when_registered
assert_equal 'in use', response_xml.at_xpath('//domain:reason', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
end

def test_domain_is_unavailable_when_blocked
assert_equal 'blocked.test', blocked_domains(:one).name

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>
<check>
<domain:check xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
<domain:name>blocked.test</domain:name>
</domain:check>
</check>
</command>
</epp>
XML

post '/epp/command/check', { frame: request_xml }, 'HTTP_COOKIE' => 'session=api_bestnames'

response_xml = Nokogiri::XML(response.body)
assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd')['avail']
assert_equal 'invalid format', response_xml.at_xpath('//domain:reason', 'domain' => 'https://epp.tld.ee/schema/domain-eis-1.0.xsd').text
end

def test_domain_is_unavailable_when_reserved
assert_equal 'reserved.test', reserved_domains(:one).name

Expand Down
2 changes: 0 additions & 2 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ class ActiveSupport::TestCase
include FactoryBot::Syntax::Methods

ActiveRecord::Migration.check_pending!

fixtures :all
set_fixture_class zones: DNS::Zone

teardown do
travel_back
Expand Down

0 comments on commit 44bbc59

Please sign in to comment.