REPP: Fix tests

This commit is contained in:
Karl Erik Õunapuu 2020-10-14 17:09:47 +03:00
parent b8311ac5f6
commit 27774cc275
No known key found for this signature in database
GPG key ID: C9DD647298A34764
2 changed files with 15 additions and 12 deletions

View file

@ -13,7 +13,7 @@ class APIDomainTransfersTest < ApplicationIntegrationTest
end end
def test_returns_domain_transfers def test_returns_domain_transfers
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 } headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert_response 200 assert_response 200
assert_equal ({ data: [{ assert_equal ({ data: [{
@ -27,19 +27,19 @@ class APIDomainTransfersTest < ApplicationIntegrationTest
def test_creates_new_domain_transfer def test_creates_new_domain_transfer
assert_difference -> { @domain.transfers.size } do 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 } headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
end end
end end
def test_approves_automatically_if_auto_approval_is_enabled 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 } headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert @domain.transfers.last.approved? assert @domain.transfers.last.approved?
end end
def test_assigns_new_registrar 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 } headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
@domain.reload @domain.reload
assert_equal @new_registrar, @domain.registrar assert_equal @new_registrar, @domain.registrar
@ -48,7 +48,7 @@ class APIDomainTransfersTest < ApplicationIntegrationTest
def test_regenerates_transfer_code def test_regenerates_transfer_code
@old_transfer_code = @domain.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 } headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
@domain.reload @domain.reload
refute_equal @domain.transfer_code, @old_transfer_code refute_equal @domain.transfer_code, @old_transfer_code
@ -58,26 +58,26 @@ class APIDomainTransfersTest < ApplicationIntegrationTest
@old_registrar = @domain.registrar @old_registrar = @domain.registrar
assert_difference -> { @old_registrar.notifications.count } do 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 } headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
end end
end end
def test_duplicates_registrant_admin_and_tech_contacts def test_duplicates_registrant_admin_and_tech_contacts
assert_difference -> { @new_registrar.contacts.size }, 3 do 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 } headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
end end
end end
def test_reuses_identical_contact 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 } headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert_equal 1, @new_registrar.contacts.where(name: 'William').size assert_equal 1, @new_registrar.contacts.where(name: 'William').size
end end
def test_fails_if_domain_does_not_exist def test_fails_if_domain_does_not_exist
post '/repp/v1/domain_transfers', post '/repp/v1/domains/transfer',
params: { data: { domainTransfers: [{ domainName: 'non-existent.test', params: { data: { domainTransfers: [{ domainName: 'non-existent.test',
transferCode: 'any' }] } }, transferCode: 'any' }] } },
as: :json, as: :json,
@ -88,7 +88,7 @@ class APIDomainTransfersTest < ApplicationIntegrationTest
end end
def test_fails_if_transfer_code_is_wrong def test_fails_if_transfer_code_is_wrong
post '/repp/v1/domain_transfers', post '/repp/v1/domains/transfer',
params: { data: { domainTransfers: [{ domainName: 'shop.test', params: { data: { domainTransfers: [{ domainName: 'shop.test',
transferCode: 'wrong' }] } }, transferCode: 'wrong' }] } },
as: :json, as: :json,

View file

@ -60,7 +60,9 @@ class APINameserversPutTest < ApplicationIntegrationTest
headers: { 'HTTP_AUTHORIZATION' => http_auth_key } headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert_response 200 assert_response 200
assert_equal ({ data: { type: 'nameserver', assert_equal ({ code: '1000',
message: 'Command completed successfully',
data: { type: 'nameserver',
id: 'ns55.bestnames.test', id: 'ns55.bestnames.test',
attributes: { hostname: 'ns55.bestnames.test', attributes: { hostname: 'ns55.bestnames.test',
ipv4: ['192.0.2.55'], ipv4: ['192.0.2.55'],
@ -96,7 +98,8 @@ class APINameserversPutTest < ApplicationIntegrationTest
headers: { 'HTTP_AUTHORIZATION' => http_auth_key } headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
assert_response 400 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) JSON.parse(response.body, symbolize_names: true)
end end