Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DinSmol committed Oct 7, 2021
1 parent 5545cf0 commit e9fc932
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 135 deletions.
10 changes: 0 additions & 10 deletions test/fixtures/dnskeys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
140 changes: 140 additions & 0 deletions test/integration/epp/domain/update/replace_dns_test.rb
Original file line number Diff line number Diff line change
@@ -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
<?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)
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
<?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\">
<command>
<update>
<update>
<name>shop.test</name>
</update>
</update>
<extension>
<update>
<rem> \n
<keyData>
<flags>257</flags>
<protocol>3</protocol>
<alg>8</alg>
<pubKey>AwEAAbXae59P87nfCP1MpLJouUhtDlVFbgek392nxqJcIHwYAs5sd4O4BPAvd41VmqhWllTiArNYDBV8UAtPZ8eZtYDC4D7ITC1HsxzQzzMUOorrNwMQMFq/PHP9tKelfRh68dh7UX0nTKlIouTcZ3xbqxAeoAbgvFjj/ZDS8G4QE2NgdonaK2w9q/da189zrZUhyAgecZCiTXbqqXd/LNXGRwDjJgFBWBmXbEjkcSfHke7idAcGqmYK2E5FstsmEwDcupxZ8jxuN1m/wDrBeZE5UdT24LtLGDda+ATXvCuARhQtZzSAn0JOdfGN5xJ02g+OtsbVC/mSGR3rykjzJ+hUlPU=</pubKey>\n </keyData>
</rem>
<add> \n
<keyData>
<flags>257</flags>
<protocol>3</protocol>
<alg>8</alg>
<pubKey>AwEAAdas/oY6xQV2MYd+o5pcUHK0f/mtETRNyBhh/TSABqRM9JikXlSrwLFT9sAfOsTiRNbPnvEiCKdEdoN0f0Oel0WNXadLlVINmxtCue93bSX7zxrVvjhbkHffOVdpBL0CIDQoX1HPZmoBXXPdZtWLpDQ7nVfUtdC/McTFSRawUYaoCWOEAgC8YY+kh6C8TUZzHMl+JiVE6YFkTIFf+z4MxA920UxUnGpdcfRbcB0CYjCxe+PuiA+aZHFheEe5S5tlW7tO96hxK/k2l93N//T2mEM53TKomk62HoWvNVdPrs7jdZbGzeY2eBPDWMAIIpgOv9ApORi+kHSQm2POCwf/KYs=</pubKey>\n </keyData>
</add>
</update>
</extension>
<clTRID>0.04946500 1632965705</clTRID>
</command>
</epp>\n
XML
end
end
125 changes: 0 additions & 125 deletions test/system/registrar_area/xml_consoles_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
<?xml version="1.0" encoding="utf-8"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd" xmlns:domain="https://epp.tld.ee/schema/domain-ee-1.2.xsd" xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1" xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi: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">
<command>
<update>
<domain:update>
<domain:name>shop.test</domain:name>
</domain:update>
</update>
<extension>
<secDNS:update>
<secDNS:rem>
<secDNS:keyData>
<secDNS:flags>#{key.flags}</secDNS:flags>
<secDNS:protocol>#{key.protocol}</secDNS:protocol>
<secDNS:alg>#{key.alg}</secDNS:alg>
<secDNS:pubKey>#{key.public_key}</secDNS:pubKey>
</secDNS:keyData>
</secDNS:rem>
</secDNS:update>
</extension>
<clTRID>0.04946500 1632965705</clTRID>
</command>
</epp>
XML
end

def schema_dnskey_add
<<~XML
<?xml version="1.0" encoding="utf-8"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd" xmlns:domain="https://epp.tld.ee/schema/domain-ee-1.2.xsd" xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1" xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi: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">
<command>
<update>
<domain:update>
<domain:name>shop.test</domain:name>
</domain:update>
</update>
<extension>
<secDNS:update>
<secDNS:add>
<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:add>
</secDNS:update>
</extension>
<clTRID>0.04946500 1632965705</clTRID>
</command>
</epp>
XML
end

def schema_dnskey_update
@dnskey = dnskeys(:one)
@dnskeynew = dnskeys(:two)
<<~XML
<?xml version="1.0" encoding="utf-8"?>
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd" xmlns:domain="https://epp.tld.ee/schema/domain-ee-1.2.xsd" xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1" xmlns:eis="https://epp.tld.ee/schema/eis-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi: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">
<command>
<update>
<domain:update>
<domain:name>shop.test</domain:name>
</domain:update>
</update>
<extension>
<secDNS:update>
<secDNS:rem> \n
<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> \n
</secDNS:rem>
<secDNS:add> \n
<secDNS:keyData>
<secDNS:flags>#{@dnskeynew.flags}</secDNS:flags>
<secDNS:protocol>#{@dnskeynew.protocol}</secDNS:protocol>
<secDNS:alg>#{@dnskeynew.alg}</secDNS:alg>
<secDNS:pubKey>#{@dnskeynew.public_key}</secDNS:pubKey>
</secDNS:keyData> \n
</secDNS:add>
</secDNS:update>
</extension>
<clTRID>0.04946500 1632965705</clTRID>
</command>
</epp>
XML
end

def schema_example
<<~XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
Expand Down

0 comments on commit e9fc932

Please sign in to comment.