mirror of
https://github.com/internetee/registry.git
synced 2025-06-07 21:25:39 +02:00
parent
125bb4bb4a
commit
263cb2e123
3 changed files with 19 additions and 1 deletions
|
@ -23,6 +23,13 @@ module Repp
|
||||||
:bad_request)
|
:bad_request)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if new_contact.invalid?
|
||||||
|
error!({ error: { type: 'invalid_request_error',
|
||||||
|
param: 'new_contact_id',
|
||||||
|
message: 'New contact must be valid' } },
|
||||||
|
:bad_request)
|
||||||
|
end
|
||||||
|
|
||||||
if current_contact == new_contact
|
if current_contact == new_contact
|
||||||
error!({ error: { type: 'invalid_request_error',
|
error!({ error: { type: 'invalid_request_error',
|
||||||
message: 'New contact ID must be different from current' \
|
message: 'New contact ID must be different from current' \
|
||||||
|
|
2
test/fixtures/contacts.yml
vendored
2
test/fixtures/contacts.yml
vendored
|
@ -76,7 +76,7 @@ not_in_use:
|
||||||
|
|
||||||
invalid:
|
invalid:
|
||||||
name: any
|
name: any
|
||||||
code: any
|
code: invalid
|
||||||
email: invalid@invalid.test
|
email: invalid@invalid.test
|
||||||
auth_info: any
|
auth_info: any
|
||||||
registrar: bestnames
|
registrar: bestnames
|
||||||
|
|
|
@ -95,6 +95,17 @@ class APIDomainContactsTest < ActionDispatch::IntegrationTest
|
||||||
JSON.parse(response.body, symbolize_names: true)
|
JSON.parse(response.body, symbolize_names: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_disallow_invalid_new_contact
|
||||||
|
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
|
||||||
|
new_contact_id: 'invalid' },
|
||||||
|
{ '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' } }),
|
||||||
|
JSON.parse(response.body, symbolize_names: true)
|
||||||
|
end
|
||||||
|
|
||||||
def test_disallow_self_replacement
|
def test_disallow_self_replacement
|
||||||
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
|
patch '/repp/v1/domains/contacts', { current_contact_id: 'william-001',
|
||||||
new_contact_id: 'william-001' },
|
new_contact_id: 'william-001' },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue