added test for feature absctraction

This commit is contained in:
olegphenomenon 2021-09-10 15:58:03 +03:00
parent 00aae6b51f
commit 285c0e78a2
3 changed files with 129 additions and 1 deletions

View file

@ -1,6 +1,7 @@
class Feature
def self.obj_and_extensions_statuses_enabled?
return false if ENV['obj_and_extensions_prohibited'] == 'false'
ENV['obj_and_extensions_prohibited'] || false
end
end
end

View file

@ -48,6 +48,100 @@ class EppDomainUpdateBaseTest < EppTestCase
assert_epp_response :parameter_value_syntax_error
end
def test_set_false_for_obj_and_extensions_prohibited
ENV['obj_and_extensions_prohibited'] = 'false'
@domain = domains(:shop)
@domain.statuses << DomainStatus::SERVER_OBJ_UPDATE_PROHIBITED
@domain.save
@dnskey = dnskeys(:one)
@dnskey.update(domain: @domain)
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:rem>
<domain:ns>
<domain:hostAttr>
<domain:hostName>#{nameservers(:shop_ns1).hostname}</domain:hostName>
</domain:hostAttr>
<domain:hostAttr>
<domain:hostName>#{nameservers(:shop_ns2).hostname}</domain:hostName>
</domain:hostAttr>
</domain:ns>
<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>
</domain:rem>
</domain:update>
</update>
</command>
</epp>
XML
post epp_update_path, params: { frame: request_xml },
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
response_xml = Nokogiri::XML(response.body)
p response.body
assert_correct_against_schema response_xml
@domain.reload
assert_epp_response :completed_successfully
ENV['obj_and_extensions_prohibited'] = nil
end
def test_set_nil_for_obj_and_extensions_prohibited
ENV['obj_and_extensions_prohibited'] = nil
@domain = domains(:shop)
@domain.statuses << DomainStatus::SERVER_OBJ_UPDATE_PROHIBITED
@domain.save
@dnskey = dnskeys(:one)
@dnskey.update(domain: @domain)
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:rem>
<domain:ns>
<domain:hostAttr>
<domain:hostName>#{nameservers(:shop_ns1).hostname}</domain:hostName>
</domain:hostAttr>
<domain:hostAttr>
<domain:hostName>#{nameservers(:shop_ns2).hostname}</domain:hostName>
</domain:hostAttr>
</domain:ns>
<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>
</domain:rem>
</domain:update>
</update>
</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_epp_response :completed_successfully
end
def test_update_domain_data_out_of_extension_block_with_serverObjUpdateProhibited
ENV['obj_and_extensions_prohibited'] = 'true'
@domain = domains(:shop)
@ -92,6 +186,7 @@ class EppDomainUpdateBaseTest < EppTestCase
@domain.reload
assert_epp_response :object_status_prohibits_operation
ENV['obj_and_extensions_prohibited'] = nil
end
def test_update_domain_data_out_of_extension_block_with_extension_update_prohibited
@ -130,6 +225,7 @@ class EppDomainUpdateBaseTest < EppTestCase
@domain.reload
assert_epp_response :completed_successfully
ENV['obj_and_extensions_prohibited'] = nil
end
def test_update_domain_dns_with_extension_update_prohibited
@ -172,6 +268,7 @@ class EppDomainUpdateBaseTest < EppTestCase
@domain.reload
assert_epp_response :object_status_prohibits_operation
ENV['obj_and_extensions_prohibited'] = nil
end
def test_update_domain

View file

@ -0,0 +1,30 @@
require 'test_helper'
class FeatureTest < ActiveSupport::TestCase
def test_if_obj_and_extensions_prohibited_enabled
ENV['obj_and_extensions_prohibited'] = 'true'
assert Feature.obj_and_extensions_statuses_enabled?
statuses = DomainStatus.admin_statuses
assert statuses.include? DomainStatus::SERVER_OBJ_UPDATE_PROHIBITED
end
def test_if_obj_and_extensions_prohibited_is_nil
ENV['obj_and_extensions_prohibited'] = nil
assert_not Feature.obj_and_extensions_statuses_enabled?
statuses = DomainStatus.admin_statuses
assert_not statuses.include? DomainStatus::SERVER_OBJ_UPDATE_PROHIBITED
end
def test_if_obj_and_extensions_prohibited_is_false
ENV['obj_and_extensions_prohibited'] = 'false'
assert_not Feature.obj_and_extensions_statuses_enabled?
statuses = DomainStatus.admin_statuses
assert_not statuses.include? DomainStatus::SERVER_OBJ_UPDATE_PROHIBITED
end
end