Add new algos & test

This commit is contained in:
Alex Sherman 2021-06-21 12:38:20 +05:00
parent 2bdb235610
commit d6310d6b15
3 changed files with 38 additions and 3 deletions

View file

@ -14,8 +14,10 @@ module Depp
['8 - RSA/SHA-256', 8],
['10 - RSA/SHA-512', 10],
['13 - ECDSA Curve P-256 with SHA-256', 13],
['14 - ECDSA Curve P-384 with SHA-384', 14]
]
['14 - ECDSA Curve P-384 with SHA-384', 14],
['15 - Ed25519', 15],
['16 - Ed448', 16],
].freeze
PROTOCOLS = [3]

View file

@ -66,6 +66,39 @@ class ReppV1DomainsDnssecTest < ActionDispatch::IntegrationTest
assert_equal payload[:dns_keys][0][:public_key], dnssec_key.public_key
end
def test_creates_dnssec_key_with_every_algo
algos = Depp::Dnskey::ALGORITHMS.map {|pair| pair[1].to_s}
algos_to_check = %w[15 16]
assert (algos & algos_to_check) == algos_to_check
algos.each do |alg|
assert @domain.dnskeys.empty?
payload = {
dns_keys: [
{ flags: '256',
alg: alg,
protocol: '3',
public_key: 'dGVzdA=='
}
]
}
post "/repp/v1/domains/#{@domain.name}/dnssec", params: payload, headers: @auth_headers
json = JSON.parse(response.body, symbolize_names: true)
@domain.reload
assert_response :ok
assert_equal 1000, json[:code]
assert_equal 'Command completed successfully', json[:message]
assert @domain.dnskeys.present?
dnssec_key = @domain.dnskeys.last
assert_equal payload[:dns_keys][0][:alg].to_i, dnssec_key.alg
@domain.dnskeys.destroy_all
end
end
def test_removes_existing_dnssec_key_successfully
payload = {
dns_keys: [

View file

@ -23,7 +23,7 @@ class DnskeyTest < ActiveSupport::TestCase
dns = Dnskey.new
dns.alg = 666
errors = dns.validate_algorithm.options[:values]
assert_equal errors, 'Valid algorithms are: 3, 5, 6, 7, 8, 10, 13, 14'
assert_equal errors, "Valid algorithms are: #{Dnskey::ALGORITHMS.join(', ')}"
end
def test_invalid_protocol