Skip to content

Commit

Permalink
Add new algos & test
Browse files Browse the repository at this point in the history
  • Loading branch information
yulgolem committed Jun 21, 2021
1 parent 2bdb235 commit 1883418
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/models/depp/dnskey.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ class Dnskey
['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]

Expand Down
33 changes: 33 additions & 0 deletions test/integration/repp/v1/domains/dnssec_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,39 @@ def test_creates_dnssec_key_successfully
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: [
Expand Down

0 comments on commit 1883418

Please sign in to comment.