mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 11:16:00 +02:00
parent
bb108efedd
commit
fa52001be6
141 changed files with 1388 additions and 1664 deletions
|
@ -20,7 +20,7 @@ class RegistrantApiAuthenticationTest < ApplicationIntegrationTest
|
|||
last_name: 'Smith',
|
||||
}
|
||||
|
||||
post '/api/v1/registrant/auth/eid', params
|
||||
post '/api/v1/registrant/auth/eid', params: params
|
||||
assert(User.find_by(registrant_ident: 'EE-30110100103'))
|
||||
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
@ -29,7 +29,7 @@ class RegistrantApiAuthenticationTest < ApplicationIntegrationTest
|
|||
|
||||
def test_request_returns_existing_user
|
||||
assert_no_changes User.count do
|
||||
post '/api/v1/registrant/auth/eid', @user_hash
|
||||
post '/api/v1/registrant/auth/eid', params: @user_hash
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -38,7 +38,7 @@ class RegistrantApiAuthenticationTest < ApplicationIntegrationTest
|
|||
@original_whitelist_ip = ENV['registrant_api_auth_allowed_ips']
|
||||
ENV['registrant_api_auth_allowed_ips'] = '1.2.3.4'
|
||||
|
||||
post '/api/v1/registrant/auth/eid', params
|
||||
post '/api/v1/registrant/auth/eid', params: params
|
||||
assert_equal(401, response.status)
|
||||
json_body = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
|
@ -50,7 +50,7 @@ class RegistrantApiAuthenticationTest < ApplicationIntegrationTest
|
|||
def test_request_documented_parameters_are_required
|
||||
params = { foo: :bar, test: :test }
|
||||
|
||||
post '/api/v1/registrant/auth/eid', params
|
||||
post '/api/v1/registrant/auth/eid', params: params
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_equal({ errors: [{ ident: ['parameter is required'] }] }, json)
|
||||
assert_equal(422, response.status)
|
||||
|
|
|
@ -14,18 +14,19 @@ class RegistrantApiContactsTest < ApplicationIntegrationTest
|
|||
contacts(:william).update!(ident: '1234', ident_type: 'priv', ident_country_code: 'US')
|
||||
assert_equal 3, @user.contacts.size
|
||||
|
||||
get '/api/v1/registrant/contacts', { 'limit' => 1, 'offset' => 0 }, @auth_headers
|
||||
get '/api/v1/registrant/contacts', params: { 'limit' => 1, 'offset' => 0 },
|
||||
headers: @auth_headers
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_equal(200, response.status)
|
||||
assert_equal(1, response_json.count)
|
||||
|
||||
get '/api/v1/registrant/contacts', {}, @auth_headers
|
||||
get '/api/v1/registrant/contacts', headers: @auth_headers
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_equal(3, response_json.count)
|
||||
end
|
||||
|
||||
def test_get_contact_details_by_uuid
|
||||
get api_v1_registrant_contact_path(@contact.uuid), nil, @auth_headers
|
||||
get api_v1_registrant_contact_path(@contact.uuid), headers: @auth_headers
|
||||
|
||||
assert_response :ok
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
@ -33,21 +34,23 @@ class RegistrantApiContactsTest < ApplicationIntegrationTest
|
|||
end
|
||||
|
||||
def test_root_does_not_accept_limit_higher_than_200
|
||||
get '/api/v1/registrant/contacts', { 'limit' => 400, 'offset' => 0 }, @auth_headers
|
||||
get '/api/v1/registrant/contacts', params: { 'limit' => 400, 'offset' => 0 },
|
||||
headers: @auth_headers
|
||||
assert_equal(400, response.status)
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_equal({ errors: [{ limit: ['parameter is out of range'] }] }, response_json)
|
||||
end
|
||||
|
||||
def test_root_does_not_accept_offset_lower_than_0
|
||||
get '/api/v1/registrant/contacts', { 'limit' => 200, 'offset' => "-10" }, @auth_headers
|
||||
get '/api/v1/registrant/contacts', params: { 'limit' => 200, 'offset' => "-10" },
|
||||
headers: @auth_headers
|
||||
assert_equal(400, response.status)
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_equal({ errors: [{ offset: ['parameter is out of range'] }] }, response_json)
|
||||
end
|
||||
|
||||
def test_root_returns_401_without_authorization
|
||||
get '/api/v1/registrant/contacts', {}, {}
|
||||
get '/api/v1/registrant/contacts'
|
||||
assert_equal(401, response.status)
|
||||
json_body = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
|
|
|
@ -2,13 +2,13 @@ require 'test_helper'
|
|||
|
||||
class RegistrantApiCorsHeadersTest < ApplicationIntegrationTest
|
||||
def test_returns_200_response_code_for_options_request
|
||||
options '/api/v1/registrant/auth/eid', {}, { 'Origin' => 'https://example.com' }
|
||||
|
||||
process :options, api_v1_registrant_auth_eid_path,
|
||||
headers: { 'Origin' => 'https://example.com' }
|
||||
assert_equal('200', response.code)
|
||||
end
|
||||
|
||||
def test_returns_expected_headers_for_options_requests
|
||||
options '/api/v1/registrant/auth/eid', {}, { 'Origin' => 'https://example.com' }
|
||||
process :options, api_v1_registrant_auth_eid_path, headers: { 'Origin' => 'https://example.com' }
|
||||
|
||||
assert_equal('https://example.com', response.headers['Access-Control-Allow-Origin'])
|
||||
assert_equal('POST, GET, PUT, PATCH, DELETE, OPTIONS',
|
||||
|
@ -20,16 +20,15 @@ class RegistrantApiCorsHeadersTest < ApplicationIntegrationTest
|
|||
end
|
||||
|
||||
def test_returns_empty_body
|
||||
options '/api/v1/registrant/auth/eid', { 'Origin' => 'https://example.com' }
|
||||
|
||||
process :options, api_v1_registrant_auth_eid_path, headers: { 'Origin' => 'https://example.com' }
|
||||
assert_equal('', response.body)
|
||||
end
|
||||
|
||||
def test_it_returns_cors_headers_for_other_requests
|
||||
post '/api/v1/registrant/auth/eid', {}, { 'Origin' => 'https://example.com' }
|
||||
post '/api/v1/registrant/auth/eid', headers: { 'Origin' => 'https://example.com' }
|
||||
assert_equal('https://example.com', response.headers['Access-Control-Allow-Origin'])
|
||||
|
||||
get '/api/v1/registrant/contacts', {}, { 'Origin' => 'https://example.com' }
|
||||
get '/api/v1/registrant/contacts', headers: { 'Origin' => 'https://example.com' }
|
||||
assert_equal('https://example.com', response.headers['Access-Control-Allow-Origin'])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
|
|||
end
|
||||
|
||||
def test_get_domain_details_by_uuid
|
||||
get '/api/v1/registrant/domains/5edda1a5-3548-41ee-8b65-6d60daf85a37', {}, @auth_headers
|
||||
get '/api/v1/registrant/domains/5edda1a5-3548-41ee-8b65-6d60daf85a37', headers: @auth_headers
|
||||
assert_equal(200, response.status)
|
||||
|
||||
domain = JSON.parse(response.body, symbolize_names: true)
|
||||
|
@ -30,7 +30,7 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
|
|||
end
|
||||
|
||||
def test_get_non_existent_domain_details_by_uuid
|
||||
get '/api/v1/registrant/domains/random-uuid', {}, @auth_headers
|
||||
get '/api/v1/registrant/domains/random-uuid', headers: @auth_headers
|
||||
assert_equal(404, response.status)
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
@ -38,7 +38,7 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
|
|||
end
|
||||
|
||||
def test_root_returns_domain_list
|
||||
get '/api/v1/registrant/domains', {}, @auth_headers
|
||||
get '/api/v1/registrant/domains', headers: @auth_headers
|
||||
assert_equal(200, response.status)
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
@ -50,20 +50,22 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
|
|||
end
|
||||
|
||||
def test_root_accepts_limit_and_offset_parameters
|
||||
get '/api/v1/registrant/domains', { 'limit' => 2, 'offset' => 0 }, @auth_headers
|
||||
get '/api/v1/registrant/domains', params: { 'limit' => 2, 'offset' => 0 },
|
||||
headers: @auth_headers
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_equal(200, response.status)
|
||||
assert_equal(2, response_json.count)
|
||||
|
||||
get '/api/v1/registrant/domains', {}, @auth_headers
|
||||
get '/api/v1/registrant/domains', headers: @auth_headers
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_equal(4, response_json.count)
|
||||
end
|
||||
|
||||
def test_root_does_not_accept_limit_higher_than_200
|
||||
get '/api/v1/registrant/domains', { 'limit' => 400, 'offset' => 0 }, @auth_headers
|
||||
get '/api/v1/registrant/domains', params: { 'limit' => 400, 'offset' => 0 },
|
||||
headers: @auth_headers
|
||||
|
||||
assert_equal(400, response.status)
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
@ -71,7 +73,8 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
|
|||
end
|
||||
|
||||
def test_root_does_not_accept_offset_lower_than_0
|
||||
get '/api/v1/registrant/domains', { 'limit' => 200, 'offset' => "-10" }, @auth_headers
|
||||
get '/api/v1/registrant/domains', params: { 'limit' => 200, 'offset' => "-10" },
|
||||
headers: @auth_headers
|
||||
|
||||
assert_equal(400, response.status)
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
@ -79,7 +82,7 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
|
|||
end
|
||||
|
||||
def test_root_returns_401_without_authorization
|
||||
get '/api/v1/registrant/domains', {}, {}
|
||||
get '/api/v1/registrant/domains'
|
||||
assert_equal(401, response.status)
|
||||
json_body = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
|
@ -87,7 +90,7 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
|
|||
end
|
||||
|
||||
def test_details_returns_401_without_authorization
|
||||
get '/api/v1/registrant/domains/5edda1a5-3548-41ee-8b65-6d60daf85a37', {}, {}
|
||||
get '/api/v1/registrant/domains/5edda1a5-3548-41ee-8b65-6d60daf85a37'
|
||||
assert_equal(401, response.status)
|
||||
json_body = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
|
|||
|
||||
def test_can_lock_a_not_locked_domain
|
||||
post '/api/v1/registrant/domains/2df2c1a1-8f6a-490a-81be-8bdf29866880/registry_lock',
|
||||
{}, @auth_headers
|
||||
headers: @auth_headers
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
|
@ -27,7 +27,7 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
|
|||
def test_locking_a_domain_creates_a_version_record
|
||||
assert_difference '@domain.versions.count', 1 do
|
||||
post '/api/v1/registrant/domains/2df2c1a1-8f6a-490a-81be-8bdf29866880/registry_lock',
|
||||
{}, @auth_headers
|
||||
headers: @auth_headers
|
||||
end
|
||||
|
||||
@domain.reload
|
||||
|
@ -39,7 +39,7 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
|
|||
@domain.save
|
||||
|
||||
post '/api/v1/registrant/domains/2df2c1a1-8f6a-490a-81be-8bdf29866880/registry_lock',
|
||||
{}, @auth_headers
|
||||
headers: @auth_headers
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_equal(422, response.status)
|
||||
|
@ -51,7 +51,7 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
|
|||
assert(@domain.locked_by_registrant?)
|
||||
|
||||
post '/api/v1/registrant/domains/2df2c1a1-8f6a-490a-81be-8bdf29866880/registry_lock',
|
||||
{}, @auth_headers
|
||||
headers: @auth_headers
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_equal(422, response.status)
|
||||
|
@ -62,7 +62,7 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
|
|||
@domain.apply_registry_lock
|
||||
|
||||
delete '/api/v1/registrant/domains/2df2c1a1-8f6a-490a-81be-8bdf29866880/registry_lock',
|
||||
{}, @auth_headers
|
||||
headers: @auth_headers
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
assert(response_json[:statuses].include?(DomainStatus::OK))
|
||||
|
@ -73,7 +73,7 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
|
|||
|
||||
def test_cannot_unlock_a_not_locked_domain
|
||||
delete '/api/v1/registrant/domains/2df2c1a1-8f6a-490a-81be-8bdf29866880/registry_lock',
|
||||
{}, @auth_headers
|
||||
headers: @auth_headers
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_equal(422, response.status)
|
||||
|
@ -81,8 +81,7 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
|
|||
end
|
||||
|
||||
def test_returns_404_when_domain_is_not_found
|
||||
post '/api/v1/registrant/domains/random-uuid/registry_lock',
|
||||
{}, @auth_headers
|
||||
post '/api/v1/registrant/domains/random-uuid/registry_lock', headers: @auth_headers
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_equal(404, response.status)
|
||||
|
@ -99,7 +98,7 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
|
|||
assert_equal '1234', contact.ident
|
||||
assert_equal 'US', contact.ident_country_code
|
||||
|
||||
post api_v1_registrant_domain_registry_lock_path(domain.uuid), nil, @auth_headers
|
||||
post api_v1_registrant_domain_registry_lock_path(domain.uuid), headers: @auth_headers
|
||||
|
||||
assert_response :unauthorized
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
@ -109,7 +108,7 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
|
|||
|
||||
def test_registrant_can_lock_a_domain
|
||||
post '/api/v1/registrant/domains/1b3ee442-e8fe-4922-9492-8fcb9dccc69c/registry_lock',
|
||||
{}, @auth_headers
|
||||
headers: @auth_headers
|
||||
|
||||
assert_equal(200, response.status)
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
@ -125,7 +124,7 @@ class RegistrantApiRegistryLocksTest < ApplicationIntegrationTest
|
|||
assert_equal 'https://bestnames.test', @domain.registrar.website
|
||||
|
||||
post '/api/v1/registrant/domains/1b3ee442-e8fe-4922-9492-8fcb9dccc69c/registry_lock',
|
||||
{}, @auth_headers
|
||||
headers: @auth_headers
|
||||
|
||||
assert_equal(200, response.status)
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue