Skip to content

Commit

Permalink
removed dublicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
DinSmol committed Oct 8, 2021
1 parent 81b2643 commit aafefe5
Showing 1 changed file with 3 additions and 96 deletions.
99 changes: 3 additions & 96 deletions test/integration/epp/domain/update/replace_dns_test.rb
Original file line number Diff line number Diff line change
@@ -1,101 +1,8 @@
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
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee', for_version: '1.0')}">
<command>
<update>
<domain:update xmlns:domain="#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}">
<domain:name>shop.test</domain:name>
<domain:chg>
<domain:authInfo>
<domain:pw>f0ff7d17b0</domain:pw>
</domain:authInfo>
</domain:chg>
</domain:update>
</update>
<extension>
<secDNS:update xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">
<secDNS:rem>
<secDNS:keyData>
<secDNS:flags>#{@dnskey.flags}</secDNS:flags>
<secDNS:protocol>#{@dnskey.protocol}</secDNS:protocol>
<secDNS:alg>#{@dnskey.alg}</secDNS:alg>
<secDNS:pubKey>#{@dnskey.public_key}</secDNS:pubKey>
</secDNS:keyData>
</secDNS:rem>
</secDNS:update>
</extension>
</command>
</epp>
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
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<epp xmlns="#{Xsd::Schema.filename(for_prefix: 'epp-ee', for_version: '1.0')}">
<command>
<update>
<domain:update xmlns:domain="#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}">
<domain:name>shop.test</domain:name>
<domain:chg>
<domain:authInfo>
<domain:pw>f0ff7d17b0</domain:pw>
</domain:authInfo>
</domain:chg>
</domain:update>
</update>
<extension>
<secDNS:update xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">
<secDNS:rem>
<secDNS:all>true</secDNS:all>
</secDNS:rem>
</secDNS:update>
</extension>
</command>
</epp>
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)
def test_parsed_response_for_dnskey_with_spaces_in_request
doc = Nokogiri::XML::Document.parse(schema_update)
params = { parsed_frame: doc }
domain_controller = Epp::DomainsController.new
domain_controller.params = ActionController::Parameters.new(params)
Expand All @@ -104,7 +11,7 @@ def test_replace_dnskey_with_spaces_in_request
assert_equal(domain_controller.send(:parsed_response_for_dnskey, 'add'), true)
end

def schema_new
def schema_update
<<~XML
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<epp schemaLocation=\"https://epp.tld.ee/schema/epp-ee-1.0.xsd epp-ee-1.0.xsd https://epp.tld.ee/schema/domain-ee-1.2.xsd domain-ee-1.2.xsd urn:ietf:params:xml:ns:secDNS-1.1 secDNS-1.1.xsd https://epp.tld.ee/schema/eis-1.0.xsd eis-1.0.xsd\">
Expand Down

0 comments on commit aafefe5

Please sign in to comment.