mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 23:24:48 +02:00
Fix tests
This commit is contained in:
parent
27774cc275
commit
a6f7af0f03
8 changed files with 35 additions and 26 deletions
|
@ -16,13 +16,20 @@ class APIDomainTransfersTest < ApplicationIntegrationTest
|
|||
post '/repp/v1/domains/transfer', 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)
|
||||
|
||||
expected_body = {
|
||||
code: 1000,
|
||||
message: 'Command completed successfully',
|
||||
data: [
|
||||
{
|
||||
type: 'domain_transfer',
|
||||
attributes: { domain_name: 'shop.test' },
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
real_body = JSON.parse(response.body, symbolize_names: true)
|
||||
assert_equal(expected_body, real_body)
|
||||
end
|
||||
|
||||
def test_creates_new_domain_transfer
|
||||
|
@ -78,8 +85,8 @@ class APIDomainTransfersTest < ApplicationIntegrationTest
|
|||
|
||||
def test_fails_if_domain_does_not_exist
|
||||
post '/repp/v1/domains/transfer',
|
||||
params: { data: { domainTransfers: [{ domainName: 'non-existent.test',
|
||||
transferCode: 'any' }] } },
|
||||
params: { data: { domain_transfers: [{ domain_name: 'non-existent.test',
|
||||
transfer_code: 'any' }] } },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response 400
|
||||
|
@ -89,8 +96,8 @@ class APIDomainTransfersTest < ApplicationIntegrationTest
|
|||
|
||||
def test_fails_if_transfer_code_is_wrong
|
||||
post '/repp/v1/domains/transfer',
|
||||
params: { data: { domainTransfers: [{ domainName: 'shop.test',
|
||||
transferCode: 'wrong' }] } },
|
||||
params: { data: { domain_transfers: [{ domain_name: 'shop.test',
|
||||
transfer_code: 'wrong' }] } },
|
||||
as: :json,
|
||||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
assert_response 400
|
||||
|
@ -102,7 +109,7 @@ class APIDomainTransfersTest < ApplicationIntegrationTest
|
|||
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,14 +60,14 @@ class APINameserversPutTest < ApplicationIntegrationTest
|
|||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response 200
|
||||
assert_equal ({ code: '1000',
|
||||
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
|
||||
|
||||
|
@ -87,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
|
||||
|
||||
|
@ -98,7 +98,7 @@ class APINameserversPutTest < ApplicationIntegrationTest
|
|||
headers: { 'HTTP_AUTHORIZATION' => http_auth_key }
|
||||
|
||||
assert_response 400
|
||||
assert_equal ({ code: '2003',
|
||||
assert_equal ({ code: 2003,
|
||||
message: 'param is missing or the value is empty: hostname' }),
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue