added test for domain transfer iteraction

This commit is contained in:
oleghasjanov 2025-08-08 15:17:17 +03:00
parent 2620933543
commit 4d9c81f63b
17 changed files with 385 additions and 41 deletions

View file

@ -11,6 +11,7 @@ class ReppV1DomainsUpdateTest < ActionDispatch::IntegrationTest
end
def test_updates_transfer_code_for_domain
DNSValidator.stub :validate, { errors: [] } do
@auth_headers['Content-Type'] = 'application/json'
new_auth_code = 'aisdcbkabcsdnc'
@ -28,12 +29,14 @@ class ReppV1DomainsUpdateTest < ActionDispatch::IntegrationTest
assert_equal 'Command completed successfully', json[:message]
assert new_auth_code, @domain.auth_info
end
end
def test_domain_pending_update_on_registrant_change
Setting.request_confirmation_on_registrant_change_enabled = true
DNSValidator.stub :validate, { errors: [] } do
Setting.request_confirmation_on_registrant_change_enabled = true
@auth_headers['Content-Type'] = 'application/json'
@auth_headers['Content-Type'] = 'application/json'
new_registrant = contacts(:william)
refute @domain.registrant == new_registrant
@ -54,12 +57,14 @@ class ReppV1DomainsUpdateTest < ActionDispatch::IntegrationTest
refute @domain.registrant.code == new_registrant.code
assert @domain.statuses.include? DomainStatus::PENDING_UPDATE
end
end
def test_replaces_registrant_when_verified
Setting.request_confirmation_on_registrant_change_enabled = true
DNSValidator.stub :validate, { errors: [] } do
Setting.request_confirmation_on_registrant_change_enabled = true
@auth_headers['Content-Type'] = 'application/json'
@auth_headers['Content-Type'] = 'application/json'
new_registrant = contacts(:william)
refute @domain.registrant == new_registrant
old_transfer_code = @domain.transfer_code
@ -84,12 +89,14 @@ class ReppV1DomainsUpdateTest < ActionDispatch::IntegrationTest
refute_equal old_transfer_code, @domain.transfer_code
assert @domain.registrant.code == new_registrant.code
refute @domain.statuses.include? DomainStatus::PENDING_UPDATE
end
end
def test_adds_epp_error_when_reserved_pw_is_missing_for_disputed_domain
Dispute.create!(domain_name: @domain.name, password: '1234567890', starts_at: Time.zone.now, expires_at: Time.zone.now + 5.days)
DNSValidator.stub :validate, { errors: [] } do
Dispute.create!(domain_name: @domain.name, password: '1234567890', starts_at: Time.zone.now, expires_at: Time.zone.now + 5.days)
@auth_headers['Content-Type'] = 'application/json'
@auth_headers['Content-Type'] = 'application/json'
payload = {
domain: {
reserved_pw: nil,
@ -102,12 +109,14 @@ class ReppV1DomainsUpdateTest < ActionDispatch::IntegrationTest
assert_response :bad_request
assert_equal 2304, json[:code]
assert_equal 'Required parameter missing; reservedpw element required for dispute domains', json[:message]
end
end
def test_adds_epp_error_when_reserved_pw_is_invalid_for_disputed_domain
Dispute.create!(domain_name: @domain.name, password: '1234567890', starts_at: Time.zone.now, expires_at: Time.zone.now + 5.days)
DNSValidator.stub :validate, { errors: [] } do
Dispute.create!(domain_name: @domain.name, password: '1234567890', starts_at: Time.zone.now, expires_at: Time.zone.now + 5.days)
@auth_headers['Content-Type'] = 'application/json'
@auth_headers['Content-Type'] = 'application/json'
payload = {
domain: {
reserved_pw: 'invalid',
@ -120,6 +129,7 @@ class ReppV1DomainsUpdateTest < ActionDispatch::IntegrationTest
assert_response :bad_request
assert_equal 2202, json[:code]
assert_equal 'Invalid authorization information; invalid reserved>pw value', json[:message]
end
end
end