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

@ -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: [