mirror of
https://github.com/internetee/registry.git
synced 2025-07-27 21:16:12 +02:00
feat: add admin contact ident type validation
- Add new setting for allowed admin contact ident types - Add validation for admin contact ident types on domain create/update - Add UI controls for managing allowed ident types - Add tests for new validation rules - Update domain model to respect new settings The changes allow configuring which identification types (private person, organization, birthday) are allowed for administrative contacts. This is enforced when creating new domains or adding new admin contacts.
This commit is contained in:
parent
b641235bbd
commit
f2978599b4
12 changed files with 346 additions and 11 deletions
|
@ -9,6 +9,9 @@ class DomainTest < ActiveSupport::TestCase
|
|||
@original_max_admin_contact_count = Setting.admin_contacts_max_count
|
||||
@original_min_tech_contact_count = Setting.tech_contacts_min_count
|
||||
@original_max_tech_contact_count = Setting.tech_contacts_max_count
|
||||
@original_admin_contacts_required_for_org = Setting.admin_contacts_required_for_org
|
||||
@original_admin_contacts_required_for_minors = Setting.admin_contacts_required_for_minors
|
||||
@original_admin_contacts_allowed_ident_type = Setting.admin_contacts_allowed_ident_type
|
||||
end
|
||||
|
||||
teardown do
|
||||
|
@ -17,6 +20,9 @@ class DomainTest < ActiveSupport::TestCase
|
|||
Setting.admin_contacts_max_count = @original_max_admin_contact_count
|
||||
Setting.tech_contacts_min_count = @original_min_tech_contact_count
|
||||
Setting.tech_contacts_max_count = @original_max_tech_contact_count
|
||||
Setting.admin_contacts_required_for_org = @original_admin_contacts_required_for_org
|
||||
Setting.admin_contacts_required_for_minors = @original_admin_contacts_required_for_minors
|
||||
Setting.admin_contacts_allowed_ident_type = @original_admin_contacts_allowed_ident_type
|
||||
end
|
||||
|
||||
def test_valid_domain_is_valid
|
||||
|
@ -615,6 +621,42 @@ class DomainTest < ActiveSupport::TestCase
|
|||
assert domain.valid?
|
||||
end
|
||||
|
||||
def test_validates_admin_contact_required_for_org_based_on_setting
|
||||
domain = valid_domain
|
||||
domain.registrant.update!(ident_type: 'org')
|
||||
domain.reload
|
||||
|
||||
# When setting is true
|
||||
Setting.admin_contacts_required_for_org = true
|
||||
domain.admin_domain_contacts.clear
|
||||
assert domain.invalid?
|
||||
assert_includes domain.errors.full_messages,
|
||||
'Admin domain contacts Admin contacts count must be between 1-10'
|
||||
|
||||
# When setting is false
|
||||
Setting.admin_contacts_required_for_org = false
|
||||
domain.admin_domain_contacts.clear
|
||||
assert domain.valid?
|
||||
end
|
||||
|
||||
def test_validates_admin_contact_required_for_minors_based_on_setting
|
||||
domain = valid_domain
|
||||
domain.registrant.update!(ident_type: 'birthday', ident: '2010-07-05')
|
||||
domain.reload
|
||||
|
||||
# When setting is true
|
||||
Setting.admin_contacts_required_for_minors = true
|
||||
domain.admin_domain_contacts.clear
|
||||
assert domain.invalid?
|
||||
assert_includes domain.errors.full_messages,
|
||||
'Admin domain contacts Admin contacts count must be between 1-10'
|
||||
|
||||
# When setting is false
|
||||
Setting.admin_contacts_required_for_minors = false
|
||||
domain.admin_domain_contacts.clear
|
||||
assert domain.valid?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def valid_domain
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue