From c0915e745c5016fa89481d7015217264ca270c36 Mon Sep 17 00:00:00 2001 From: oleghasjanov Date: Mon, 5 Aug 2024 14:15:01 +0300 Subject: [PATCH] rollback --- app/models/reserved_domain.rb | 9 +-------- app/validators/domain_name_validator.rb | 9 ++------- test/fixtures/reserved_domains.yml | 3 --- .../domain_names_controller_test.rb | 6 +++--- .../repp/v1/retained_domains_test.rb | 2 ++ test/models/reserved_domain_test.rb | 19 ------------------- .../get_invoice_number_test.rb | 8 ++++---- 7 files changed, 12 insertions(+), 44 deletions(-) diff --git a/app/models/reserved_domain.rb b/app/models/reserved_domain.rb index 43f6171d55..98ac0d46cb 100644 --- a/app/models/reserved_domain.rb +++ b/app/models/reserved_domain.rb @@ -6,7 +6,6 @@ class ReservedDomain < ApplicationRecord before_save :sync_dispute_password after_destroy :remove_data - before_validation :normalize_name, on: %w[create, update] validates :name, domain_name: true, uniqueness: true alias_attribute :registration_code, :password @@ -41,7 +40,7 @@ def new_password_for(name) end def name=(val) - super SimpleIDN.to_unicode(val).mb_chars.downcase.strip + super SimpleIDN.to_unicode(val) end def fill_empty_passwords @@ -70,10 +69,4 @@ def generate_data def remove_data UpdateWhoisRecordJob.perform_later name, 'reserved' end - - private - - def normalize_name - self.name = SimpleIDN.to_unicode(name).mb_chars.downcase.strip - end end diff --git a/app/validators/domain_name_validator.rb b/app/validators/domain_name_validator.rb index 5d95992ac1..5ca4e93a7f 100644 --- a/app/validators/domain_name_validator.rb +++ b/app/validators/domain_name_validator.rb @@ -2,11 +2,7 @@ class DomainNameValidator < ActiveModel::EachValidator # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/LineLength def validate_each(record, attribute, value) - origins = DNS::Zone.origins - - if origins.include?(value) - record.errors.add(:base, :domain_name_blocked) - elsif !self.class.validate_format(value) + if !self.class.validate_format(value) record.errors.add(attribute, options[:message] || record.errors.generate_message(attribute, :invalid)) elsif !self.class.validate_blocked(value) record.errors.add(:base, :domain_name_blocked) @@ -22,7 +18,7 @@ def validate_format(value) origins = DNS::Zone.origins # if someone tries to register an origin domain, let this validation pass # the error will be caught in blocked domains validator - return false unless origins.include?(value.split('.').last) + return true if origins.include?(value) general_domains = /(#{origins.join('|')})/ @@ -32,7 +28,6 @@ def validate_format(value) return false unless value.match?(regexp) value = SimpleIDN.to_unicode(value).mb_chars.downcase.strip - end unicode_chars = /\u00E4\u00F5\u00F6\u00FC\u0161\u017E/ # äõöüšž diff --git a/test/fixtures/reserved_domains.yml b/test/fixtures/reserved_domains.yml index 9d023c1c1a..a34e0a24fd 100644 --- a/test/fixtures/reserved_domains.yml +++ b/test/fixtures/reserved_domains.yml @@ -2,6 +2,3 @@ one: name: reserved.test password: reserved-001 -two: - name: company-name.test - password: company-002 diff --git a/test/integration/api/business_registry/domain_names_controller_test.rb b/test/integration/api/business_registry/domain_names_controller_test.rb index e558b7bea3..dfe72e7fe1 100644 --- a/test/integration/api/business_registry/domain_names_controller_test.rb +++ b/test/integration/api/business_registry/domain_names_controller_test.rb @@ -15,9 +15,9 @@ class Api::V1::BusinessRegistry::DomainNamesControllerTest < ActionDispatch::Int assert_response :success assert_equal @allowed_origins.first, response.headers['Access-Control-Allow-Origin'] json_response = JSON.parse(response.body) - assert_includes json_response['variants'], 'testcompany' - assert_includes json_response['variants'], 'test-company' - assert_includes json_response['variants'], 'test_company' + assert_includes json_response['variants'], 'testcompanyas' + assert_includes json_response['variants'], 'test-company-as' + assert_includes json_response['variants'], 'test_company_as' assert_includes json_response['variants'], "testcompany#{Time.current.year}" end diff --git a/test/integration/repp/v1/retained_domains_test.rb b/test/integration/repp/v1/retained_domains_test.rb index 814eabfc1e..cfdabfd20a 100644 --- a/test/integration/repp/v1/retained_domains_test.rb +++ b/test/integration/repp/v1/retained_domains_test.rb @@ -28,6 +28,8 @@ def test_get_index_with_type_parameter get repp_v1_retained_domains_path({ 'type' => 'reserved' }) response_json = JSON.parse(response.body, symbolize_names: true) + puts response_json + assert response_json[:count] == 1 expected_objects = [{ name: 'reserved.test', diff --git a/test/models/reserved_domain_test.rb b/test/models/reserved_domain_test.rb index be249d8282..2515a1e5d3 100644 --- a/test/models/reserved_domain_test.rb +++ b/test/models/reserved_domain_test.rb @@ -13,23 +13,4 @@ def test_aliases_registration_code_to_password reserved_domain = ReservedDomain.new(password: 'reserved-001') assert_equal 'reserved-001', reserved_domain.registration_code end - - def test_create_reserved_domain_with_punycode_name - reserved_domain = ReservedDomain.create(name: 'xn--4ca7aey.test') - assert reserved_domain.valid? - end - - def test_create_reserved_domain_with_unicode_name - reserved_domain = ReservedDomain.create(name: 'õäöü.test') - assert reserved_domain.valid? - end - - def test_cannot_create_the_same_domain_twicde_with_punycode_and_unicode - punycode_reserved_domain = ReservedDomain.new(name: 'xn--4ca7aey.test') - assert punycode_reserved_domain.valid? - punycode_reserved_domain.save && punycode_reserved_domain.reload - - unicode_reserved_domain = ReservedDomain.new(name: 'õäöü.test') - assert_not unicode_reserved_domain.valid? - end end diff --git a/test/services/eis_billing_system/get_invoice_number_test.rb b/test/services/eis_billing_system/get_invoice_number_test.rb index 869c15e3ae..78edb76cba 100644 --- a/test/services/eis_billing_system/get_invoice_number_test.rb +++ b/test/services/eis_billing_system/get_invoice_number_test.rb @@ -5,7 +5,7 @@ class GetInvoiceNumberTest < ActionDispatch::IntegrationTest setup do @original_base_url = ENV['eis_billing_system_base_url'] @original_billing_secret = ENV['billing_secret'] - ENV['eis_billing_system_base_url'] = 'https://test-billing.example.com' + ENV['eis_billing_system_base_url'] = 'http://eis_billing_system:3000' ENV['billing_secret'] = 'test_secret' end @@ -17,7 +17,7 @@ class GetInvoiceNumberTest < ActionDispatch::IntegrationTest test "call returns expected result" do expected_response = '{"invoice_number": "12345"}' - stub_request(:post, "https://test-billing.example.com/api/v1/invoice_generator/invoice_number_generator") + stub_request(:post, "http://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator") .to_return(status: 200, body: expected_response, headers: { 'Content-Type' => 'application/json' }) result = EisBilling::GetInvoiceNumber.call @@ -25,7 +25,7 @@ class GetInvoiceNumberTest < ActionDispatch::IntegrationTest assert_equal expected_response, result.body assert_equal '200', result.code - assert_requested :post, "https://test-billing.example.com/api/v1/invoice_generator/invoice_number_generator", { + assert_requested :post, "http://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator", { headers: { 'Content-Type' => 'application/json', 'Authorization' => /^Bearer .+$/ @@ -35,7 +35,7 @@ class GetInvoiceNumberTest < ActionDispatch::IntegrationTest end test "invoice_number_generator_url returns correct URL" do - expected_url = "https://test-billing.example.com/api/v1/invoice_generator/invoice_number_generator" + expected_url = "http://eis_billing_system:3000/api/v1/invoice_generator/invoice_number_generator" assert_equal expected_url, EisBilling::GetInvoiceNumber.send(:invoice_number_generator_url) end