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

@ -1,11 +1,58 @@
require 'test_helper'
class DnskeyTest < ActiveSupport::TestCase
setup do
@dnskey = 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8 '
end
include EppErrors
def test_dns_key
end
setup do
@dnskey = 'AwEAAddt2AkLfYGKgiEZB5SmIF8EvrjxNMH6HtxWEA4RJ9Ao6LCWheg8'
@domain = domains(:shop)
end
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