diff --git a/test/fixtures/dnskeys.yml b/test/fixtures/dnskeys.yml index 2b75b46034..b740a6ec0e 100644 --- a/test/fixtures/dnskeys.yml +++ b/test/fixtures/dnskeys.yml @@ -18,13 +18,3 @@ with_whitespace: ds_alg: 13 ds_digest_type: 2 ds_digest: 39456058862EA09DD96992ED2BDAFAEDE8C7E949589E3DA903A46F4F9CD373EA -two: - domain: - flags: 257 - protocol: 3 - alg: 8 - public_key: AwEAAdas/oY6xQV2MYd+o5pcUHK0f/mtETRNyBhh/TSABqRM9JikXlSrwLFT9sAfOsTiRNbPnvEiCKdEdoN0f0Oel0WNXadLlVINmxtCue93bSX7zxrVvjhbkHffOVdpBL0CIDQoX1HPZmoBXXPdZtWLpDQ7nVfUtdC/McTFSRawUYaoCWOEAgC8YY+kh6C8TUZzHMl+JiVE6YFkTIFf+z4MxA920UxUnGpdcfRbcB0CYjCxe+PuiA+aZHFheEe5S5tlW7tO96hxK/k2l93N//T2mEM53TKomk62HoWvNVdPrs7jdZbGzeY2eBPDWMAIIpgOv9ApORi+kHSQm2POCwf/KYs= - ds_key_tag: 23527 - ds_alg: 8 - ds_digest_type: 2 - ds_digest: 5937141E8D3D91E15D94263A723C4E804513C71CB642AB86B41BDB65EF2FA4F4 diff --git a/test/integration/epp/domain/update/replace_dns_test.rb b/test/integration/epp/domain/update/replace_dns_test.rb new file mode 100644 index 0000000000..51f307dc73 --- /dev/null +++ b/test/integration/epp/domain/update/replace_dns_test.rb @@ -0,0 +1,140 @@ +require 'test_helper' + +class EppDomainUpdateReplaceDnsTest < EppTestCase + include ActionMailer::TestHelper + include ActiveJob::TestHelper + + setup do + @domain = domains(:shop) + @contact = contacts(:john) + @dnskey = dnskeys(:one) + @dnskey.update(domain: @domain) + @original_registrant_change_verification = + Setting.request_confirmation_on_registrant_change_enabled + ActionMailer::Base.deliveries.clear + end + + teardown do + Setting.request_confirmation_on_registrant_change_enabled = + @original_registrant_change_verification + end + + def test_remove_dnskey_if_explicitly_set + request_xml = <<-XML + + + + + + shop.test + + + f0ff7d17b0 + + + + + + + + + #{@dnskey.flags} + #{@dnskey.protocol} + #{@dnskey.alg} + #{@dnskey.public_key} + + + + + + + XML + + post epp_update_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + response_xml = Nokogiri::XML(response.body) + assert_correct_against_schema response_xml + @domain.reload + assert_equal 0, @domain.dnskeys.count + assert_epp_response :completed_successfully + end + + def test_remove_dnskey_if_remove_all + request_xml = <<-XML + + + + + + shop.test + + + f0ff7d17b0 + + + + + + + + true + + + + + + XML + + post epp_update_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + response_xml = Nokogiri::XML(response.body) + assert_correct_against_schema response_xml + @domain.reload + assert_equal 0, @domain.dnskeys.count + assert_epp_response :completed_successfully + end + + def test_replace_dnskey_with_spaces_in_request + doc = Nokogiri::XML::Document.parse(schema_new) + params = { parsed_frame: doc } + domain_controller = Epp::DomainsController.new + domain_controller.params = ActionController::Parameters.new(params) + + assert_equal(domain_controller.send(:parsed_response_for_dnskey, 'rem'), true) + assert_equal(domain_controller.send(:parsed_response_for_dnskey, 'add'), true) + end + + def schema_new + <<~XML + + + + + + shop.test + + + + + \n + + 257 + 3 + 8 + AwEAAbXae59P87nfCP1MpLJouUhtDlVFbgek392nxqJcIHwYAs5sd4O4BPAvd41VmqhWllTiArNYDBV8UAtPZ8eZtYDC4D7ITC1HsxzQzzMUOorrNwMQMFq/PHP9tKelfRh68dh7UX0nTKlIouTcZ3xbqxAeoAbgvFjj/ZDS8G4QE2NgdonaK2w9q/da189zrZUhyAgecZCiTXbqqXd/LNXGRwDjJgFBWBmXbEjkcSfHke7idAcGqmYK2E5FstsmEwDcupxZ8jxuN1m/wDrBeZE5UdT24LtLGDda+ATXvCuARhQtZzSAn0JOdfGN5xJ02g+OtsbVC/mSGR3rykjzJ+hUlPU=\n + + \n + + 257 + 3 + 8 + AwEAAdas/oY6xQV2MYd+o5pcUHK0f/mtETRNyBhh/TSABqRM9JikXlSrwLFT9sAfOsTiRNbPnvEiCKdEdoN0f0Oel0WNXadLlVINmxtCue93bSX7zxrVvjhbkHffOVdpBL0CIDQoX1HPZmoBXXPdZtWLpDQ7nVfUtdC/McTFSRawUYaoCWOEAgC8YY+kh6C8TUZzHMl+JiVE6YFkTIFf+z4MxA920UxUnGpdcfRbcB0CYjCxe+PuiA+aZHFheEe5S5tlW7tO96hxK/k2l93N//T2mEM53TKomk62HoWvNVdPrs7jdZbGzeY2eBPDWMAIIpgOv9ApORi+kHSQm2POCwf/KYs=\n + + + + 0.04946500 1632965705 + +\n + XML + end +end diff --git a/test/system/registrar_area/xml_consoles_test.rb b/test/system/registrar_area/xml_consoles_test.rb index a6555ce717..51cc362eb8 100644 --- a/test/system/registrar_area/xml_consoles_test.rb +++ b/test/system/registrar_area/xml_consoles_test.rb @@ -14,133 +14,8 @@ def test_epp_server_does_not_response assert el.text.include? 'CONNECTION ERROR - Is the EPP server running?' end - def test_update_dnskey - @domain = domains(:shop) - @dnskey = dnskeys(:one) - @dnskeynew = dnskeys(:two) - visit registrar_xml_console_path - fill_in 'payload', with: schema_dnskey_rem(@dnskey) - click_on 'Send EPP Request' - fill_in 'payload', with: schema_dnskey_rem(@dnskeynew) - click_on 'Send EPP Request' - - visit registrar_xml_console_path - fill_in 'payload', with: schema_dnskey_add - click_on 'Send EPP Request' - - el = page.find('.CodeRay', visible: :all) - assert el.text.include? 'Command completed successfully' - - @domain.statuses << DomainStatus::SERVER_UPDATE_PROHIBITED - assert @domain.statuses.include? DomainStatus::SERVER_UPDATE_PROHIBITED - - ENV['obj_and_extensions_prohibited'] = 'true' - assert Feature.obj_and_extensions_statuses_enabled? - - visit registrar_xml_console_path - fill_in 'payload', with: schema_dnskey_update - click_on 'Send EPP Request' - - el = page.find('.CodeRay', visible: :all) - assert el.text.include? 'Command completed successfully' - end - private - def schema_dnskey_rem(key) - <<~XML - - - - - - shop.test - - - - - - - #{key.flags} - #{key.protocol} - #{key.alg} - #{key.public_key} - - - - - 0.04946500 1632965705 - - - XML - end - - def schema_dnskey_add - <<~XML - - - - - - shop.test - - - - - - - #{@dnskey.flags} - #{@dnskey.protocol} - #{@dnskey.alg} - #{@dnskey.public_key} - - - - - 0.04946500 1632965705 - - - XML - end - - def schema_dnskey_update - @dnskey = dnskeys(:one) - @dnskeynew = dnskeys(:two) - <<~XML - - - - - - shop.test - - - - - \n - - #{@dnskey.flags} - #{@dnskey.protocol} - #{@dnskey.alg} - #{@dnskey.public_key} - \n - - \n - - #{@dnskeynew.flags} - #{@dnskeynew.protocol} - #{@dnskeynew.alg} - #{@dnskeynew.public_key} - \n - - - - 0.04946500 1632965705 - - - XML - end - def schema_example <<~XML