mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 14:44:47 +02:00
Merge remote-tracking branch 'origin/master' into 1739-ns-bulk-change-test-and-whois-update
This commit is contained in:
commit
c1aa286e90
192 changed files with 5154 additions and 1343 deletions
10
test/fixtures/bounced_mail_addresses.yml
vendored
Normal file
10
test/fixtures/bounced_mail_addresses.yml
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
one:
|
||||
email: bounced@registry.test
|
||||
message_id: 010f0174a0c7d348-ea6e2fc1-0854-4073-b71f-5cecf9b0d0b2-000000
|
||||
bounce_type: Permanent
|
||||
bounce_subtype: General
|
||||
action: failed
|
||||
status: '5.1.1'
|
||||
diagnostic: 'smtp; 550 5.1.1 user unknown'
|
||||
created_at: <%= Time.zone.parse('2010-07-05').to_s(:db) %>
|
||||
updated_at: <%= Time.zone.parse('2010-07-05').to_s(:db) %>
|
|
@ -27,8 +27,8 @@ class APIDomainContactsTest < ApplicationIntegrationTest
|
|||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response :ok
|
||||
assert_equal ({ affected_domains: %w[airport.test shop.test],
|
||||
skipped_domains: [] }),
|
||||
assert_equal ({ code: 1000, message: 'Command completed successfully', data: { affected_domains: %w[airport.test shop.test],
|
||||
skipped_domains: [] }}),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
|
@ -42,7 +42,7 @@ class APIDomainContactsTest < ApplicationIntegrationTest
|
|||
|
||||
assert_response :ok
|
||||
assert_equal %w[airport.test shop.test], JSON.parse(response.body,
|
||||
symbolize_names: true)[:skipped_domains]
|
||||
symbolize_names: true)[:data][:skipped_domains]
|
||||
end
|
||||
|
||||
def test_keep_other_tech_contacts_intact
|
||||
|
@ -66,10 +66,8 @@ class APIDomainContactsTest < ApplicationIntegrationTest
|
|||
new_contact_id: 'william-002' },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response :bad_request
|
||||
assert_equal ({ error: { type: 'invalid_request_error',
|
||||
param: 'current_contact_id',
|
||||
message: 'No such contact: jack-001' } }),
|
||||
assert_response :not_found
|
||||
assert_equal ({ code: 2303, message: 'Object does not exist' }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
|
@ -77,10 +75,8 @@ class APIDomainContactsTest < ApplicationIntegrationTest
|
|||
patch '/repp/v1/domains/contacts', params: { current_contact_id: 'non-existent',
|
||||
new_contact_id: 'john-001' },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response :bad_request
|
||||
assert_equal ({ error: { type: 'invalid_request_error',
|
||||
param: 'current_contact_id',
|
||||
message: 'No such contact: non-existent' } }),
|
||||
assert_response :not_found
|
||||
assert_equal ({ code: 2303, message: 'Object does not exist' }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
|
@ -88,10 +84,8 @@ class APIDomainContactsTest < ApplicationIntegrationTest
|
|||
patch '/repp/v1/domains/contacts', params: { current_contact_id: 'william-001',
|
||||
new_contact_id: 'non-existent' },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response :bad_request
|
||||
assert_equal ({ error: { type: 'invalid_request_error',
|
||||
param: 'new_contact_id',
|
||||
message: 'No such contact: non-existent' } }),
|
||||
assert_response :not_found
|
||||
assert_equal ({code: 2303, message: 'Object does not exist'}),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
|
@ -100,9 +94,7 @@ class APIDomainContactsTest < ApplicationIntegrationTest
|
|||
new_contact_id: 'invalid' },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response :bad_request
|
||||
assert_equal ({ error: { type: 'invalid_request_error',
|
||||
param: 'new_contact_id',
|
||||
message: 'New contact must be valid' } }),
|
||||
assert_equal ({ code: 2304, message: 'New contact must be valid', data: {} }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
|
@ -111,8 +103,7 @@ class APIDomainContactsTest < ApplicationIntegrationTest
|
|||
new_contact_id: 'william-001' },
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response :bad_request
|
||||
assert_equal ({ error: { type: 'invalid_request_error',
|
||||
message: 'New contact ID must be different from current contact ID' } }),
|
||||
assert_equal ({ code: 2304, message: 'New contact must be different from current', data: {} }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
|
|
|
@ -12,34 +12,21 @@ class APIDomainTransfersTest < ApplicationIntegrationTest
|
|||
Setting.transfer_wait_time = @original_transfer_wait_time
|
||||
end
|
||||
|
||||
def test_returns_domain_transfers
|
||||
post '/repp/v1/domain_transfers', params: request_params, as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response 200
|
||||
assert_equal ({ data: [{
|
||||
type: 'domain_transfer',
|
||||
attributes: {
|
||||
domain_name: 'shop.test'
|
||||
},
|
||||
}] }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_creates_new_domain_transfer
|
||||
assert_difference -> { @domain.transfers.size } do
|
||||
post '/repp/v1/domain_transfers', params: request_params, as: :json,
|
||||
post '/repp/v1/domains/transfer', params: request_params, as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
end
|
||||
end
|
||||
|
||||
def test_approves_automatically_if_auto_approval_is_enabled
|
||||
post '/repp/v1/domain_transfers', params: request_params, as: :json,
|
||||
post '/repp/v1/domains/transfer', params: request_params, as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert @domain.transfers.last.approved?
|
||||
end
|
||||
|
||||
def test_assigns_new_registrar
|
||||
post '/repp/v1/domain_transfers', params: request_params, as: :json,
|
||||
post '/repp/v1/domains/transfer', params: request_params, as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
@domain.reload
|
||||
assert_equal @new_registrar, @domain.registrar
|
||||
|
@ -48,7 +35,7 @@ class APIDomainTransfersTest < ApplicationIntegrationTest
|
|||
def test_regenerates_transfer_code
|
||||
@old_transfer_code = @domain.transfer_code
|
||||
|
||||
post '/repp/v1/domain_transfers', params: request_params, as: :json,
|
||||
post '/repp/v1/domains/transfer', params: request_params, as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
@domain.reload
|
||||
refute_equal @domain.transfer_code, @old_transfer_code
|
||||
|
@ -58,51 +45,28 @@ class APIDomainTransfersTest < ApplicationIntegrationTest
|
|||
@old_registrar = @domain.registrar
|
||||
|
||||
assert_difference -> { @old_registrar.notifications.count } do
|
||||
post '/repp/v1/domain_transfers', params: request_params, as: :json,
|
||||
post '/repp/v1/domains/transfer', params: request_params, as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
end
|
||||
end
|
||||
|
||||
def test_duplicates_registrant_admin_and_tech_contacts
|
||||
assert_difference -> { @new_registrar.contacts.size }, 3 do
|
||||
post '/repp/v1/domain_transfers', params: request_params, as: :json,
|
||||
post '/repp/v1/domains/transfer', params: request_params, as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
end
|
||||
end
|
||||
|
||||
def test_reuses_identical_contact
|
||||
post '/repp/v1/domain_transfers', params: request_params, as: :json,
|
||||
post '/repp/v1/domains/transfer', params: request_params, as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_equal 1, @new_registrar.contacts.where(name: 'William').size
|
||||
end
|
||||
|
||||
def test_fails_if_domain_does_not_exist
|
||||
post '/repp/v1/domain_transfers',
|
||||
params: { data: { domainTransfers: [{ domainName: 'non-existent.test',
|
||||
transferCode: 'any' }] } },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response 400
|
||||
assert_equal ({ errors: [{ title: 'non-existent.test does not exist' }] }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
def test_fails_if_transfer_code_is_wrong
|
||||
post '/repp/v1/domain_transfers',
|
||||
params: { data: { domainTransfers: [{ domainName: 'shop.test',
|
||||
transferCode: 'wrong' }] } },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response 400
|
||||
refute_equal @new_registrar, @domain.registrar
|
||||
assert_equal ({ errors: [{ title: 'shop.test transfer code is wrong' }] }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def request_params
|
||||
{ data: { domainTransfers: [{ domainName: 'shop.test', transferCode: '65078d5' }] } }
|
||||
{ data: { domain_transfers: [{ domain_name: 'shop.test', transfer_code: '65078d5' }] } }
|
||||
end
|
||||
|
||||
def http_auth_key
|
||||
|
|
|
@ -60,12 +60,14 @@ class APINameserversPutTest < ApplicationIntegrationTest
|
|||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response 200
|
||||
assert_equal ({ data: { type: 'nameserver',
|
||||
assert_equal ({ code: 1000,
|
||||
message: 'Command completed successfully',
|
||||
data: { type: 'nameserver',
|
||||
id: 'ns55.bestnames.test',
|
||||
attributes: { hostname: 'ns55.bestnames.test',
|
||||
ipv4: ['192.0.2.55'],
|
||||
ipv6: ['2001:db8::55'] } },
|
||||
affected_domains: ["airport.test", "shop.test"] }),
|
||||
ipv6: ['2001:db8::55'] },
|
||||
affected_domains: ["airport.test", "shop.test"] }}),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
|
@ -85,7 +87,7 @@ class APINameserversPutTest < ApplicationIntegrationTest
|
|||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response 404
|
||||
assert_equal ({ errors: [{ title: 'Hostname non-existent.test does not exist' }] }),
|
||||
assert_equal ({code: 2303, message: 'Object does not exist' }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
|
@ -96,7 +98,8 @@ class APINameserversPutTest < ApplicationIntegrationTest
|
|||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response 400
|
||||
assert_equal ({ errors: [{ title: 'Hostname is missing' }] }),
|
||||
assert_equal ({ code: 2003,
|
||||
message: 'param is missing or the value is empty: hostname' }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
||||
|
|
|
@ -50,10 +50,10 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
|
|||
assert_equal(200, response.status)
|
||||
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
array_of_domain_names = response_json.map { |x| x[:name] }
|
||||
array_of_domain_names = response_json[:domains].map { |x| x[:name] }
|
||||
assert(array_of_domain_names.include?('hospital.test'))
|
||||
|
||||
array_of_domain_registrars = response_json.map { |x| x[:registrar] }
|
||||
array_of_domain_registrars = response_json[:domains].map { |x| x[:registrar] }
|
||||
assert(array_of_domain_registrars.include?({name: 'Good Names', website: nil}))
|
||||
end
|
||||
|
||||
|
@ -63,12 +63,12 @@ class RegistrantApiDomainsTest < ApplicationIntegrationTest
|
|||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_equal(200, response.status)
|
||||
assert_equal(2, response_json.count)
|
||||
assert_equal(2, response_json[:domains].count)
|
||||
|
||||
get '/api/v1/registrant/domains', headers: @auth_headers
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_equal(4, response_json.count)
|
||||
assert_equal(4, response_json[:domains].count)
|
||||
end
|
||||
|
||||
def test_root_does_not_accept_limit_higher_than_200
|
||||
|
|
|
@ -0,0 +1,297 @@
|
|||
require 'test_helper'
|
||||
require 'auth_token/auth_token_creator'
|
||||
|
||||
class RegistrantApiVerificationsTest < ApplicationIntegrationTest
|
||||
def setup
|
||||
super
|
||||
|
||||
@domain = domains(:hospital)
|
||||
@registrant = @domain.registrant
|
||||
@new_registrant = contacts(:jack)
|
||||
@user = users(:api_bestnames)
|
||||
|
||||
@token = 'verysecrettoken'
|
||||
|
||||
@domain.update!(statuses: [DomainStatus::PENDING_UPDATE],
|
||||
registrant_verification_asked_at: Time.zone.now - 1.day,
|
||||
registrant_verification_token: @token)
|
||||
|
||||
end
|
||||
|
||||
def test_fetches_registrant_change_request
|
||||
pending_json = { new_registrant_id: @new_registrant.id,
|
||||
new_registrant_name: @new_registrant.name,
|
||||
new_registrant_email: @new_registrant.email,
|
||||
current_user_id: @user.id }
|
||||
|
||||
@domain.update(pending_json: pending_json)
|
||||
@domain.reload
|
||||
|
||||
assert @domain.registrant_update_confirmable?(@token)
|
||||
|
||||
get "/api/v1/registrant/confirms/#{@domain.name_puny}/change/#{@token}"
|
||||
assert_equal(200, response.status)
|
||||
|
||||
res = JSON.parse(response.body, symbolize_names: true)
|
||||
expected_body = {
|
||||
domain_name: "hospital.test",
|
||||
current_registrant: {
|
||||
name: @registrant.name,
|
||||
ident: @registrant.ident,
|
||||
country: @registrant.ident_country_code
|
||||
},
|
||||
new_registrant: {
|
||||
name: @new_registrant.name,
|
||||
ident: @new_registrant.ident,
|
||||
country: @new_registrant.ident_country_code
|
||||
}
|
||||
}
|
||||
|
||||
assert_equal expected_body, res
|
||||
end
|
||||
|
||||
def test_approves_registrant_change_request
|
||||
pending_json = { new_registrant_id: @new_registrant.id,
|
||||
new_registrant_name: @new_registrant.name,
|
||||
new_registrant_email: @new_registrant.email,
|
||||
current_user_id: @user.id }
|
||||
|
||||
@domain.update!(pending_json: pending_json)
|
||||
@domain.reload
|
||||
|
||||
assert @domain.registrant_update_confirmable?(@token)
|
||||
|
||||
perform_enqueued_jobs do
|
||||
post "/api/v1/registrant/confirms/#{@domain.name_puny}/change/#{@token}/confirmed"
|
||||
assert_equal(200, response.status)
|
||||
|
||||
res = JSON.parse(response.body, symbolize_names: true)
|
||||
expected_body = {
|
||||
domain_name: @domain.name,
|
||||
current_registrant: {
|
||||
name: @new_registrant.name,
|
||||
ident: @new_registrant.ident,
|
||||
country: @new_registrant.ident_country_code
|
||||
},
|
||||
status: 'confirmed'
|
||||
}
|
||||
assert_equal expected_body, res
|
||||
end
|
||||
end
|
||||
|
||||
def test_rejects_registrant_change_request
|
||||
pending_json = { new_registrant_id: @new_registrant.id,
|
||||
new_registrant_name: @new_registrant.name,
|
||||
new_registrant_email: @new_registrant.email,
|
||||
current_user_id: @user.id }
|
||||
|
||||
@domain.update(pending_json: pending_json)
|
||||
@domain.reload
|
||||
|
||||
assert @domain.registrant_update_confirmable?(@token)
|
||||
|
||||
post "/api/v1/registrant/confirms/#{@domain.name_puny}/change/#{@token}/rejected"
|
||||
assert_equal(200, response.status)
|
||||
|
||||
res = JSON.parse(response.body, symbolize_names: true)
|
||||
expected_body = {
|
||||
domain_name: @domain.name,
|
||||
current_registrant: {
|
||||
name: @registrant.name,
|
||||
ident: @registrant.ident,
|
||||
country: @registrant.ident_country_code
|
||||
},
|
||||
status: 'rejected'
|
||||
}
|
||||
|
||||
assert_equal expected_body, res
|
||||
end
|
||||
|
||||
def test_registrant_change_requires_valid_attributes
|
||||
pending_json = { new_registrant_id: @new_registrant.id,
|
||||
new_registrant_name: @new_registrant.name,
|
||||
new_registrant_email: @new_registrant.email,
|
||||
current_user_id: @user.id }
|
||||
|
||||
@domain.update(pending_json: pending_json)
|
||||
@domain.reload
|
||||
|
||||
get "/api/v1/registrant/confirms/#{@domain.name_puny}/change/123"
|
||||
assert_equal 401, response.status
|
||||
|
||||
get "/api/v1/registrant/confirms/aohldfjg.ee/change/123"
|
||||
assert_equal 404, response.status
|
||||
|
||||
post "/api/v1/registrant/confirms/#{@domain.name_puny}/change/#{@token}/invalidaction"
|
||||
assert_equal 404, response.status
|
||||
end
|
||||
|
||||
def test_fetches_domain_delete_request
|
||||
pending_json = { new_registrant_id: @new_registrant.id,
|
||||
new_registrant_name: @new_registrant.name,
|
||||
new_registrant_email: @new_registrant.email,
|
||||
current_user_id: @user.id }
|
||||
|
||||
@domain.update(pending_json: pending_json, statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION])
|
||||
@domain.reload
|
||||
|
||||
assert @domain.registrant_delete_confirmable?(@token)
|
||||
|
||||
get "/api/v1/registrant/confirms/#{@domain.name_puny}/delete/#{@token}"
|
||||
assert_equal(200, response.status)
|
||||
|
||||
res = JSON.parse(response.body, symbolize_names: true)
|
||||
expected_body = {
|
||||
domain_name: "hospital.test",
|
||||
current_registrant: {
|
||||
name: @registrant.name,
|
||||
ident: @registrant.ident,
|
||||
country: @registrant.ident_country_code
|
||||
}
|
||||
}
|
||||
|
||||
assert_equal expected_body, res
|
||||
end
|
||||
|
||||
def test_approves_domain_delete_request
|
||||
pending_json = { new_registrant_id: @new_registrant.id,
|
||||
new_registrant_name: @new_registrant.name,
|
||||
new_registrant_email: @new_registrant.email,
|
||||
current_user_id: @user.id }
|
||||
|
||||
@domain.update(pending_json: pending_json, statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION])
|
||||
@domain.reload
|
||||
|
||||
assert @domain.registrant_delete_confirmable?(@token)
|
||||
|
||||
post "/api/v1/registrant/confirms/#{@domain.name_puny}/delete/#{@token}/confirmed"
|
||||
assert_equal(200, response.status)
|
||||
|
||||
res = JSON.parse(response.body, symbolize_names: true)
|
||||
expected_body = {
|
||||
domain_name: @domain.name,
|
||||
current_registrant: {
|
||||
name: @registrant.name,
|
||||
ident: @registrant.ident,
|
||||
country: @registrant.ident_country_code
|
||||
},
|
||||
status: 'confirmed'
|
||||
}
|
||||
|
||||
assert_equal expected_body, res
|
||||
end
|
||||
|
||||
def test_rejects_domain_delete_request
|
||||
pending_json = { new_registrant_id: @new_registrant.id,
|
||||
new_registrant_name: @new_registrant.name,
|
||||
new_registrant_email: @new_registrant.email,
|
||||
current_user_id: @user.id }
|
||||
|
||||
@domain.update(pending_json: pending_json, statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION])
|
||||
@domain.reload
|
||||
|
||||
assert @domain.registrant_delete_confirmable?(@token)
|
||||
|
||||
post "/api/v1/registrant/confirms/#{@domain.name_puny}/delete/#{@token}/rejected"
|
||||
assert_equal(200, response.status)
|
||||
|
||||
res = JSON.parse(response.body, symbolize_names: true)
|
||||
expected_body = {
|
||||
domain_name: @domain.name,
|
||||
current_registrant: {
|
||||
name: @registrant.name,
|
||||
ident: @registrant.ident,
|
||||
country: @registrant.ident_country_code
|
||||
},
|
||||
status: 'rejected'
|
||||
}
|
||||
|
||||
assert_equal expected_body, res
|
||||
end
|
||||
|
||||
def test_domain_delete_requires_valid_attributes
|
||||
pending_json = { new_registrant_id: @new_registrant.id,
|
||||
new_registrant_name: @new_registrant.name,
|
||||
new_registrant_email: @new_registrant.email,
|
||||
current_user_id: @user.id }
|
||||
|
||||
@domain.update(pending_json: pending_json, statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION])
|
||||
@domain.reload
|
||||
|
||||
get "/api/v1/registrant/confirms/#{@domain.name_puny}/delete/123"
|
||||
assert_equal 401, response.status
|
||||
|
||||
get "/api/v1/registrant/confirms/aohldfjg.ee/delete/123"
|
||||
assert_equal 404, response.status
|
||||
|
||||
post "/api/v1/registrant/confirms/#{@domain.name_puny}/delete/#{@token}/invalidaction"
|
||||
assert_equal 404, response.status
|
||||
end
|
||||
#def test_get_non_existent_domain_details_by_uuid
|
||||
# get '/api/v1/registrant/domains/random-uuid', headers: @auth_headers
|
||||
# assert_equal(404, response.status)
|
||||
|
||||
# response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
# assert_equal({ errors: [base: ['Domain not found']] }, response_json)
|
||||
#end
|
||||
|
||||
#def test_root_returns_domain_list
|
||||
# get '/api/v1/registrant/domains', headers: @auth_headers
|
||||
# assert_equal(200, response.status)
|
||||
|
||||
# response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
# array_of_domain_names = response_json.map { |x| x[:name] }
|
||||
# assert(array_of_domain_names.include?('hospital.test'))
|
||||
|
||||
# array_of_domain_registrars = response_json.map { |x| x[:registrar] }
|
||||
# assert(array_of_domain_registrars.include?({name: 'Good Names', website: nil}))
|
||||
#end
|
||||
|
||||
#def test_root_accepts_limit_and_offset_parameters
|
||||
# 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', 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', 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/domains', 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/domains'
|
||||
# assert_equal(401, response.status)
|
||||
# json_body = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
# assert_equal({ errors: [base: ['Not authorized']] }, json_body)
|
||||
#end
|
||||
|
||||
#def test_details_returns_401_without_authorization
|
||||
# get '/api/v1/registrant/domains/5edda1a5-3548-41ee-8b65-6d60daf85a37'
|
||||
# assert_equal(401, response.status)
|
||||
# json_body = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
# assert_equal({ errors: [base: ['Not authorized']] }, json_body)
|
||||
#end
|
||||
end
|
75
test/integration/api/v1/bounces/create_test.rb
Normal file
75
test/integration/api/v1/bounces/create_test.rb
Normal file
|
@ -0,0 +1,75 @@
|
|||
require 'test_helper'
|
||||
|
||||
class BouncesApiV1CreateTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@api_key = "Basic #{ENV['api_shared_key']}"
|
||||
@headers = { "Authorization": "#{@api_key}" }
|
||||
@json_body = { "data": valid_bounce_request }.as_json
|
||||
end
|
||||
|
||||
def test_authorizes_api_request
|
||||
post api_v1_bounces_path, params: @json_body, headers: @headers
|
||||
assert_response :created
|
||||
|
||||
invalid_headers = { "Authorization": "Basic invalid_api_key" }
|
||||
post api_v1_bounces_path, params: @json_body, headers: invalid_headers
|
||||
assert_response :unauthorized
|
||||
end
|
||||
|
||||
def test_returns_bad_request_if_invalid_payload
|
||||
invalid_json_body = @json_body.dup
|
||||
invalid_json_body['data']['bounce']['bouncedRecipients'] = nil
|
||||
|
||||
post api_v1_bounces_path, params: invalid_json_body, headers: @headers
|
||||
assert_response :bad_request
|
||||
|
||||
invalid_json_body = 'aaaa'
|
||||
post api_v1_bounces_path, params: invalid_json_body, headers: @headers
|
||||
assert_response :bad_request
|
||||
end
|
||||
|
||||
def test_saves_new_bounce_object
|
||||
request_body = @json_body.dup
|
||||
random_mail = "#{rand(10000..99999)}@registry.test"
|
||||
request_body['data']['bounce']['bouncedRecipients'][0]['emailAddress'] = random_mail
|
||||
|
||||
post api_v1_bounces_path, params: request_body, headers: @headers
|
||||
assert_response :created
|
||||
|
||||
bounced_mail = BouncedMailAddress.last
|
||||
assert bounced_mail.email = random_mail
|
||||
assert '5.1.1', bounced_mail.status
|
||||
assert 'failed', bounced_mail.action
|
||||
end
|
||||
|
||||
def valid_bounce_request
|
||||
{
|
||||
"notificationType": "Bounce",
|
||||
"mail": {
|
||||
"source": "noreply@registry.test",
|
||||
"sourceIp": "195.43.86.5",
|
||||
"messageId": "010f0174a0c7d348-ea6e2fc1-0854-4073-b71f-5cecf9b0d0b2-000000",
|
||||
"sourceArn": "arn:aws:ses:us-east-2:65026820000:identity/noreply@registry.test",
|
||||
"timestamp": "2020-09-18T10:34:44.000Z",
|
||||
"destination": [ "bounced@registry.test" ],
|
||||
"sendingAccountId": "650268220000"
|
||||
},
|
||||
"bounce": {
|
||||
"timestamp": "2020-09-18T10:34:44.911Z",
|
||||
"bounceType": "Permanent",
|
||||
"feedbackId": "010f0174a0c7d4f9-27d59756-6111-4d5f-xxxx-26bee0d55fa2-000000",
|
||||
"remoteMtaIp": "127.0.01",
|
||||
"reportingMTA": "dsn; xxx.amazonses.com",
|
||||
"bounceSubType": "General",
|
||||
"bouncedRecipients": [
|
||||
{
|
||||
"action": "failed",
|
||||
"status": "5.1.1",
|
||||
"emailAddress": "bounced@registry.test",
|
||||
"diagnosticCode": "smtp; 550 5.1.1 user unknown"
|
||||
}
|
||||
]
|
||||
}
|
||||
}.as_json
|
||||
end
|
||||
end
|
|
@ -44,7 +44,7 @@ class EppContactInfoBaseTest < EppTestCase
|
|||
contact: xml_schema).text
|
||||
end
|
||||
|
||||
def test_hides_password_when_current_registrar_is_not_sponsoring
|
||||
def test_hides_password_and_name_when_current_registrar_is_not_sponsoring
|
||||
non_sponsoring_registrar = registrars(:goodnames)
|
||||
@contact.update!(registrar: non_sponsoring_registrar)
|
||||
|
||||
|
@ -70,6 +70,7 @@ class EppContactInfoBaseTest < EppTestCase
|
|||
assert_epp_response :completed_successfully
|
||||
response_xml = Nokogiri::XML(response.body)
|
||||
assert_nil response_xml.at_xpath('//contact:authInfo', contact: xml_schema)
|
||||
assert_equal 'No access', response_xml.at_xpath('//contact:name', contact: xml_schema).text
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -35,7 +35,6 @@ class EppDomainDeleteBaseTest < EppTestCase
|
|||
XML
|
||||
|
||||
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
# binding.pry
|
||||
assert_includes Domain.find_by(name: 'invalid.test').statuses, DomainStatus::PENDING_DELETE_CONFIRMATION
|
||||
assert_epp_response :completed_successfully_action_pending
|
||||
end
|
||||
|
@ -90,7 +89,9 @@ class EppDomainDeleteBaseTest < EppTestCase
|
|||
</epp>
|
||||
XML
|
||||
|
||||
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
perform_enqueued_jobs do
|
||||
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
@domain.reload
|
||||
|
||||
assert @domain.registrant_verification_asked?
|
||||
|
@ -121,7 +122,9 @@ class EppDomainDeleteBaseTest < EppTestCase
|
|||
</epp>
|
||||
XML
|
||||
|
||||
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
perform_enqueued_jobs do
|
||||
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
@domain.reload
|
||||
|
||||
assert_not @domain.registrant_verification_asked?
|
||||
|
@ -152,7 +155,9 @@ class EppDomainDeleteBaseTest < EppTestCase
|
|||
</epp>
|
||||
XML
|
||||
|
||||
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
perform_enqueued_jobs do
|
||||
post epp_delete_path, params: { frame: request_xml }, headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
end
|
||||
@domain.reload
|
||||
|
||||
assert_not @domain.registrant_verification_asked?
|
||||
|
|
|
@ -503,6 +503,30 @@ class EppDomainUpdateBaseTest < EppTestCase
|
|||
assert_not_includes(@domain.statuses, DomainStatus::CLIENT_HOLD)
|
||||
end
|
||||
|
||||
def test_update_domain_returns_error_when_removing_unassigned_status
|
||||
assert_not_includes(@domain.statuses, DomainStatus::CLIENT_HOLD)
|
||||
request_xml = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<epp xmlns="https://epp.tld.ee/schema/epp-ee-1.0.xsd">
|
||||
<command>
|
||||
<update>
|
||||
<domain:update xmlns:domain="https://epp.tld.ee/schema/domain-eis-1.0.xsd">
|
||||
<domain:name>#{@domain.name}</domain:name>
|
||||
<domain:rem>
|
||||
<domain:status s="clientHold"/>
|
||||
</domain:rem>
|
||||
</domain:update>
|
||||
</update>
|
||||
</command>
|
||||
</epp>
|
||||
XML
|
||||
|
||||
post epp_update_path, params: { frame: request_xml },
|
||||
headers: { 'HTTP_COOKIE' => 'session=api_bestnames' }
|
||||
@domain.reload
|
||||
assert_epp_response :object_does_not_exist
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assert_verification_and_notification_emails
|
||||
|
|
22
test/integration/repp/v1/accounts/balance_test.rb
Normal file
22
test/integration/repp/v1/accounts/balance_test.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ReppV1BalanceTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@registrar = users(:api_bestnames)
|
||||
token = Base64.encode64("#{@registrar.username}:#{@registrar.plain_text_password}")
|
||||
token = "Basic #{token}"
|
||||
|
||||
@auth_headers = { 'Authorization' => token }
|
||||
end
|
||||
|
||||
def test_can_query_balance
|
||||
get '/repp/v1/accounts/balance', headers: @auth_headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 1000, json[:code]
|
||||
assert_equal 'Command completed successfully', json[:message]
|
||||
assert_equal @registrar.registrar.cash_account.balance.to_s, json[:data][:balance]
|
||||
assert_equal @registrar.registrar.cash_account.currency, json[:data][:currency]
|
||||
end
|
||||
end
|
63
test/integration/repp/v1/base_test.rb
Normal file
63
test/integration/repp/v1/base_test.rb
Normal file
|
@ -0,0 +1,63 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ReppV1BaseTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@registrar = users(:api_bestnames)
|
||||
token = Base64.encode64("#{@registrar.username}:#{@registrar.plain_text_password}")
|
||||
token = "Basic #{token}"
|
||||
|
||||
@auth_headers = { 'Authorization' => token }
|
||||
end
|
||||
|
||||
def test_unauthorized_user_has_no_access
|
||||
get repp_v1_contacts_path
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :unauthorized
|
||||
assert_equal 'Invalid authorization information', response_json[:message]
|
||||
|
||||
invalid_token = Base64.encode64("nonexistant:user")
|
||||
headers = { 'Authorization' => "Basic #{invalid_token}" }
|
||||
|
||||
get repp_v1_contacts_path, headers: headers
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :unauthorized
|
||||
assert_equal 'Invalid authorization information', response_json[:message]
|
||||
end
|
||||
|
||||
def test_authenticates_valid_user
|
||||
get repp_v1_contacts_path, headers: @auth_headers
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
end
|
||||
|
||||
def test_processes_invalid_base64_token_format_properly
|
||||
token = '??as8d9sf kjsdjh klsdfjjf'
|
||||
headers = { 'Authorization' => "Basic #{token}"}
|
||||
get repp_v1_contacts_path, headers: headers
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :unauthorized
|
||||
assert_equal 'Invalid authorization information', response_json[:message]
|
||||
end
|
||||
|
||||
def test_takes_ip_whitelist_into_account
|
||||
Setting.api_ip_whitelist_enabled = true
|
||||
Setting.registrar_ip_whitelist_enabled = true
|
||||
|
||||
whiteip = white_ips(:one)
|
||||
whiteip.update(ipv4: '1.1.1.1')
|
||||
|
||||
get repp_v1_contacts_path, headers: @auth_headers
|
||||
response_json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :unauthorized
|
||||
assert_equal 2202, response_json[:code]
|
||||
assert response_json[:message].include? 'Access denied from IP'
|
||||
|
||||
Setting.api_ip_whitelist_enabled = false
|
||||
Setting.registrar_ip_whitelist_enabled = false
|
||||
end
|
||||
end
|
30
test/integration/repp/v1/contacts/check_test.rb
Normal file
30
test/integration/repp/v1/contacts/check_test.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ReppV1ContactsCheckTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@user = users(:api_bestnames)
|
||||
token = Base64.encode64("#{@user.username}:#{@user.plain_text_password}")
|
||||
token = "Basic #{token}"
|
||||
|
||||
@auth_headers = { 'Authorization' => token }
|
||||
end
|
||||
|
||||
def test_code_based_check_returns_true_for_available_contact
|
||||
get '/repp/v1/contacts/check/nonexistant:code', headers: @auth_headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 'nonexistant:code', json[:data][:contact][:id]
|
||||
assert_equal true, json[:data][:contact][:available]
|
||||
end
|
||||
|
||||
def test_code_based_check_returns_true_for_available_contact
|
||||
contact = contacts(:jack)
|
||||
get "/repp/v1/contacts/check/#{contact.code}", headers: @auth_headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal contact.code, json[:data][:contact][:id]
|
||||
assert_equal false, json[:data][:contact][:available]
|
||||
end
|
||||
end
|
156
test/integration/repp/v1/contacts/create_test.rb
Normal file
156
test/integration/repp/v1/contacts/create_test.rb
Normal file
|
@ -0,0 +1,156 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ReppV1ContactsCreateTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@user = users(:api_bestnames)
|
||||
token = Base64.encode64("#{@user.username}:#{@user.plain_text_password}")
|
||||
token = "Basic #{token}"
|
||||
|
||||
@auth_headers = { 'Authorization' => token }
|
||||
end
|
||||
|
||||
def test_creates_new_contact
|
||||
request_body = {
|
||||
"contact": {
|
||||
"name": "Donald Trump",
|
||||
"phone": "+372.51111112",
|
||||
"email": "donald@trumptower.com",
|
||||
"ident": {
|
||||
"ident_type": "priv",
|
||||
"ident_country_code": "EE",
|
||||
"ident": "39708290069"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post '/repp/v1/contacts', 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]
|
||||
|
||||
contact = Contact.find_by(code: json[:data][:contact][:id])
|
||||
assert contact.present?
|
||||
|
||||
assert_equal(request_body[:contact][:name], contact.name)
|
||||
assert_equal(request_body[:contact][:phone], contact.phone)
|
||||
assert_equal(request_body[:contact][:email], contact.email)
|
||||
assert_equal(request_body[:contact][:ident][:ident_type], contact.ident_type)
|
||||
assert_equal(request_body[:contact][:ident][:ident_country_code], contact.ident_country_code)
|
||||
assert_equal(request_body[:contact][:ident][:ident], contact.ident)
|
||||
end
|
||||
|
||||
def test_removes_postal_info_when_contact_created
|
||||
request_body = {
|
||||
"contact": {
|
||||
"name": "Donald Trump",
|
||||
"phone": "+372.51111111",
|
||||
"email": "donald@trump.com",
|
||||
"ident": {
|
||||
"ident_type": "priv",
|
||||
"ident_country_code": "EE",
|
||||
"ident": "39708290069"
|
||||
},
|
||||
"addr": {
|
||||
"city": "Tallinn",
|
||||
"street": "Wismari 13",
|
||||
"zip": "12345",
|
||||
"country_code": "EE"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post '/repp/v1/contacts', headers: @auth_headers, params: request_body
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 1100, json[:code]
|
||||
assert_equal 'Command completed successfully; Postal address data discarded', json[:message]
|
||||
|
||||
contact = Contact.find_by(code: json[:data][:contact][:id])
|
||||
assert contact.present?
|
||||
|
||||
assert_nil contact.city
|
||||
assert_nil contact.street
|
||||
assert_nil contact.zip
|
||||
assert_nil contact.country_code
|
||||
end
|
||||
|
||||
def test_requires_contact_address_when_processing_enabled
|
||||
Setting.address_processing = true
|
||||
|
||||
request_body = {
|
||||
"contact": {
|
||||
"name": "Donald Trump",
|
||||
"phone": "+372.51111112",
|
||||
"email": "donald@trumptower.com",
|
||||
"ident": {
|
||||
"ident_type": "priv",
|
||||
"ident_country_code": "EE",
|
||||
"ident": "39708290069"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post '/repp/v1/contacts', headers: @auth_headers, params: request_body
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :bad_request
|
||||
assert_equal 2003, json[:code]
|
||||
assert json[:message].include? 'param is missing or the value is empty'
|
||||
|
||||
Setting.address_processing = false
|
||||
end
|
||||
|
||||
def test_validates_ident_code
|
||||
request_body = {
|
||||
"contact": {
|
||||
"name": "Donald Trump",
|
||||
"phone": "+372.51111112",
|
||||
"email": "donald@trumptower.com",
|
||||
"ident": {
|
||||
"ident_type": "priv",
|
||||
"ident_country_code": "EE",
|
||||
"ident": "123123123"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post '/repp/v1/contacts', headers: @auth_headers, params: request_body
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :bad_request
|
||||
assert_equal 2005, json[:code]
|
||||
assert json[:message].include? 'Ident code does not conform to national identification number format'
|
||||
end
|
||||
|
||||
def test_attaches_legaldoc_if_present
|
||||
request_body = {
|
||||
"contact": {
|
||||
"name": "Donald Trump",
|
||||
"phone": "+372.51111112",
|
||||
"email": "donald@trumptower.com",
|
||||
"ident": {
|
||||
"ident_type": "priv",
|
||||
"ident_country_code": "EE",
|
||||
"ident": "39708290069"
|
||||
},
|
||||
},
|
||||
"legal_document": {
|
||||
"type": "pdf",
|
||||
"body": "#{'test' * 2000}"
|
||||
}
|
||||
}
|
||||
|
||||
post '/repp/v1/contacts', 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]
|
||||
|
||||
contact = Contact.find_by(code: json[:data][:contact][:id])
|
||||
assert contact.legal_documents.any?
|
||||
end
|
||||
end
|
47
test/integration/repp/v1/contacts/delete_test.rb
Normal file
47
test/integration/repp/v1/contacts/delete_test.rb
Normal file
|
@ -0,0 +1,47 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ReppV1ContactsDeleteTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@user = users(:api_bestnames)
|
||||
token = Base64.encode64("#{@user.username}:#{@user.plain_text_password}")
|
||||
token = "Basic #{token}"
|
||||
|
||||
@auth_headers = { 'Authorization' => token }
|
||||
end
|
||||
|
||||
def test_deletes_unassociated_contact
|
||||
contact = contacts(:invalid_email)
|
||||
delete "/repp/v1/contacts/#{contact.code}", headers: @auth_headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 1000, json[:code]
|
||||
assert_equal 'Command completed successfully', json[:message]
|
||||
end
|
||||
|
||||
def test_can_not_delete_associated_contact
|
||||
contact = contacts(:john)
|
||||
delete "/repp/v1/contacts/#{contact.code}", headers: @auth_headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :bad_request
|
||||
assert_equal 2305, json[:code]
|
||||
assert_equal 'Object association prohibits operation [domains]', json[:message]
|
||||
end
|
||||
|
||||
def test_handles_unknown_contact
|
||||
delete "/repp/v1/contacts/definitely:unexistant", headers: @auth_headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :not_found
|
||||
end
|
||||
|
||||
def test_can_not_destroy_other_registrar_contact
|
||||
contact = contacts(:jack)
|
||||
|
||||
delete "/repp/v1/contacts/#{contact.code}", headers: @auth_headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :not_found
|
||||
end
|
||||
end
|
55
test/integration/repp/v1/contacts/list_test.rb
Normal file
55
test/integration/repp/v1/contacts/list_test.rb
Normal file
|
@ -0,0 +1,55 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ReppV1ContactsListTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@user = users(:api_bestnames)
|
||||
token = Base64.encode64("#{@user.username}:#{@user.plain_text_password}")
|
||||
token = "Basic #{token}"
|
||||
|
||||
@auth_headers = { 'Authorization' => token }
|
||||
end
|
||||
|
||||
def test_returns_registrar_contacts
|
||||
get repp_v1_contacts_path, headers: @auth_headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
|
||||
assert_equal @user.registrar.contacts.count, json[:total_number_of_records]
|
||||
assert_equal @user.registrar.contacts.count, json[:contacts].length
|
||||
|
||||
assert json[:contacts][0].is_a? String
|
||||
end
|
||||
|
||||
|
||||
def test_returns_detailed_registrar_contacts
|
||||
get repp_v1_contacts_path(details: true), headers: @auth_headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
|
||||
assert_equal @user.registrar.contacts.count, json[:total_number_of_records]
|
||||
assert_equal @user.registrar.contacts.count, json[:contacts].length
|
||||
|
||||
assert json[:contacts][0].is_a? Hash
|
||||
end
|
||||
|
||||
def test_respects_limit
|
||||
get repp_v1_contacts_path(details: true, limit: 2), headers: @auth_headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
|
||||
assert_equal 2, json[:contacts].length
|
||||
end
|
||||
|
||||
def test_respects_offset
|
||||
offset = 1
|
||||
get repp_v1_contacts_path(details: true, offset: offset), headers: @auth_headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
|
||||
assert_equal (@user.registrar.contacts.count - offset), json[:contacts].length
|
||||
end
|
||||
end
|
45
test/integration/repp/v1/contacts/show_test.rb
Normal file
45
test/integration/repp/v1/contacts/show_test.rb
Normal file
|
@ -0,0 +1,45 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ReppV1ContactsShowTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@user = users(:api_bestnames)
|
||||
token = Base64.encode64("#{@user.username}:#{@user.plain_text_password}")
|
||||
token = "Basic #{token}"
|
||||
|
||||
@auth_headers = { 'Authorization' => token }
|
||||
end
|
||||
|
||||
def test_returns_error_when_not_found
|
||||
get repp_v1_contact_path(id: 'definitelynotexistant'), headers: @auth_headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :not_found
|
||||
assert_equal 2303, json[:code]
|
||||
assert_equal 'Object does not exist', json[:message]
|
||||
end
|
||||
|
||||
def test_shows_existing_contact
|
||||
contact = @user.registrar.contacts.first
|
||||
|
||||
get repp_v1_contact_path(id: contact.code), headers: @auth_headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 1000, json[:code]
|
||||
assert_equal 'Command completed successfully', json[:message]
|
||||
|
||||
assert_equal contact.code, json[:data][:id]
|
||||
end
|
||||
|
||||
def test_can_not_access_out_of_scope_contacts
|
||||
# Contact of registrar goodnames, we're using bestnames API credentials
|
||||
contact = contacts(:jack)
|
||||
|
||||
get repp_v1_contact_path(id: contact.code), headers: @auth_headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :not_found
|
||||
assert_equal 2303, json[:code]
|
||||
assert_equal 'Object does not exist', json[:message]
|
||||
end
|
||||
end
|
119
test/integration/repp/v1/contacts/update_test.rb
Normal file
119
test/integration/repp/v1/contacts/update_test.rb
Normal file
|
@ -0,0 +1,119 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ReppV1ContactsUpdateTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@contact = contacts(:john)
|
||||
@user = users(:api_bestnames)
|
||||
token = Base64.encode64("#{@user.username}:#{@user.plain_text_password}")
|
||||
token = "Basic #{token}"
|
||||
|
||||
@auth_headers = { 'Authorization' => token }
|
||||
end
|
||||
|
||||
def test_updates_contact
|
||||
request_body = {
|
||||
"contact": {
|
||||
"email": "donaldtrump@yandex.ru"
|
||||
}
|
||||
}
|
||||
|
||||
put "/repp/v1/contacts/#{@contact.code}", 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]
|
||||
|
||||
contact = Contact.find_by(code: json[:data][:contact][:id])
|
||||
assert contact.present?
|
||||
|
||||
assert_equal(request_body[:contact][:email], contact.email)
|
||||
end
|
||||
|
||||
def test_removes_postal_info_when_updated
|
||||
request_body = {
|
||||
"contact": {
|
||||
"addr": {
|
||||
"city": "Tallinn",
|
||||
"street": "Wismari 13",
|
||||
"zip": "12345",
|
||||
"country_code": "EE"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
put "/repp/v1/contacts/#{@contact.code}", headers: @auth_headers, params: request_body
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 1100, json[:code]
|
||||
assert_equal 'Command completed successfully; Postal address data discarded', json[:message]
|
||||
|
||||
contact = Contact.find_by(code: json[:data][:contact][:id])
|
||||
assert contact.present?
|
||||
|
||||
assert_nil contact.city
|
||||
assert_nil contact.street
|
||||
assert_nil contact.zip
|
||||
assert_nil contact.country_code
|
||||
end
|
||||
|
||||
def test_can_not_change_ident_code
|
||||
request_body = {
|
||||
"contact": {
|
||||
"name": "Donald Trumpster",
|
||||
"ident": {
|
||||
"ident_type": "priv",
|
||||
"ident_country_code": "US",
|
||||
"ident": "12345"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
put "/repp/v1/contacts/#{@contact.code}", headers: @auth_headers, params: request_body
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
@contact.reload
|
||||
assert_not @contact.ident == 12345
|
||||
assert_response :bad_request
|
||||
assert_equal 2308, json[:code]
|
||||
assert json[:message].include? 'Ident update is not allowed. Consider creating new contact object'
|
||||
end
|
||||
|
||||
def test_attaches_legaldoc_if_present
|
||||
request_body = {
|
||||
"contact": {
|
||||
"email": "donaldtrump@yandex.ru"
|
||||
},
|
||||
"legal_document": {
|
||||
"type": "pdf",
|
||||
"body": "#{'test' * 2000}"
|
||||
}
|
||||
}
|
||||
|
||||
put "/repp/v1/contacts/#{@contact.code}", 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]
|
||||
|
||||
@contact.reload
|
||||
assert @contact.legal_documents.any?
|
||||
end
|
||||
|
||||
def test_returns_error_if_ident_wrong_format
|
||||
request_body = {
|
||||
"contact": {
|
||||
"ident": "123"
|
||||
}
|
||||
}
|
||||
|
||||
put "/repp/v1/contacts/#{@contact.code}", headers: @auth_headers, params: request_body
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :bad_request
|
||||
assert_equal 2308, json[:code]
|
||||
assert_equal 'Ident update is not allowed. Consider creating new contact object', json[:message]
|
||||
end
|
||||
end
|
91
test/integration/repp/v1/domains/bulk_renew_test.rb
Normal file
91
test/integration/repp/v1/domains/bulk_renew_test.rb
Normal file
|
@ -0,0 +1,91 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ReppV1DomainsBulkRenewTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
travel_to Time.zone.parse('2010-07-05 10:30')
|
||||
@user = users(:api_bestnames)
|
||||
token = Base64.encode64("#{@user.username}:#{@user.plain_text_password}")
|
||||
token = "Basic #{token}"
|
||||
|
||||
@auth_headers = { 'Authorization' => token }
|
||||
end
|
||||
|
||||
def test_renews_domains
|
||||
payload = {
|
||||
"domains": [
|
||||
'shop.test',
|
||||
'airport.test',
|
||||
'library.test'
|
||||
],
|
||||
"renew_period": "1y"
|
||||
}
|
||||
|
||||
assert_changes -> { Domain.find_by(name: 'shop.test').valid_to } do
|
||||
assert_changes -> { Domain.find_by(name: 'airport.test').valid_to } do
|
||||
assert_changes -> { Domain.find_by(name: 'library.test').valid_to } do
|
||||
post "/repp/v1/domains/renew/bulk", headers: @auth_headers, params: payload
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 1000, json[:code]
|
||||
assert_equal 'Command completed successfully', json[:message]
|
||||
assert json[:data][:updated_domains].include? 'shop.test'
|
||||
assert json[:data][:updated_domains].include? 'airport.test'
|
||||
assert json[:data][:updated_domains].include? 'library.test'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_throws_error_when_domain_not_renewable
|
||||
payload = {
|
||||
"domains": [
|
||||
'invalid.test',
|
||||
],
|
||||
"renew_period": "1y"
|
||||
}
|
||||
assert_no_changes -> { Domain.find_by(name: 'invalid.test').valid_to } do
|
||||
post "/repp/v1/domains/renew/bulk", headers: @auth_headers, params: payload
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :bad_request
|
||||
assert_equal 2002, json[:code]
|
||||
assert_equal 'Domain renew error for invalid.test', json[:message]
|
||||
end
|
||||
end
|
||||
|
||||
def test_throws_error_when_not_enough_balance
|
||||
billing_prices(:renew_one_year).update(price_cents: 99999999)
|
||||
payload = {
|
||||
"domains": [
|
||||
'invalid.test',
|
||||
],
|
||||
"renew_period": "1y"
|
||||
}
|
||||
|
||||
assert_no_changes -> { Domain.find_by(name: 'invalid.test').valid_to } do
|
||||
post "/repp/v1/domains/renew/bulk", headers: @auth_headers, params: payload
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :bad_request
|
||||
assert_equal 2002, json[:code]
|
||||
assert_equal 'Not enough funds for renew domains', json[:message]
|
||||
end
|
||||
end
|
||||
|
||||
def test_throws_error_if_invalid_renew_period
|
||||
payload = {
|
||||
"domains": [
|
||||
'shop.test'
|
||||
],
|
||||
"renew_period": "nope"
|
||||
}
|
||||
|
||||
post "/repp/v1/domains/renew/bulk", headers: @auth_headers, params: payload
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :bad_request
|
||||
assert_equal 2005, json[:code]
|
||||
assert_equal 'Invalid renew period', json[:message]
|
||||
end
|
||||
end
|
65
test/integration/repp/v1/domains/contact_replacement_test.rb
Normal file
65
test/integration/repp/v1/domains/contact_replacement_test.rb
Normal file
|
@ -0,0 +1,65 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ReppV1DomainsContactReplacementTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@user = users(:api_bestnames)
|
||||
token = Base64.encode64("#{@user.username}:#{@user.plain_text_password}")
|
||||
token = "Basic #{token}"
|
||||
|
||||
@auth_headers = { 'Authorization' => token }
|
||||
end
|
||||
|
||||
def test_replaces_tech_contact_with_new_one
|
||||
replaceable_contact = contacts(:william)
|
||||
replacing_contact = contacts(:jane)
|
||||
|
||||
payload = {
|
||||
"current_contact_id": replaceable_contact.code,
|
||||
"new_contact_id": replacing_contact.code
|
||||
}
|
||||
|
||||
patch '/repp/v1/domains/contacts', headers: @auth_headers, params: payload
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 1000, json[:code]
|
||||
assert_equal 'Command completed successfully', json[:message]
|
||||
|
||||
assert json[:data][:affected_domains].include? 'airport.test'
|
||||
assert json[:data][:affected_domains].include? 'shop.test'
|
||||
|
||||
assert_empty json[:data][:skipped_domains]
|
||||
end
|
||||
|
||||
def test_tech_contact_id_must_differ
|
||||
replaceable_contact = contacts(:william)
|
||||
replacing_contact = contacts(:william)
|
||||
|
||||
payload = {
|
||||
"current_contact_id": replaceable_contact.code,
|
||||
"new_contact_id": replacing_contact.code
|
||||
}
|
||||
|
||||
patch '/repp/v1/domains/contacts', headers: @auth_headers, params: payload
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :bad_request
|
||||
assert_equal 2304, json[:code]
|
||||
assert_equal 'New contact must be different from current', json[:message]
|
||||
end
|
||||
|
||||
def test_contact_codes_must_be_valid
|
||||
payload = {
|
||||
"current_contact_id": 'dfgsdfg',
|
||||
"new_contact_id": 'vvv'
|
||||
}
|
||||
|
||||
patch '/repp/v1/domains/contacts', headers: @auth_headers, params: payload
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :not_found
|
||||
assert_equal 2303, json[:code]
|
||||
assert_equal 'Object does not exist', json[:message]
|
||||
end
|
||||
|
||||
end
|
54
test/integration/repp/v1/domains/list_test.rb
Normal file
54
test/integration/repp/v1/domains/list_test.rb
Normal file
|
@ -0,0 +1,54 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ReppV1DomainsListTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@user = users(:api_bestnames)
|
||||
token = Base64.encode64("#{@user.username}:#{@user.plain_text_password}")
|
||||
token = "Basic #{token}"
|
||||
|
||||
@auth_headers = { 'Authorization' => token }
|
||||
end
|
||||
|
||||
def test_returns_registrar_domains
|
||||
get repp_v1_domains_path, headers: @auth_headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
|
||||
assert_equal @user.registrar.domains.count, json[:data][:total_number_of_records]
|
||||
assert_equal @user.registrar.domains.count, json[:data][:domains].length
|
||||
|
||||
assert json[:data][:domains][0].is_a? String
|
||||
end
|
||||
|
||||
def test_returns_detailed_registrar_domains
|
||||
get repp_v1_domains_path(details: true), headers: @auth_headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
|
||||
assert_equal @user.registrar.domains.count, json[:data][:total_number_of_records]
|
||||
assert_equal @user.registrar.domains.count, json[:data][:domains].length
|
||||
|
||||
assert json[:data][:domains][0].is_a? Hash
|
||||
end
|
||||
|
||||
def test_respects_limit
|
||||
get repp_v1_domains_path(details: true, limit: 2), headers: @auth_headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
|
||||
assert_equal 2, json[:data][:domains].length
|
||||
end
|
||||
|
||||
def test_respects_offset
|
||||
offset = 1
|
||||
get repp_v1_domains_path(details: true, offset: offset), headers: @auth_headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
|
||||
assert_equal (@user.registrar.domains.count - offset), json[:data][:domains].length
|
||||
end
|
||||
end
|
40
test/integration/repp/v1/domains/transfer_info_test.rb
Normal file
40
test/integration/repp/v1/domains/transfer_info_test.rb
Normal file
|
@ -0,0 +1,40 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ReppV1DomainsTransferInfoTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@user = users(:api_bestnames)
|
||||
token = Base64.encode64("#{@user.username}:#{@user.plain_text_password}")
|
||||
token = "Basic #{token}"
|
||||
@domain = domains(:shop)
|
||||
@auth_headers = { 'Authorization' => token }
|
||||
end
|
||||
|
||||
def test_can_query_domain_info
|
||||
headers = @auth_headers
|
||||
headers['Auth-Code'] = @domain.transfer_code
|
||||
|
||||
get "/repp/v1/domains/#{@domain.name}/transfer_info", headers: headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 1000, json[:code]
|
||||
assert_equal 'Command completed successfully', json[:message]
|
||||
assert_equal @domain.name, json[:data][:domain]
|
||||
assert json[:data][:registrant].present?
|
||||
assert json[:data][:admin_contacts].present?
|
||||
assert json[:data][:tech_contacts].present?
|
||||
end
|
||||
|
||||
def test_respects_domain_authorization_code
|
||||
headers = @auth_headers
|
||||
headers['Auth-Code'] = 'jhfgifhdg'
|
||||
|
||||
get "/repp/v1/domains/#{@domain.name}/transfer_info", headers: headers
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :bad_request
|
||||
assert_equal 2202, json[:code]
|
||||
assert_equal 'Authorization error', json[:message]
|
||||
assert_empty json[:data]
|
||||
end
|
||||
end
|
127
test/integration/repp/v1/domains/transfer_test.rb
Normal file
127
test/integration/repp/v1/domains/transfer_test.rb
Normal file
|
@ -0,0 +1,127 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ReppV1DomainsTransferTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@user = users(:api_bestnames)
|
||||
token = Base64.encode64("#{@user.username}:#{@user.plain_text_password}")
|
||||
token = "Basic #{token}"
|
||||
@domain = domains(:hospital)
|
||||
|
||||
@auth_headers = { 'Authorization' => token }
|
||||
end
|
||||
|
||||
def test_transfers_domain
|
||||
payload = {
|
||||
"data": {
|
||||
"domain_transfers": [
|
||||
{ "domain_name": @domain.name, "transfer_code": @domain.transfer_code }
|
||||
]
|
||||
}
|
||||
}
|
||||
post "/repp/v1/domains/transfer", headers: @auth_headers, params: payload
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 1000, json[:code]
|
||||
assert_equal 'Command completed successfully', json[:message]
|
||||
|
||||
assert_equal @domain.name, json[:data][:success][0][:domain_name]
|
||||
|
||||
@domain.reload
|
||||
|
||||
assert @domain.registrar = @user.registrar
|
||||
end
|
||||
|
||||
def test_does_not_transfer_domain_if_not_transferable
|
||||
@domain.schedule_force_delete(type: :fast_track)
|
||||
|
||||
payload = {
|
||||
"data": {
|
||||
"domain_transfers": [
|
||||
{ "domain_name": @domain.name, "transfer_code": @domain.transfer_code }
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
post "/repp/v1/domains/transfer", headers: @auth_headers, params: payload
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 1000, json[:code]
|
||||
assert_equal 'Command completed successfully', json[:message]
|
||||
|
||||
assert_equal 'Object status prohibits operation', json[:data][:failed][0][:errors][0][:msg]
|
||||
|
||||
@domain.reload
|
||||
|
||||
assert_not @domain.registrar == @user.registrar
|
||||
end
|
||||
|
||||
def test_does_not_transfer_domain_with_invalid_auth_code
|
||||
payload = {
|
||||
"data": {
|
||||
"domain_transfers": [
|
||||
{ "domain_name": @domain.name, "transfer_code": "sdfgsdfg" }
|
||||
]
|
||||
}
|
||||
}
|
||||
post "/repp/v1/domains/transfer", headers: @auth_headers, params: payload
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 1000, json[:code]
|
||||
assert_equal 'Command completed successfully', json[:message]
|
||||
|
||||
assert_equal "Invalid authorization information", json[:data][:failed][0][:errors][0][:msg]
|
||||
end
|
||||
|
||||
def test_does_not_transfer_domain_to_same_registrar
|
||||
@domain.update!(registrar: @user.registrar)
|
||||
|
||||
payload = {
|
||||
"data": {
|
||||
"domain_transfers": [
|
||||
{ "domain_name": @domain.name, "transfer_code": @domain.transfer_code }
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
post "/repp/v1/domains/transfer", headers: @auth_headers, params: payload
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 1000, json[:code]
|
||||
assert_equal 'Command completed successfully', json[:message]
|
||||
|
||||
assert_equal 'Domain already belongs to the querying registrar', json[:data][:failed][0][:errors][0][:msg]
|
||||
|
||||
@domain.reload
|
||||
|
||||
assert @domain.registrar == @user.registrar
|
||||
end
|
||||
|
||||
def test_does_not_transfer_domain_if_discarded
|
||||
@domain.update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||
|
||||
payload = {
|
||||
"data": {
|
||||
"domain_transfers": [
|
||||
{ "domain_name": @domain.name, "transfer_code": @domain.transfer_code }
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
post "/repp/v1/domains/transfer", headers: @auth_headers, params: payload
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 1000, json[:code]
|
||||
assert_equal 'Command completed successfully', json[:message]
|
||||
|
||||
assert_equal 'Object is not eligible for transfer', json[:data][:failed][0][:errors][0][:msg]
|
||||
|
||||
@domain.reload
|
||||
|
||||
assert_not @domain.registrar == @user.registrar
|
||||
end
|
||||
end
|
77
test/integration/repp/v1/registrar/nameservers_test.rb
Normal file
77
test/integration/repp/v1/registrar/nameservers_test.rb
Normal file
|
@ -0,0 +1,77 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ReppV1RegistrarNameserversTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@user = users(:api_bestnames)
|
||||
token = Base64.encode64("#{@user.username}:#{@user.plain_text_password}")
|
||||
token = "Basic #{token}"
|
||||
|
||||
@auth_headers = { 'Authorization' => token }
|
||||
end
|
||||
|
||||
def test_updates_nameserver_values
|
||||
nameserver = nameservers(:shop_ns1)
|
||||
payload = {
|
||||
"data": {
|
||||
"id": nameserver.hostname,
|
||||
"type": "nameserver",
|
||||
"attributes": {
|
||||
"hostname": "#{nameserver.hostname}.test",
|
||||
"ipv4": ["1.1.1.1"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
put '/repp/v1/registrar/nameservers', headers: @auth_headers, params: payload
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 1000, json[:code]
|
||||
assert_equal 'Command completed successfully', json[:message]
|
||||
assert_equal({ hostname: "#{nameserver.hostname}.test", ipv4: ["1.1.1.1"] }, json[:data][:attributes])
|
||||
assert_equal({ hostname: "#{nameserver.hostname}.test", ipv4: ["1.1.1.1"] }, json[:data][:attributes])
|
||||
assert json[:data][:affected_domains].include? 'airport.test'
|
||||
assert json[:data][:affected_domains].include? 'shop.test'
|
||||
end
|
||||
|
||||
def test_nameserver_with_hostname_must_exist
|
||||
payload = {
|
||||
"data": {
|
||||
"id": 'ns.nonexistant.test',
|
||||
"type": "nameserver",
|
||||
"attributes": {
|
||||
"hostname": "ns1.dn.test",
|
||||
"ipv4": ["1.1.1.1"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
put '/repp/v1/registrar/nameservers', headers: @auth_headers, params: payload
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :not_found
|
||||
assert_equal 2303, json[:code]
|
||||
assert_equal 'Object does not exist', json[:message]
|
||||
end
|
||||
|
||||
def test_ip_must_be_in_correct_format
|
||||
nameserver = nameservers(:shop_ns1)
|
||||
payload = {
|
||||
"data": {
|
||||
"id": nameserver.hostname,
|
||||
"type": "nameserver",
|
||||
"attributes": {
|
||||
"hostname": "#{nameserver.hostname}.test",
|
||||
"ipv6": ["1.1.1.1"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
put '/repp/v1/registrar/nameservers', headers: @auth_headers, params: payload
|
||||
json = JSON.parse(response.body, symbolize_names: true)
|
||||
|
||||
assert_response :bad_request
|
||||
assert_equal 2005, json[:code]
|
||||
assert_equal 'IPv6 is invalid [ipv6]', json[:message]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,25 @@
|
|||
require 'test_helper'
|
||||
|
||||
class DomainDeleteTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@domain = domains(:shop)
|
||||
end
|
||||
|
||||
def test_discards_domains_with_past_delete_date
|
||||
@domain.update!(delete_date: '2010-07-04')
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
|
||||
Domains::Delete::DoDelete.run(domain: @domain)
|
||||
|
||||
assert @domain.destroyed?
|
||||
end
|
||||
|
||||
def test_sends_notification
|
||||
@domain.update!(delete_date: '2010-07-04')
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
|
||||
assert_difference '@domain.registrar.notifications.count', 1 do
|
||||
Domains::Delete::DoDelete.run(domain: @domain)
|
||||
end
|
||||
end
|
||||
end
|
28
test/interactions/expire_period/start_test.rb
Normal file
28
test/interactions/expire_period/start_test.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
require 'test_helper'
|
||||
|
||||
class StartTest < ActiveSupport::TestCase
|
||||
include ActionMailer::TestHelper
|
||||
|
||||
setup do
|
||||
@domain = domains(:shop)
|
||||
@domain.update(expire_time: Time.zone.now - 1.day)
|
||||
ActionMailer::Base.deliveries.clear
|
||||
end
|
||||
|
||||
def test_sets_expired
|
||||
job_count = lambda do
|
||||
QueJob.where("args->>0 = '#{@domain.id}'", job_class: DomainExpireEmailJob.name).count
|
||||
end
|
||||
|
||||
assert_difference job_count, 1 do
|
||||
perform_enqueued_jobs do
|
||||
DomainCron.start_expire_period
|
||||
end
|
||||
end
|
||||
|
||||
@domain.reload
|
||||
assert @domain.statuses.include?(DomainStatus::EXPIRED)
|
||||
assert_equal @domain.outzone_at, @domain.expire_time + Domain.expire_warning_period
|
||||
assert_equal @domain.delete_date, (@domain.outzone_at + Domain.redemption_grace_period).to_date
|
||||
end
|
||||
end
|
25
test/interactions/redemption_grace_period/start_test.rb
Normal file
25
test/interactions/redemption_grace_period/start_test.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
require 'test_helper'
|
||||
|
||||
class StartTest < ActiveSupport::TestCase
|
||||
|
||||
setup do
|
||||
@domain = domains(:shop)
|
||||
@domain.update(outzone_time: Time.zone.now - 1.day)
|
||||
end
|
||||
|
||||
def test_sets_server_hold
|
||||
DomainCron.start_redemption_grace_period
|
||||
|
||||
@domain.reload
|
||||
assert @domain.statuses.include?(DomainStatus::SERVER_HOLD)
|
||||
end
|
||||
|
||||
def test_doesnt_sets_server_hold_if_not_outzone
|
||||
@domain.update(outzone_time: nil)
|
||||
@domain.reload
|
||||
DomainCron.start_redemption_grace_period
|
||||
|
||||
@domain.reload
|
||||
assert_not @domain.statuses.include?(DomainStatus::SERVER_HOLD)
|
||||
end
|
||||
end
|
|
@ -18,7 +18,7 @@ class DomainDeleteConfirmJobTest < ActiveSupport::TestCase
|
|||
new_registrant_email: @new_registrant.email,
|
||||
current_user_id: @user.id })
|
||||
|
||||
DomainDeleteConfirmJob.enqueue(@domain.id, RegistrantVerification::REJECTED)
|
||||
DomainDeleteConfirmJob.perform_now(@domain.id, RegistrantVerification::REJECTED)
|
||||
|
||||
last_registrar_notification = @domain.registrar.notifications.last
|
||||
assert_equal(last_registrar_notification.attached_obj_id, @domain.id)
|
||||
|
@ -31,7 +31,7 @@ class DomainDeleteConfirmJobTest < ActiveSupport::TestCase
|
|||
new_registrant_email: @new_registrant.email,
|
||||
current_user_id: @user.id })
|
||||
|
||||
DomainDeleteConfirmJob.enqueue(@domain.id, RegistrantVerification::CONFIRMED)
|
||||
DomainDeleteConfirmJob.perform_now(@domain.id, RegistrantVerification::CONFIRMED)
|
||||
|
||||
last_registrar_notification = @domain.registrar.notifications.last
|
||||
assert_equal(last_registrar_notification.attached_obj_id, @domain.id)
|
||||
|
@ -51,7 +51,7 @@ class DomainDeleteConfirmJobTest < ActiveSupport::TestCase
|
|||
assert @domain.registrant_delete_confirmable?(@domain.registrant_verification_token)
|
||||
assert_equal @user.id, @domain.pending_json['current_user_id']
|
||||
|
||||
DomainDeleteConfirmJob.enqueue(@domain.id, RegistrantVerification::CONFIRMED)
|
||||
DomainDeleteConfirmJob.perform_now(@domain.id, RegistrantVerification::CONFIRMED)
|
||||
@domain.reload
|
||||
|
||||
assert @domain.statuses.include? DomainStatus::PENDING_DELETE
|
||||
|
@ -72,7 +72,7 @@ class DomainDeleteConfirmJobTest < ActiveSupport::TestCase
|
|||
assert @domain.registrant_delete_confirmable?(@domain.registrant_verification_token)
|
||||
assert_equal @user.id, @domain.pending_json['current_user_id']
|
||||
|
||||
DomainDeleteConfirmJob.enqueue(@domain.id, RegistrantVerification::REJECTED)
|
||||
DomainDeleteConfirmJob.perform_now(@domain.id, RegistrantVerification::REJECTED)
|
||||
@domain.reload
|
||||
|
||||
assert_equal ['ok'], @domain.statuses
|
||||
|
|
|
@ -20,7 +20,7 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_rejected_registrant_verification_notifies_registrar
|
||||
DomainUpdateConfirmJob.enqueue(@domain.id, RegistrantVerification::REJECTED)
|
||||
DomainUpdateConfirmJob.perform_now(@domain.id, RegistrantVerification::REJECTED)
|
||||
|
||||
last_registrar_notification = @domain.registrar.notifications.last
|
||||
assert_equal(last_registrar_notification.attached_obj_id, @domain.id)
|
||||
|
@ -28,7 +28,7 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_accepted_registrant_verification_notifies_registrar
|
||||
DomainUpdateConfirmJob.enqueue(@domain.id, RegistrantVerification::CONFIRMED)
|
||||
DomainUpdateConfirmJob.perform_now(@domain.id, RegistrantVerification::CONFIRMED)
|
||||
|
||||
last_registrar_notification = @domain.registrar.notifications.last
|
||||
assert_equal(last_registrar_notification.attached_obj_id, @domain.id)
|
||||
|
@ -44,10 +44,11 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase
|
|||
@domain.update(pending_json: @domain.pending_json)
|
||||
|
||||
@domain.reload
|
||||
DomainUpdateConfirmJob.enqueue(@domain.id, RegistrantVerification::CONFIRMED)
|
||||
DomainUpdateConfirmJob.perform_now(@domain.id, RegistrantVerification::CONFIRMED)
|
||||
@domain.reload
|
||||
|
||||
assert_equal @domain.registrant.code, @new_registrant.code
|
||||
assert @domain.statuses.include? DomainStatus::OK
|
||||
end
|
||||
|
||||
def test_clears_pending_update_after_denial
|
||||
|
@ -58,10 +59,84 @@ class DomainUpdateConfirmJobTest < ActiveSupport::TestCase
|
|||
@domain.pending_json['frame'] = epp_xml
|
||||
@domain.update(pending_json: @domain.pending_json)
|
||||
|
||||
DomainUpdateConfirmJob.enqueue(@domain.id, RegistrantVerification::REJECTED)
|
||||
DomainUpdateConfirmJob.perform_now(@domain.id, RegistrantVerification::REJECTED)
|
||||
@domain.reload
|
||||
|
||||
assert_not @domain.statuses.include? DomainStatus::PENDING_DELETE_CONFIRMATION
|
||||
assert_not @domain.statuses.include? DomainStatus::PENDING_DELETE
|
||||
end
|
||||
|
||||
def test_protects_statuses_after_denial
|
||||
epp_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<epp>\n <command>\n <update>\n <update>\n <name>#{@domain.name}</name>\n" \
|
||||
" <chg>\n <registrant>#{@new_registrant.code}</registrant>\n </chg>\n </update>\n </update>\n <extension>\n <update/>\n" \
|
||||
" <extdata>\n <legalDocument type=\"pdf\">#{@legal_doc_path}</legalDocument>\n </extdata>\n" \
|
||||
" </extension>\n <clTRID>20alla-1594199756</clTRID>\n </command>\n</epp>\n"
|
||||
@domain.pending_json['frame'] = epp_xml
|
||||
@domain.update(pending_json: @domain.pending_json)
|
||||
@domain.update(statuses: [DomainStatus::DELETE_CANDIDATE, DomainStatus::DISPUTED])
|
||||
|
||||
DomainUpdateConfirmJob.perform_now(@domain.id, RegistrantVerification::REJECTED)
|
||||
@domain.reload
|
||||
|
||||
assert_not @domain.statuses.include? DomainStatus::PENDING_DELETE_CONFIRMATION
|
||||
assert_not @domain.statuses.include? DomainStatus::PENDING_DELETE
|
||||
assert @domain.statuses.include? DomainStatus::DELETE_CANDIDATE
|
||||
assert @domain.statuses.include? DomainStatus::DISPUTED
|
||||
end
|
||||
|
||||
def test_protects_statuses_after_confirm
|
||||
epp_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<epp>\n <command>\n <update>\n <update>\n <name>#{@domain.name}</name>\n" \
|
||||
" <chg>\n <registrant>#{@new_registrant.code}</registrant>\n </chg>\n </update>\n </update>\n <extension>\n <update/>\n" \
|
||||
" <extdata>\n <legalDocument type=\"pdf\">#{@legal_doc_path}</legalDocument>\n </extdata>\n" \
|
||||
" </extension>\n <clTRID>20alla-1594199756</clTRID>\n </command>\n</epp>\n"
|
||||
@domain.pending_json['frame'] = epp_xml
|
||||
@domain.update(pending_json: @domain.pending_json)
|
||||
@domain.update(statuses: [DomainStatus::DELETE_CANDIDATE, DomainStatus::DISPUTED])
|
||||
|
||||
DomainUpdateConfirmJob.perform_now(@domain.id, RegistrantVerification::CONFIRMED)
|
||||
@domain.reload
|
||||
|
||||
assert_not @domain.statuses.include? DomainStatus::PENDING_DELETE_CONFIRMATION
|
||||
assert_not @domain.statuses.include? DomainStatus::PENDING_DELETE
|
||||
assert @domain.statuses.include? DomainStatus::DELETE_CANDIDATE
|
||||
assert @domain.statuses.include? DomainStatus::DISPUTED
|
||||
end
|
||||
|
||||
def test_clears_pending_update_and_inactive_after_denial
|
||||
epp_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<epp>\n <command>\n <update>\n <update>\n <name>#{@domain.name}</name>\n" \
|
||||
" <chg>\n <registrant>#{@new_registrant.code}</registrant>\n </chg>\n </update>\n </update>\n <extension>\n <update/>\n" \
|
||||
" <extdata>\n <legalDocument type=\"pdf\">#{@legal_doc_path}</legalDocument>\n </extdata>\n" \
|
||||
" </extension>\n <clTRID>20alla-1594199756</clTRID>\n </command>\n</epp>\n"
|
||||
@domain.pending_json['frame'] = epp_xml
|
||||
@domain.update(pending_json: @domain.pending_json)
|
||||
@domain.update(statuses: [DomainStatus::PENDING_UPDATE])
|
||||
@domain.nameservers.destroy_all
|
||||
@domain.reload
|
||||
|
||||
DomainUpdateConfirmJob.perform_now(@domain.id, RegistrantVerification::REJECTED)
|
||||
@domain.reload
|
||||
|
||||
assert_not @domain.statuses.include? DomainStatus::PENDING_DELETE_CONFIRMATION
|
||||
assert_not @domain.statuses.include? DomainStatus::PENDING_DELETE
|
||||
assert_not @domain.statuses.include? DomainStatus::PENDING_UPDATE
|
||||
assert @domain.statuses.include? DomainStatus::INACTIVE
|
||||
end
|
||||
|
||||
def test_clears_pending_update_and_sets_ok_after_denial
|
||||
epp_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<epp>\n <command>\n <update>\n <update>\n <name>#{@domain.name}</name>\n" \
|
||||
" <chg>\n <registrant>#{@new_registrant.code}</registrant>\n </chg>\n </update>\n </update>\n <extension>\n <update/>\n" \
|
||||
" <extdata>\n <legalDocument type=\"pdf\">#{@legal_doc_path}</legalDocument>\n </extdata>\n" \
|
||||
" </extension>\n <clTRID>20alla-1594199756</clTRID>\n </command>\n</epp>\n"
|
||||
@domain.pending_json['frame'] = epp_xml
|
||||
@domain.update(pending_json: @domain.pending_json)
|
||||
@domain.update(statuses: [DomainStatus::OK, DomainStatus::PENDING_UPDATE])
|
||||
|
||||
DomainUpdateConfirmJob.perform_now(@domain.id, RegistrantVerification::REJECTED)
|
||||
@domain.reload
|
||||
|
||||
assert_not @domain.statuses.include? DomainStatus::PENDING_DELETE_CONFIRMATION
|
||||
assert_not @domain.statuses.include? DomainStatus::PENDING_DELETE
|
||||
assert_not @domain.statuses.include? DomainStatus::PENDING_UPDATE
|
||||
assert @domain.statuses.include? DomainStatus::OK
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ require 'serializers/registrant_api/contact'
|
|||
class SerializersRegistrantApiContactTest < ActiveSupport::TestCase
|
||||
def setup
|
||||
@contact = contacts(:william)
|
||||
@serializer = Serializers::RegistrantApi::Contact.new(@contact)
|
||||
@serializer = Serializers::RegistrantApi::Contact.new(@contact, false)
|
||||
@json = @serializer.to_json
|
||||
end
|
||||
|
||||
|
|
104
test/models/bounced_mail_address_test.rb
Normal file
104
test/models/bounced_mail_address_test.rb
Normal file
|
@ -0,0 +1,104 @@
|
|||
require 'test_helper'
|
||||
|
||||
class BouncedMailAddressTest < ActiveSupport::TestCase
|
||||
include ActionMailer::TestHelper
|
||||
|
||||
def setup
|
||||
@bounced_mail = BouncedMailAddress.new
|
||||
@bounced_mail.email = 'recipient@registry.test'
|
||||
@bounced_mail.message_id = '010f0174a0c7d348-ea6e2fc1-0854-4073-b71f-5cecf9b0d0b2-000000'
|
||||
@bounced_mail.bounce_type = 'Permanent'
|
||||
@bounced_mail.bounce_subtype = 'General'
|
||||
@bounced_mail.action = 'failed'
|
||||
@bounced_mail.status = '5.1.1'
|
||||
@bounced_mail.diagnostic = 'smtp; 550 5.1.1 user unknown'
|
||||
end
|
||||
|
||||
def test_email_is_required
|
||||
assert @bounced_mail.valid?
|
||||
@bounced_mail.email = nil
|
||||
assert @bounced_mail.invalid?
|
||||
end
|
||||
|
||||
def test_message_id_is_required
|
||||
assert @bounced_mail.valid?
|
||||
@bounced_mail.message_id = nil
|
||||
assert @bounced_mail.invalid?
|
||||
end
|
||||
|
||||
def test_bounce_type_is_required
|
||||
assert @bounced_mail.valid?
|
||||
@bounced_mail.bounce_type = nil
|
||||
assert @bounced_mail.invalid?
|
||||
end
|
||||
|
||||
def test_bounce_subtype_is_required
|
||||
assert @bounced_mail.valid?
|
||||
@bounced_mail.bounce_subtype = nil
|
||||
assert @bounced_mail.invalid?
|
||||
end
|
||||
|
||||
def test_action_is_required
|
||||
assert @bounced_mail.valid?
|
||||
@bounced_mail.action = nil
|
||||
assert @bounced_mail.invalid?
|
||||
end
|
||||
|
||||
def test_status_is_required
|
||||
assert @bounced_mail.valid?
|
||||
@bounced_mail.status = nil
|
||||
assert @bounced_mail.invalid?
|
||||
end
|
||||
|
||||
def test_diagnostic_is_not_required
|
||||
assert @bounced_mail.valid?
|
||||
@bounced_mail.diagnostic = nil
|
||||
assert @bounced_mail.valid?
|
||||
end
|
||||
|
||||
def test_bounce_reason_is_determined_dynamically
|
||||
assert @bounced_mail.valid?
|
||||
assert_equal 'failed (5.1.1 smtp; 550 5.1.1 user unknown)', @bounced_mail.bounce_reason
|
||||
end
|
||||
|
||||
def test_creates_objects_from_sns_json
|
||||
BouncedMailAddress.record(sns_bounce_payload)
|
||||
|
||||
bounced_mail = BouncedMailAddress.last
|
||||
assert_equal domains(:shop).registrant.email, bounced_mail.email
|
||||
assert_equal 'failed', bounced_mail.action
|
||||
assert_equal '5.1.1', bounced_mail.status
|
||||
assert_equal 'smtp; 550 5.1.1 user unknown', bounced_mail.diagnostic
|
||||
end
|
||||
|
||||
def sns_bounce_payload
|
||||
{
|
||||
"notificationType": "Bounce",
|
||||
"mail": {
|
||||
"source": "noreply@registry.test",
|
||||
"sourceIp": "195.43.86.5",
|
||||
"messageId": "010f0174a0c7d348-ea6e2fc1-0854-4073-b71f-5cecf9b0d0b2-000000",
|
||||
"sourceArn": "arn:aws:ses:us-east-2:65026820000:identity/noreply@registry.test",
|
||||
"timestamp": "2020-09-18T10:34:44.000Z",
|
||||
"destination": [ "#{domains(:shop).registrant.email}" ],
|
||||
"sendingAccountId": "650268220000"
|
||||
},
|
||||
"bounce": {
|
||||
"timestamp": "2020-09-18T10:34:44.911Z",
|
||||
"bounceType": "Permanent",
|
||||
"feedbackId": "010f0174a0c7d4f9-27d59756-6111-4d5f-xxxx-26bee0d55fa2-000000",
|
||||
"remoteMtaIp": "127.0.01",
|
||||
"reportingMTA": "dsn; xxx.amazonses.com",
|
||||
"bounceSubType": "General",
|
||||
"bouncedRecipients": [
|
||||
{
|
||||
"action": "failed",
|
||||
"status": "5.1.1",
|
||||
"emailAddress": "#{domains(:shop).registrant.email}",
|
||||
"diagnosticCode": "smtp; 550 5.1.1 user unknown"
|
||||
}
|
||||
]
|
||||
}
|
||||
}.as_json
|
||||
end
|
||||
end
|
|
@ -1,18 +1,20 @@
|
|||
require 'test_helper'
|
||||
|
||||
class NewDomainForceDeleteTest < ActiveSupport::TestCase
|
||||
class ForceDeleteTest < ActionMailer::TestCase
|
||||
setup do
|
||||
@domain = domains(:shop)
|
||||
Setting.redemption_grace_period = 30
|
||||
ActionMailer::Base.deliveries.clear
|
||||
end
|
||||
|
||||
def test_schedules_force_delete_fast_track
|
||||
assert_not @domain.force_delete_scheduled?
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
|
||||
@domain.schedule_force_delete(type: :fast_track)
|
||||
@domain.schedule_force_delete(type: :fast_track, notify_by_email: true)
|
||||
@domain.reload
|
||||
|
||||
assert_emails 1
|
||||
assert @domain.force_delete_scheduled?
|
||||
assert_equal Date.parse('2010-08-20'), @domain.force_delete_date.to_date
|
||||
assert_equal Date.parse('2010-07-06'), @domain.force_delete_start.to_date
|
||||
|
@ -111,9 +113,12 @@ class NewDomainForceDeleteTest < ActiveSupport::TestCase
|
|||
|
||||
def test_force_delete_cannot_be_scheduled_when_a_domain_is_discarded
|
||||
@domain.update!(statuses: [DomainStatus::DELETE_CANDIDATE])
|
||||
assert_raises StandardError do
|
||||
@domain.schedule_force_delete(type: :fast_track)
|
||||
end
|
||||
result = Domains::ForceDelete::SetForceDelete.run(domain: @domain, type: :fast_track)
|
||||
|
||||
assert_not result.valid?
|
||||
assert_not @domain.force_delete_scheduled?
|
||||
message = ["Force delete procedure cannot be scheduled while a domain is discarded"]
|
||||
assert_equal message, result.errors.messages[:domain]
|
||||
end
|
||||
|
||||
def test_cancels_force_delete
|
||||
|
@ -201,9 +206,10 @@ class NewDomainForceDeleteTest < ActiveSupport::TestCase
|
|||
@domain.schedule_force_delete(type: :soft)
|
||||
|
||||
travel_to Time.zone.parse('2010-08-21')
|
||||
DomainCron.start_client_hold
|
||||
Domains::ClientHold::SetClientHold.run!
|
||||
@domain.reload
|
||||
|
||||
assert_emails 1
|
||||
assert_equal(@domain.purge_date.to_date, @domain.force_delete_date.to_date)
|
||||
assert_equal(@domain.outzone_date.to_date, @domain.force_delete_start.to_date +
|
||||
Setting.expire_warning_period.days)
|
||||
|
@ -221,8 +227,10 @@ class NewDomainForceDeleteTest < ActiveSupport::TestCase
|
|||
@domain.schedule_force_delete(type: :soft)
|
||||
|
||||
travel_to Time.zone.parse('2010-08-21')
|
||||
DomainCron.start_client_hold
|
||||
Domains::ClientHold::SetClientHold.run!
|
||||
@domain.reload
|
||||
|
||||
assert_emails 1
|
||||
assert_includes(@domain.statuses, asserted_status)
|
||||
end
|
||||
|
||||
|
@ -236,7 +244,7 @@ class NewDomainForceDeleteTest < ActiveSupport::TestCase
|
|||
@domain.schedule_force_delete(type: :soft)
|
||||
|
||||
travel_to Time.zone.parse('2010-07-06')
|
||||
DomainCron.start_client_hold
|
||||
Domains::ClientHold::SetClientHold.run!
|
||||
@domain.reload
|
||||
|
||||
assert_not_includes(@domain.statuses, asserted_status)
|
||||
|
@ -251,7 +259,7 @@ class NewDomainForceDeleteTest < ActiveSupport::TestCase
|
|||
|
||||
@domain.schedule_force_delete(type: :fast_track)
|
||||
travel_to Time.zone.parse('2010-07-25')
|
||||
DomainCron.start_client_hold
|
||||
Domains::ClientHold::SetClientHold.run!
|
||||
@domain.reload
|
||||
|
||||
assert_includes(@domain.statuses, asserted_status)
|
||||
|
@ -267,7 +275,7 @@ class NewDomainForceDeleteTest < ActiveSupport::TestCase
|
|||
|
||||
@domain.schedule_force_delete(type: :fast_track)
|
||||
travel_to Time.zone.parse('2010-07-06')
|
||||
DomainCron.start_client_hold
|
||||
Domains::ClientHold::SetClientHold.run!
|
||||
@domain.reload
|
||||
|
||||
assert_not_includes(@domain.statuses, asserted_status)
|
||||
|
|
|
@ -19,7 +19,9 @@ class DomainCronTest < ActiveSupport::TestCase
|
|||
registrant_verification_token: 'test',
|
||||
statuses: [DomainStatus::PENDING_DELETE_CONFIRMATION])
|
||||
|
||||
DomainCron.clean_expired_pendings
|
||||
perform_enqueued_jobs do
|
||||
DomainCron.clean_expired_pendings
|
||||
end
|
||||
|
||||
assert_emails 1
|
||||
end
|
||||
|
@ -84,7 +86,9 @@ class DomainCronTest < ActiveSupport::TestCase
|
|||
assert @domain.pending_update?
|
||||
@domain.reload
|
||||
|
||||
DomainCron.clean_expired_pendings
|
||||
perform_enqueued_jobs do
|
||||
DomainCron.clean_expired_pendings
|
||||
end
|
||||
@domain.reload
|
||||
|
||||
assert_not @domain.pending_update?
|
||||
|
|
|
@ -414,7 +414,7 @@ class DomainTest < ActiveSupport::TestCase
|
|||
force_delete_date: nil)
|
||||
@domain.update(template_name: 'legal_person')
|
||||
travel_to Time.zone.parse('2010-07-05')
|
||||
@domain.schedule_force_delete(type: :fast_track)
|
||||
Domains::ForceDelete::SetForceDelete.run!(domain: @domain, type: :fast_track)
|
||||
assert(@domain.force_delete_scheduled?)
|
||||
other_registrant = Registrant.find_by(code: 'jane-001')
|
||||
@domain.pending_json['new_registrant_id'] = other_registrant.id
|
||||
|
|
|
@ -70,6 +70,6 @@ class Whois::RecordTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def registration_deadline
|
||||
Time.zone.now + 10.days
|
||||
@registration_deadline ||= Time.zone.now + 10.days
|
||||
end
|
||||
end
|
||||
|
|
40
test/system/admin_area/bounced_mail_addresses_test.rb
Normal file
40
test/system/admin_area/bounced_mail_addresses_test.rb
Normal file
|
@ -0,0 +1,40 @@
|
|||
require 'application_system_test_case'
|
||||
|
||||
class AdminBouncedMailAddressesTest < ApplicationSystemTestCase
|
||||
include ActionView::Helpers::NumberHelper
|
||||
|
||||
def setup
|
||||
@bounced_mail = bounced_mail_addresses(:one)
|
||||
@original_default_language = Setting.default_language
|
||||
sign_in users(:admin)
|
||||
end
|
||||
|
||||
def teardown
|
||||
Setting.default_language = @original_default_language
|
||||
end
|
||||
|
||||
def test_shows_bounced_emails
|
||||
visit admin_bounced_mail_addresses_path
|
||||
assert_text @bounced_mail.status
|
||||
assert_text @bounced_mail.action
|
||||
assert_text @bounced_mail.diagnostic
|
||||
assert_text @bounced_mail.email
|
||||
end
|
||||
|
||||
def test_shows_detailed_bounced_email
|
||||
visit admin_bounced_mail_address_path(@bounced_mail)
|
||||
assert_text @bounced_mail.status
|
||||
assert_text @bounced_mail.action
|
||||
assert_text @bounced_mail.diagnostic
|
||||
assert_text @bounced_mail.email
|
||||
|
||||
assert_text @bounced_mail.message_id
|
||||
end
|
||||
|
||||
def test_deletes_registrar
|
||||
visit admin_bounced_mail_address_path(@bounced_mail)
|
||||
click_on 'Destroy'
|
||||
|
||||
assert_text 'Bounced mail address was successfully destroyed.'
|
||||
end
|
||||
end
|
|
@ -1,6 +1,7 @@
|
|||
require 'application_system_test_case'
|
||||
|
||||
class DomainDeleteConfirmsTest < ApplicationSystemTestCase
|
||||
include ActionMailer::TestHelper
|
||||
setup do
|
||||
@user = users(:registrant)
|
||||
sign_in @user
|
||||
|
@ -13,7 +14,9 @@ class DomainDeleteConfirmsTest < ApplicationSystemTestCase
|
|||
def test_enqueues_approve_job_after_verification
|
||||
visit registrant_domain_delete_confirm_url(@domain.id, token: @domain.registrant_verification_token)
|
||||
|
||||
click_on 'Confirm domain delete'
|
||||
perform_enqueued_jobs do
|
||||
click_on 'Confirm domain delete'
|
||||
end
|
||||
assert_text 'Domain registrant change has successfully received.'
|
||||
|
||||
@domain.reload
|
||||
|
@ -23,7 +26,9 @@ class DomainDeleteConfirmsTest < ApplicationSystemTestCase
|
|||
def test_enqueues_reject_job_after_verification
|
||||
visit registrant_domain_delete_confirm_url(@domain.id, token: @domain.registrant_verification_token)
|
||||
|
||||
click_on 'Reject domain delete'
|
||||
perform_enqueued_jobs do
|
||||
click_on 'Reject domain delete'
|
||||
end
|
||||
assert_text 'Domain registrant change has been rejected successfully.'
|
||||
|
||||
@domain.reload
|
||||
|
|
|
@ -29,6 +29,16 @@ class RegistrarAreaBaseTestTest < ApplicationSystemTestCase
|
|||
assert_button 'Login'
|
||||
end
|
||||
|
||||
def test_user_can_access_when_ip_is_whitelisted_with_subnet
|
||||
white_ips(:one).update!(ipv4: '127.0.0.1/32', interfaces: [WhiteIp::REGISTRAR])
|
||||
Setting.registrar_ip_whitelist_enabled = true
|
||||
|
||||
visit new_registrar_user_session_url
|
||||
|
||||
assert_no_text 'Access denied from IP 127.0.0.1'
|
||||
assert_button 'Login'
|
||||
end
|
||||
|
||||
def test_user_can_access_when_ip_is_not_whitelisted_and_whitelist_is_disabled
|
||||
Setting.registrar_ip_whitelist_enabled = false
|
||||
WhiteIp.delete_all
|
||||
|
|
70
test/system/registrar_area/bulk_change/bulk_renew_test.rb
Normal file
70
test/system/registrar_area/bulk_change/bulk_renew_test.rb
Normal file
|
@ -0,0 +1,70 @@
|
|||
require 'application_system_test_case'
|
||||
|
||||
class BulkRenewTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
@registrar = users(:api_bestnames).registrar
|
||||
@price = billing_prices(:renew_one_year)
|
||||
end
|
||||
|
||||
def test_shows_domain_list
|
||||
sign_in users(:api_bestnames)
|
||||
travel_to Time.zone.parse('2010-07-05 10:30')
|
||||
|
||||
visit new_registrar_bulk_change_url
|
||||
click_link('Bulk renew')
|
||||
assert_text 'Current balance'
|
||||
page.has_css?('#registrar_balance', text:
|
||||
ApplicationController.helpers.number_to_currency(@registrar.balance))
|
||||
|
||||
select '1 year', from: 'Period'
|
||||
click_button 'Filter'
|
||||
|
||||
@registrar.domains.pluck(:name).each do |domain_name|
|
||||
assert_text domain_name
|
||||
end
|
||||
end
|
||||
|
||||
def test_makes_bulk_renew
|
||||
sign_in users(:api_bestnames)
|
||||
travel_to Time.zone.parse('2010-07-05 10:30')
|
||||
|
||||
req_body = { domains: ["shop.test", "airport.test", "library.test", "invalid.test"], renew_period: "1y" }
|
||||
stub_request(:post, "#{ENV['repp_url']}domains/renew/bulk").with(body: req_body)
|
||||
.to_return(status: 400, body: {
|
||||
code: 2304,
|
||||
message: "Domain renew error for invalid.test",
|
||||
data: {}
|
||||
}.to_json)
|
||||
|
||||
visit new_registrar_bulk_change_url
|
||||
click_link('Bulk renew')
|
||||
select '1 year', from: 'Period'
|
||||
click_button 'Filter'
|
||||
click_button 'Renew'
|
||||
|
||||
assert_text 'Domain renew error for invalid.test'
|
||||
end
|
||||
|
||||
def test_bulk_renew_checks_balance
|
||||
sign_in users(:api_bestnames)
|
||||
@price.update(price_cents: 99999999)
|
||||
travel_to Time.zone.parse('2010-07-05 10:30')
|
||||
|
||||
req_body = { domains: ["shop.test", "airport.test", "library.test", "invalid.test"], renew_period: "1y" }
|
||||
stub_request(:post, "#{ENV['repp_url']}domains/renew/bulk").with(body: req_body)
|
||||
.to_return(status: 400, body: {
|
||||
code: 2304,
|
||||
message: "Not enough funds for renew domains",
|
||||
data: {}
|
||||
}.to_json)
|
||||
|
||||
visit new_registrar_bulk_change_url
|
||||
click_link('Bulk renew')
|
||||
select '1 year', from: 'Period'
|
||||
click_button 'Filter'
|
||||
click_button 'Renew'
|
||||
|
||||
assert_text 'Not enough funds for renew domains'
|
||||
|
||||
end
|
||||
end
|
|
@ -6,14 +6,14 @@ class RegistrarAreaBulkTransferTest < ApplicationSystemTestCase
|
|||
end
|
||||
|
||||
def test_transfer_multiple_domains_in_bulk
|
||||
request_body = { data: { domainTransfers: [{ domainName: 'shop.test', transferCode: '65078d5' }] } }
|
||||
request_body = { data: { domain_transfers: [{ domain_name: 'shop.test', transfer_code: '65078d5' }] } }
|
||||
headers = { 'Content-type' => Mime[:json] }
|
||||
request_stub = stub_request(:post, /domain_transfers/).with(body: request_body,
|
||||
request_stub = stub_request(:post, /domains\/transfer/).with(body: request_body,
|
||||
headers: headers,
|
||||
basic_auth: ['test_goodnames', 'testtest'])
|
||||
.to_return(body: { data: [{
|
||||
type: 'domain_transfer'
|
||||
}] }.to_json, status: 200)
|
||||
.to_return(body: { data: { success: [{ type: 'domain_transfer', domain_name: 'shop.test' }],
|
||||
failed: []
|
||||
} }.to_json, status: 200)
|
||||
|
||||
visit registrar_domains_url
|
||||
click_link 'Bulk change'
|
||||
|
@ -27,9 +27,9 @@ class RegistrarAreaBulkTransferTest < ApplicationSystemTestCase
|
|||
end
|
||||
|
||||
def test_fail_gracefully
|
||||
body = { errors: [{ title: 'epic fail' }] }.to_json
|
||||
body = { message: 'epic fail' }.to_json
|
||||
headers = { 'Content-type' => Mime[:json] }
|
||||
stub_request(:post, /domain_transfers/).to_return(status: 400, body: body, headers: headers)
|
||||
stub_request(:post, /domains\/transfer/).to_return(status: 400, body: body, headers: headers)
|
||||
|
||||
visit registrar_domains_url
|
||||
click_link 'Bulk change'
|
||||
|
|
|
@ -15,10 +15,12 @@ class RegistrarAreaNameserverBulkChangeTest < ApplicationSystemTestCase
|
|||
request_stub = stub_request(:put, /registrar\/nameservers/).with(body: request_body,
|
||||
headers: { 'Content-type' => Mime[:json] },
|
||||
basic_auth: ['test_goodnames', 'testtest'])
|
||||
.to_return(body: { data: [{
|
||||
type: 'nameserver',
|
||||
id: 'new-ns.bestnames.test'}],
|
||||
affected_domains: ["airport.test", "shop.test"]}.to_json, status: 200)
|
||||
.to_return(body: { data: {
|
||||
type: 'nameserver',
|
||||
id: 'new-ns.bestnames.test',
|
||||
affected_domains: ["airport.test", "shop.test"]
|
||||
}
|
||||
}.to_json, status: 200)
|
||||
|
||||
visit registrar_domains_url
|
||||
click_link 'Bulk change'
|
||||
|
@ -38,7 +40,7 @@ class RegistrarAreaNameserverBulkChangeTest < ApplicationSystemTestCase
|
|||
|
||||
def test_fails_gracefully
|
||||
stub_request(:put, /registrar\/nameservers/).to_return(status: 400,
|
||||
body: { errors: [{ title: 'epic fail' }] }.to_json,
|
||||
body: { message: 'epic fail' }.to_json,
|
||||
headers: { 'Content-type' => Mime[:json] })
|
||||
|
||||
visit registrar_domains_url
|
||||
|
@ -68,9 +70,9 @@ class RegistrarAreaNameserverBulkChangeTest < ApplicationSystemTestCase
|
|||
request_stub = stub_request(:put, /registrar\/nameservers/).with(body: request_body,
|
||||
headers: { 'Content-type' => Mime[:json] },
|
||||
basic_auth: ['test_goodnames', 'testtest'])
|
||||
.to_return(body: { data: [{
|
||||
.to_return(body: { data: {
|
||||
type: 'nameserver',
|
||||
id: 'new-ns.bestnames.test'}],
|
||||
id: 'new-ns.bestnames.test'},
|
||||
affected_domains: ["shop.test"]}.to_json, status: 200)
|
||||
|
||||
visit registrar_domains_url
|
||||
|
|
|
@ -9,8 +9,8 @@ class RegistrarAreaTechContactBulkChangeTest < ApplicationSystemTestCase
|
|||
request_stub = stub_request(:patch, /domains\/contacts/)
|
||||
.with(body: { current_contact_id: 'william-001', new_contact_id: 'john-001' },
|
||||
basic_auth: ['test_bestnames', 'testtest'])
|
||||
.to_return(body: { affected_domains: %w[foo.test bar.test],
|
||||
skipped_domains: %w[baz.test qux.test] }.to_json,
|
||||
.to_return(body: { data: { affected_domains: %w[foo.test bar.test],
|
||||
skipped_domains: %w[baz.test qux.test] } }.to_json,
|
||||
status: 200)
|
||||
|
||||
visit registrar_domains_url
|
||||
|
@ -30,7 +30,7 @@ class RegistrarAreaTechContactBulkChangeTest < ApplicationSystemTestCase
|
|||
def test_fails_gracefully
|
||||
stub_request(:patch, /domains\/contacts/)
|
||||
.to_return(status: 400,
|
||||
body: { error: { message: 'epic fail' } }.to_json,
|
||||
body: { message: 'epic fail' }.to_json,
|
||||
headers: { 'Content-type' => Mime[:json] })
|
||||
|
||||
visit registrar_domains_url
|
||||
|
|
|
@ -6,6 +6,7 @@ if ENV['COVERAGE']
|
|||
add_filter '/lib/core_monkey_patches/'
|
||||
add_filter '/lib/daemons/'
|
||||
add_filter '/lib/gem_monkey_patches/'
|
||||
add_filter '/lib/tasks/'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue