mirror of
https://github.com/internetee/registry.git
synced 2025-07-28 05:26:17 +02:00
Add admin mailers and tests to white_ips
This commit is contained in:
parent
149cbb6138
commit
f68d8e91c2
8 changed files with 45 additions and 6 deletions
|
@ -16,7 +16,7 @@ class ReppV1WhiteIpsCreateTest < ActionDispatch::IntegrationTest
|
|||
request_body = {
|
||||
white_ip: {
|
||||
address: '127.1.1.1',
|
||||
interfaces: ['API'],
|
||||
interfaces: ['api'],
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -31,13 +31,41 @@ class ReppV1WhiteIpsCreateTest < ActionDispatch::IntegrationTest
|
|||
assert white_ip.present?
|
||||
|
||||
assert_equal(request_body[:white_ip][:address], white_ip.ipv4)
|
||||
refute white_ip.committed
|
||||
|
||||
last_email = ActionMailer::Base.deliveries.last
|
||||
assert last_email.subject.include?('Whitelisted IP Address Change Notification')
|
||||
end
|
||||
|
||||
def test_creates_new_white_ip_with_registrar_interface
|
||||
request_body = {
|
||||
white_ip: {
|
||||
address: '127.1.1.1',
|
||||
interfaces: ['registrar'],
|
||||
},
|
||||
}
|
||||
|
||||
post '/repp/v1/white_ips', headers: @auth_headers, params: request_body
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 1000, json[:code]
|
||||
assert_equal 'Command completed successfully', json[:message]
|
||||
|
||||
white_ip = WhiteIp.find(json[:data][:ip][:id])
|
||||
assert white_ip.present?
|
||||
|
||||
assert_equal(request_body[:white_ip][:address], white_ip.ipv4)
|
||||
assert white_ip.committed
|
||||
|
||||
refute ActionMailer::Base.deliveries.last
|
||||
end
|
||||
|
||||
def test_validates_ip_max_count
|
||||
request_body = {
|
||||
white_ip: {
|
||||
address: '2001:db8::/120',
|
||||
interfaces: ['API'],
|
||||
interfaces: ['api'],
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -55,7 +83,7 @@ class ReppV1WhiteIpsCreateTest < ActionDispatch::IntegrationTest
|
|||
request_body = {
|
||||
white_ip: {
|
||||
address: '127.0.0.1',
|
||||
interfaces: ['API'],
|
||||
interfaces: ['api'],
|
||||
},
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue