test: removed unless tests, added new tests for dnskey and for domain

This commit is contained in:
Oleg Hasjanov 2021-03-04 15:32:19 +02:00
parent 853e4c447b
commit 3a77e420bd
6 changed files with 79 additions and 24 deletions

View file

@ -0,0 +1,11 @@
require 'test_helper'
class FormHelperTest < ActionView::TestCase
def test_legal_document_field
meth = MiniTest::Mock.new
returned_legal_document_field = ApplicationController.helpers.legal_document_field('Hello', meth)
assert returned_legal_document_field.include? 'data-legal-document="true"'
assert returned_legal_document_field.include? 'accept=".pdf,.asice,.asics,.sce,.scs,.adoc,.edoc,.bdoc,.zip,.rar,.gz,.tar,.7z,.odt,.doc,.docx"'
end
end

View file

@ -0,0 +1,9 @@
require 'test_helper'
class FormTagHelperTest < ActionView::TestCase
def test_legal_document_field
returned_legal_document_field = ApplicationController.helpers.legal_document_field_tag('Hello')
assert returned_legal_document_field.include? 'data-legal-document="true"'
assert returned_legal_document_field.include? 'accept=".pdf,.asice,.asics,.sce,.scs,.adoc,.edoc,.bdoc,.zip,.rar,.gz,.tar,.7z,.odt,.doc,.docx"'
end
end

View file

@ -1,18 +0,0 @@
require 'test_helper'
class RegistrantAreaDomainUpdateConfirmsIntegrationTest < ApplicationIntegrationTest
setup do
@domain = domains(:shop)
end
def test_show_confirm_to_update_domain
@domain.update!(registrant_verification_asked_at: Time.zone.now,
registrant_verification_token: 'test',
statuses: [DomainStatus::PENDING_UPDATE])
get registrant_domain_update_confirm_path(@domain, token: 'test', confirmed: true)
assert @domain.registrant_update_confirmable?('test')
end
end

View file

@ -1,6 +1,8 @@
require 'test_helper' require 'test_helper'
class RegistrarAreaDomainsIntegrationTest < ApplicationIntegrationTest class RegistrarAreaDomainsIntegrationTest < ApplicationIntegrationTest
include FormTagHelper
setup do setup do
sign_in users(:api_bestnames) sign_in users(:api_bestnames)
end end

View file

@ -178,6 +178,10 @@ class DNS::ZoneTest < ActiveSupport::TestCase
assert_nil Whois::Record.find_by(name: subzone.origin) assert_nil Whois::Record.find_by(name: subzone.origin)
end end
def test_generate_zonefile
end
private private
def valid_zone def valid_zone

View file

@ -1,11 +1,58 @@
require 'test_helper' require 'test_helper'
class DnskeyTest < ActiveSupport::TestCase class DnskeyTest < ActiveSupport::TestCase
include EppErrors
setup do setup do
@dnskey = 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8 ' @dnskey = 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8'
@domain = domains(:shop)
end end
def test_dns_key def test_valid_dns_key
dns = Dnskey.new
dns.domain_id = @domain.id
dns.flags = 257
dns.protocol = 3
dns.alg = 8
dns.public_key = @dnskey
assert dns.save
end
def test_invalid_algrorithm
dns = Dnskey.new
dns.alg = 666
errors = dns.validate_algorithm
assert_equal errors, ['Valid algorithms are: 3, 5, 6, 7, 8, 10, 13, 14']
end
def test_invalid_protocol
dns = Dnskey.new
dns.protocol = 666
errors = dns.validate_protocol
assert_equal errors, ['Valid protocols are: 3']
end
def test_invalid_flags
dns = Dnskey.new
dns.flags = 666
errors = dns.validate_flags
assert_equal errors, ['Valid flags are: 0, 256, 257']
end
def test_ds_digest_type_one
Setting.ds_digest_type = 1
dns = Dnskey.new
dns.domain_id = @domain.id
dns.flags = 257
dns.protocol = 3
dns.alg = 8
dns.public_key = @dnskey
assert dns.save
assert_equal dns.ds_digest_type, 1
assert_equal dns.ds_digest, '640D173A44D9AF2856FBE282EE64CE11A76DBB84'
end end
end end