From 4c30418f5ef04831be5d8b0a12bc3ad237d369c0 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 15 Feb 2018 17:38:35 +0200 Subject: [PATCH 1/4] Improve readability #707 --- test/models/domain/domain_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/models/domain/domain_test.rb b/test/models/domain/domain_test.rb index a2c3fae55..562e8e3e9 100644 --- a/test/models/domain/domain_test.rb +++ b/test/models/domain/domain_test.rb @@ -5,7 +5,7 @@ class DomainTest < ActiveSupport::TestCase @domain = domains(:shop) end - def test_validates + def test_valid_fixture assert @domain.valid? end end From 6c1342c9577e337c379073311d6bef14dfb4ca4f Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 15 Feb 2018 17:46:09 +0200 Subject: [PATCH 2/4] Bypass validation on EPP domain:delete #707 --- app/models/epp/domain.rb | 2 -- test/fixtures/contacts.yml | 1 + test/fixtures/domain_contacts.yml | 10 +++++++ test/fixtures/domains.yml | 6 +++++ .../epp/domain/domain_delete_test.rb | 27 +++++++++++++++++++ test/models/domain/domain_test.rb | 4 +++ 6 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 test/integration/epp/domain/domain_delete_test.rb diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 969d9a9bc..a59094d1e 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -556,8 +556,6 @@ class Epp::Domain < Domain end def epp_destroy(frame, user_id) - return false unless valid? - check_discarded if doc = attach_legal_document(Epp::Domain.parse_legal_document_from_frame(frame)) diff --git a/test/fixtures/contacts.yml b/test/fixtures/contacts.yml index 2a9898543..8c0fb4e10 100644 --- a/test/fixtures/contacts.yml +++ b/test/fixtures/contacts.yml @@ -34,5 +34,6 @@ acme_ltd: invalid: name: any code: any + email: invalid@invalid.test auth_info: any registrar: bestnames diff --git a/test/fixtures/domain_contacts.yml b/test/fixtures/domain_contacts.yml index 8a429f628..fd60e8c99 100644 --- a/test/fixtures/domain_contacts.yml +++ b/test/fixtures/domain_contacts.yml @@ -12,3 +12,13 @@ library_john: domain: library contact: john type: AdminDomainContact + +invalid_invalid_admin: + domain: invalid + contact: invalid + type: AdminDomainContact + +invalid_invalid_tech: + domain: invalid + contact: invalid + type: TechDomainContact diff --git a/test/fixtures/domains.yml b/test/fixtures/domains.yml index 7c7b429cf..a7ed8e337 100644 --- a/test/fixtures/domains.yml +++ b/test/fixtures/domains.yml @@ -27,3 +27,9 @@ library: valid_to: 2010-07-05 period: 1 period_unit: m + +invalid: + name: invalid.test + transfer_code: any + registrar: bestnames + registrant: invalid diff --git a/test/integration/epp/domain/domain_delete_test.rb b/test/integration/epp/domain/domain_delete_test.rb new file mode 100644 index 000000000..212ec589a --- /dev/null +++ b/test/integration/epp/domain/domain_delete_test.rb @@ -0,0 +1,27 @@ +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_equal '1001', Nokogiri::XML(response.body).at_css('result')[:code] + assert_equal 1, Nokogiri::XML(response.body).css('result').size + end +end diff --git a/test/models/domain/domain_test.rb b/test/models/domain/domain_test.rb index 562e8e3e9..b022fd35b 100644 --- a/test/models/domain/domain_test.rb +++ b/test/models/domain/domain_test.rb @@ -8,4 +8,8 @@ class DomainTest < ActiveSupport::TestCase def test_valid_fixture assert @domain.valid? end + + def test_invalid_fixture + assert domains(:invalid).invalid? + end end From 81ea57c5236b25ec0730c15aee60ff4b91760225 Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 15 Feb 2018 21:41:35 +0200 Subject: [PATCH 3/4] Improve readability #707 --- test/models/contact/contact_test.rb | 2 +- test/models/domain/domain_test.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/models/contact/contact_test.rb b/test/models/contact/contact_test.rb index c4f26f4a3..ef958e2a4 100644 --- a/test/models/contact/contact_test.rb +++ b/test/models/contact/contact_test.rb @@ -5,7 +5,7 @@ class ContactTest < ActiveSupport::TestCase @contact = contacts(:john) end - def test_validates + def test_valid_fixture_is_valid assert @contact.valid? end diff --git a/test/models/domain/domain_test.rb b/test/models/domain/domain_test.rb index b022fd35b..c67c8ee87 100644 --- a/test/models/domain/domain_test.rb +++ b/test/models/domain/domain_test.rb @@ -5,11 +5,11 @@ class DomainTest < ActiveSupport::TestCase @domain = domains(:shop) end - def test_valid_fixture + def test_valid_fixture_is_valid assert @domain.valid? end - def test_invalid_fixture + def test_invalid_fixture_is_invalid assert domains(:invalid).invalid? end end From de6e640f86195a36617718abb53f1397f4d3905d Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Thu, 15 Feb 2018 22:07:10 +0200 Subject: [PATCH 4/4] Improve/fix tests #707 --- test/fixtures/domains.yml | 1 + test/integration/epp/domain/domain_delete_test.rb | 1 + test/integration/registrar/domains_test.rb | 1 + 3 files changed, 3 insertions(+) diff --git a/test/fixtures/domains.yml b/test/fixtures/domains.yml index a7ed8e337..7c0844d97 100644 --- a/test/fixtures/domains.yml +++ b/test/fixtures/domains.yml @@ -31,5 +31,6 @@ library: invalid: name: invalid.test transfer_code: any + valid_to: 2010-07-05 registrar: bestnames registrant: invalid diff --git a/test/integration/epp/domain/domain_delete_test.rb b/test/integration/epp/domain/domain_delete_test.rb index 212ec589a..bdd326a3e 100644 --- a/test/integration/epp/domain/domain_delete_test.rb +++ b/test/integration/epp/domain/domain_delete_test.rb @@ -21,6 +21,7 @@ class EppDomainDeleteTest < ActionDispatch::IntegrationTest 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 diff --git a/test/integration/registrar/domains_test.rb b/test/integration/registrar/domains_test.rb index 51b76fc7c..f3936c578 100644 --- a/test/integration/registrar/domains_test.rb +++ b/test/integration/registrar/domains_test.rb @@ -9,6 +9,7 @@ class RegistrarDomainsTest < ActionDispatch::IntegrationTest Domain,Transfer code,Registrant name,Registrant code,Date of expiry library.test,45118f5,Acme Ltd,acme-ltd-001,2010-07-05 shop.test,65078d5,John,john-001,2010-07-05 + invalid.test,any,any,any,2010-07-05 airport.test,55438j5,John,john-001,2010-07-05 CSV