mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 05:05:45 +02:00
Add new algos & test
This commit is contained in:
parent
2bdb235610
commit
d6310d6b15
3 changed files with 38 additions and 3 deletions
|
@ -14,8 +14,10 @@ module Depp
|
||||||
['8 - RSA/SHA-256', 8],
|
['8 - RSA/SHA-256', 8],
|
||||||
['10 - RSA/SHA-512', 10],
|
['10 - RSA/SHA-512', 10],
|
||||||
['13 - ECDSA Curve P-256 with SHA-256', 13],
|
['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]
|
PROTOCOLS = [3]
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,39 @@ class ReppV1DomainsDnssecTest < ActionDispatch::IntegrationTest
|
||||||
assert_equal payload[:dns_keys][0][:public_key], dnssec_key.public_key
|
assert_equal payload[:dns_keys][0][:public_key], dnssec_key.public_key
|
||||||
end
|
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
|
def test_removes_existing_dnssec_key_successfully
|
||||||
payload = {
|
payload = {
|
||||||
dns_keys: [
|
dns_keys: [
|
||||||
|
|
|
@ -23,7 +23,7 @@ class DnskeyTest < ActiveSupport::TestCase
|
||||||
dns = Dnskey.new
|
dns = Dnskey.new
|
||||||
dns.alg = 666
|
dns.alg = 666
|
||||||
errors = dns.validate_algorithm.options[:values]
|
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
|
end
|
||||||
|
|
||||||
def test_invalid_protocol
|
def test_invalid_protocol
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue