mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 14:44:47 +02:00
covered white_ips and covered a little certificates
This commit is contained in:
parent
512d4137e8
commit
a5f8e277dd
2 changed files with 133 additions and 28 deletions
|
@ -13,32 +13,16 @@ class AdminAreaCertificatesIntegrationTest < JavaScriptApplicationSystemTestCase
|
|||
|
||||
@apiuser = users(:api_bestnames)
|
||||
@certificate = certificates(:api)
|
||||
# @certificate.update!(csr: "-----BEGIN CERTIFICATE REQUEST-----
|
||||
# MIICszCCAZsCAQAwbjELMAkGA1UEBhMCRUUxFDASBgNVBAMMC2ZyZXNoYm94LmVl
|
||||
# MRAwDgYDVQQHDAdUYWxsaW5uMREwDwYDVQQKDAhGcmVzaGJveDERMA8GA1UECAwI
|
||||
# SGFyanVtYWExETAPBgNVBAsMCEZyZXNoYm94MIIBIjANBgkqhkiG9w0BAQEFAAOC
|
||||
# AQ8AMIIBCgKCAQEA1VVESynZoZhIbe8s9zHkELZ/ZDCGiM2Q8IIGb1IOieT5U2mx
|
||||
# IsVXz85USYsSQY9+4YdEXnupq9fShArT8pstS/VN6BnxdfAiYXc3UWWAuaYAdNGJ
|
||||
# Dr5Jf6uMt1wVnCgoDL7eJq9tWMwARC/viT81o92fgqHFHW0wEolfCmnpik9o0ACD
|
||||
# FiWZ9IBIevmFqXtq25v9CY2cT9+eZW127WtJmOY/PKJhzh0QaEYHqXTHWOLZWpnp
|
||||
# HH4elyJ2CrFulOZbHPkPNB9Nf4XQjzk1ffoH6e5IVys2VV5xwcTkF0jY5XTROVxX
|
||||
# lR2FWqic8Q2pIhSks48+J6o1GtXGnTxv94lSDwIDAQABoAAwDQYJKoZIhvcNAQEL
|
||||
# BQADggEBAEFcYmQvcAC8773eRTWBJJNoA4kRgoXDMYiiEHih5iJPVSxfidRwYDTF
|
||||
# sP+ttNTUg3JocFHY75kuM9T2USh+gu/trRF0o4WWa+AbK3JbbdjdT1xOMn7XtfUU
|
||||
# Z/f1XCS9YdHQFCA6nk4Z+TLWwYsgk7n490AQOiB213fa1UIe83qIfw/3GRqRUZ7U
|
||||
# wIWEGsHED5WT69GyxjyKHcqGoV7uFnqFN0sQVKVTy/NFRVQvtBUspCbsOirdDRie
|
||||
# AB2KbGHL+t1QrRF10szwCJDyk5aYlVhxvdI8zn010nrxHkiyQpDFFldDMLJl10BW
|
||||
# 2w9PGO061z+tntdRcKQGuEpnIr9U5Vs=
|
||||
# -----END CERTIFICATE REQUEST----\n")
|
||||
@certificate.update!(csr: "-----BEGIN CERTIFICATE REQUEST-----\nMIICszCCAZsCAQAwbjELMAkGA1UEBhMCRUUxFDASBgNVBAMMC2ZyZXNoYm94LmVl\nMRAwDgYDVQQHDAdUYWxsaW5uMREwDwYDVQQKDAhGcmVzaGJveDERMA8GA1UECAwI\nSGFyanVtYWExETAPBgNVBAsMCEZyZXNoYm94MIIBIjANBgkqhkiG9w0BAQEFAAOC\nAQ8AMIIBCgKCAQEA1VVESynZoZhIbe8s9zHkELZ/ZDCGiM2Q8IIGb1IOieT5U2mx\nIsVXz85USYsSQY9+4YdEXnupq9fShArT8pstS/VN6BnxdfAiYXc3UWWAuaYAdNGJ\nDr5Jf6uMt1wVnCgoDL7eJq9tWMwARC/viT81o92fgqHFHW0wEolfCmnpik9o0ACD\nFiWZ9IBIevmFqXtq25v9CY2cT9+eZW127WtJmOY/PKJhzh0QaEYHqXTHWOLZWpnp\nHH4elyJ2CrFulOZbHPkPNB9Nf4XQjzk1ffoH6e5IVys2VV5xwcTkF0jY5XTROVxX\nlR2FWqic8Q2pIhSks48+J6o1GtXGnTxv94lSDwIDAQABoAAwDQYJKoZIhvcNAQEL\nBQADggEBAEFcYmQvcAC8773eRTWBJJNoA4kRgoXDMYiiEHih5iJPVSxfidRwYDTF\nsP+ttNTUg3JocFHY75kuM9T2USh+gu/trRF0o4WWa+AbK3JbbdjdT1xOMn7XtfUU\nZ/f1XCS9YdHQFCA6nk4Z+TLWwYsgk7n490AQOiB213fa1UIe83qIfw/3GRqRUZ7U\nwIWEGsHED5WT69GyxjyKHcqGoV7uFnqFN0sQVKVTy/NFRVQvtBUspCbsOirdDRie\nAB2KbGHL+t1QrRF10szwCJDyk5aYlVhxvdI8zn010nrxHkiyQpDFFldDMLJl10BW\n2w9PGO061z+tntdRcKQGuEpnIr9U5Vs=\n-----END CERTIFICATE REQUEST-----\n")
|
||||
end
|
||||
|
||||
# Helpers
|
||||
# Helpers =======================
|
||||
def show_certificate_info
|
||||
visit admin_api_user_certificate_path(api_user_id: @apiuser.id, id: @certificate.id)
|
||||
assert_text 'Certificates'
|
||||
end
|
||||
|
||||
# Tests
|
||||
# TESTs ===========================
|
||||
def test_show_certificate_info
|
||||
show_certificate_info
|
||||
end
|
||||
|
@ -52,18 +36,38 @@ class AdminAreaCertificatesIntegrationTest < JavaScriptApplicationSystemTestCase
|
|||
assert_text 'Record deleted'
|
||||
end
|
||||
|
||||
# TODO
|
||||
# Should be display "Revoke this certificate" button
|
||||
# download_csr_admin_api_user_certificate GET /admin/api_users/:api_user_id/certificates/:id/download_csr(.:format)
|
||||
def test_download_csr
|
||||
get download_csr_admin_api_user_certificate_path(api_user_id: @apiuser.id, id: @certificate.id)
|
||||
|
||||
# def test_revoke_certificate
|
||||
# show_certificate_info
|
||||
assert_response :ok
|
||||
assert_equal 'application/octet-stream', response.headers['Content-Type']
|
||||
assert_equal "attachment; filename=\"test_bestnames.csr.pem\"; filename*=UTF-8''test_bestnames.csr.pem", response.headers['Content-Disposition']
|
||||
assert_not_empty response.body
|
||||
end
|
||||
|
||||
# element = find(:xpath, "//body/div[2]").native.attribute('outerHTML')
|
||||
# puts element
|
||||
# download_crt_admin_api_user_certificate GET /admin/api_users/:api_user_id/certificates/:id/download_crt(.:format)
|
||||
def test_download_crt
|
||||
get download_crt_admin_api_user_certificate_path(api_user_id: @apiuser.id, id: @certificate.id)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 'application/octet-stream', response.headers['Content-Type']
|
||||
assert_equal "attachment; filename=\"test_bestnames.crt.pem\"; filename*=UTF-8''test_bestnames.crt.pem", response.headers['Content-Disposition']
|
||||
assert_not_empty response.body
|
||||
end
|
||||
|
||||
# # find(:xpath, "/html/body/div[2]/div[5]/div/div/div[1]/div[2]/a[2]").click
|
||||
def test_failed_to_revoke_certificate
|
||||
show_certificate_info
|
||||
|
||||
# # assert_text 'Record deleted'
|
||||
# end
|
||||
find(:xpath, "//a[text()='Revoke this certificate']").click
|
||||
assert_text 'Failed to update record'
|
||||
|
||||
# element = find(:xpath, "//body").native.attribute('outerHTML')
|
||||
# puts element
|
||||
|
||||
# find(:xpath, "/html/body/div[2]/div[5]/div/div/div[1]/div[2]/a[2]").click
|
||||
|
||||
# assert_text 'Record deleted'
|
||||
end
|
||||
|
||||
end
|
101
test/integration/admin_area/white_ips_test.rb
Normal file
101
test/integration/admin_area/white_ips_test.rb
Normal file
|
@ -0,0 +1,101 @@
|
|||
# admin_registrar_white_ips GET /admin/registrars/:registrar_id/white_ips(.:format)
|
||||
|
||||
require 'test_helper'
|
||||
require 'application_system_test_case'
|
||||
|
||||
class AdminAreaWhiteIpsIntegrationTest < JavaScriptApplicationSystemTestCase
|
||||
|
||||
setup do
|
||||
WebMock.allow_net_connect!
|
||||
sign_in users(:admin)
|
||||
|
||||
@registrar = registrars(:bestnames)
|
||||
@white_ip = white_ips(:one)
|
||||
end
|
||||
|
||||
# Helpers ====================================
|
||||
def visit_new_whitelisted_ip_page
|
||||
visit new_admin_registrar_white_ip_path(registrar_id: @registrar.id)
|
||||
assert_text 'New whitelisted IP'
|
||||
end
|
||||
|
||||
def visit_edit_whitelisted_ip_page
|
||||
visit edit_admin_registrar_white_ip_path(registrar_id: @registrar.id, id: @white_ip.id)
|
||||
assert_text 'Edit white IP'
|
||||
end
|
||||
|
||||
def visit_info_whitelisted_ip_page
|
||||
visit admin_registrar_white_ip_path(registrar_id: @registrar.id, id: @white_ip.id)
|
||||
assert_text 'White IP'
|
||||
end
|
||||
|
||||
# Tests =====================================
|
||||
|
||||
def test_visit_new_whitelisted_ip_page
|
||||
visit_new_whitelisted_ip_page
|
||||
end
|
||||
|
||||
def test_create_new_whitelisted_ip
|
||||
visit_new_whitelisted_ip_page
|
||||
fill_in 'IPv4', with: "127.0.0.1"
|
||||
fill_in 'IPv6', with: "::ffff:192.0.2.1"
|
||||
|
||||
find(:css, "#white_ip_interfaces_api").set(true)
|
||||
find(:css, "#white_ip_interfaces_registrar").set(true)
|
||||
|
||||
click_on 'Save'
|
||||
|
||||
assert_text 'Record created'
|
||||
end
|
||||
|
||||
def test_failed_to_create_new_whitelisted_ip
|
||||
visit_new_whitelisted_ip_page
|
||||
fill_in 'IPv4', with: "asdadadad.asd"
|
||||
|
||||
click_on 'Save'
|
||||
|
||||
assert_text 'Failed to create record'
|
||||
end
|
||||
|
||||
def test_visit_edit_whitelisted_ip_page
|
||||
visit_edit_whitelisted_ip_page
|
||||
end
|
||||
|
||||
def test_update_whitelisted_ip
|
||||
visit_info_whitelisted_ip_page
|
||||
click_on 'Edit'
|
||||
|
||||
fill_in 'IPv4', with: "127.0.0.2"
|
||||
|
||||
find(:css, "#white_ip_interfaces_api").set(false)
|
||||
|
||||
click_on 'Save'
|
||||
|
||||
assert_text 'Record updated'
|
||||
end
|
||||
|
||||
def test_failed_to_update_whitelisted_ip
|
||||
visit_info_whitelisted_ip_page
|
||||
click_on 'Edit'
|
||||
|
||||
fill_in 'IPv4', with: "asdadad#"
|
||||
|
||||
click_on 'Save'
|
||||
|
||||
assert_text 'Failed to update record'
|
||||
end
|
||||
|
||||
def test_visit_info_whitelisted_ip_page
|
||||
visit_info_whitelisted_ip_page
|
||||
end
|
||||
|
||||
def test_delete_whitelisted_ip
|
||||
visit_info_whitelisted_ip_page
|
||||
|
||||
click_on 'Delete'
|
||||
|
||||
page.driver.browser.switch_to.alert.accept
|
||||
|
||||
assert_text 'Record deleted'
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue