diff --git a/.codeclimate.yml b/.codeclimate.yml index 77b7917a2..4f803baf1 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -31,7 +31,7 @@ plugins: enabled: false rubocop: enabled: true - channel: rubocop-0-74 + channel: rubocop-1-18-3 checks: Rubocop/Style/ClassAndModuleChildren: enabled: false diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 1a986169e..4ff7d7e6f 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -17,7 +17,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-18.04] - ruby: [ 2.7 ] + ruby: [ 2.7, 3.0 ] runs-on: ${{ matrix.os }} continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }} steps: @@ -85,6 +85,10 @@ jobs: path: coverage/codeclimate.${{ matrix.ruby }}.json upload_coverage: + strategy: + fail-fast: false + matrix: + ruby: [ 2.7, 3.0 ] runs-on: ubuntu-18.04 env: @@ -102,7 +106,7 @@ jobs: - uses: actions/download-artifact@v2.0.10 with: - name: coverage-2.7 + name: coverage-${{ matrix.ruby }} path: coverage - name: Aggregate & upload results to Code Climate diff --git a/.ruby-version b/.ruby-version index a4dd9dba4..b50214693 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.4 +3.0.2 diff --git a/CHANGELOG.md b/CHANGELOG.md index c7aeedf78..319bf518e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +14.09.2021 +* New epp statuses to better control registry lock and enable dnssec on locked domains (currently disabled on production) [#2143](https://github.com/internetee/registry/issues/2143) + +13.09.2021 +* Upgrade Ruby to 3.0.2 [#2152](https://github.com/internetee/registry/pull/2152) + +06.09.2021 + 31.08.2021 * Fix for multiplied renew issue [#2135](https://github.com/internetee/registry/issues/2135) * Admin: filtering and search options for the invoices view [#2124](https://github.com/internetee/registry/issues/2124) diff --git a/Dockerfile b/Dockerfile index 97b0452e1..9c46182a3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM internetee/ruby:2.7-buster +FROM internetee/ruby:3.0-buster RUN mkdir -p /opt/webapps/app/tmp/pids WORKDIR /opt/webapps/app diff --git a/Gemfile b/Gemfile index 046c5dd92..0a9208904 100644 --- a/Gemfile +++ b/Gemfile @@ -5,8 +5,8 @@ gem 'active_interaction', '~> 4.0' gem 'apipie-rails', '~> 0.5.19' gem 'bootsnap', '>= 1.1.0', require: false gem 'iso8601', '0.13.0' # for dates and times -gem 'mime-types-data' gem 'mimemagic', '0.4.3' +gem 'mime-types-data' gem 'puma' gem 'rails', '~> 6.1.4' gem 'rest-client' @@ -29,22 +29,22 @@ gem 'nokogiri', '~> 1.12.4' # style gem 'bootstrap-sass', '~> 3.4' +gem 'cancancan' gem 'coderay', '1.1.3' # xml console visualize gem 'coffee-rails', '>= 5.0' +gem 'devise', '~> 4.8' gem 'jquery-rails' -gem 'selectize-rails', '0.12.6' # include selectize.js for select gem 'kaminari' gem 'sass-rails' gem 'select2-rails', '4.0.13' # for autocomplete -gem 'cancancan' -gem 'devise', '~> 4.8' +gem 'selectize-rails', '0.12.6' # include selectize.js for select # registry specfic gem 'data_migrate', '~> 7.0' gem 'dnsruby', '~> 1.61' gem 'isikukood' # for EE-id validation -gem 'simpleidn', '0.2.1' # For punycode gem 'money-rails' +gem 'simpleidn', '0.2.1' # For punycode gem 'whenever', '1.0.0', require: false # country listing @@ -62,22 +62,22 @@ gem 'omniauth-rails_csrf_protection' gem 'omniauth-tara', github: 'internetee/omniauth-tara' +gem 'airbrake' +gem 'daemons-rails', '1.2.1' gem 'epp', github: 'internetee/epp', branch: :master gem 'epp-xml', '1.2.0', github: 'internetee/epp-xml', branch: :master +gem 'jquery-ui-rails', '6.0.1' +gem 'pdfkit' gem 'que' -gem 'daemons-rails', '1.2.1' gem 'que-web' gem 'sidekiq' -gem 'pdfkit' -gem 'jquery-ui-rails', '6.0.1' -gem 'airbrake' gem 'company_register', github: 'internetee/company_register', branch: 'master' -gem 'e_invoice', github: 'internetee/e_invoice', branch: :master -gem 'lhv', github: 'internetee/lhv', branch: 'master' gem 'domain_name' +gem 'e_invoice', github: 'internetee/e_invoice', branch: :master gem 'haml', '~> 5.2' +gem 'lhv', github: 'internetee/lhv', branch: 'master' gem 'rexml' gem 'wkhtmltopdf-binary', '~> 0.12.5.1' diff --git a/app/controllers/admin/account_activities_controller.rb b/app/controllers/admin/account_activities_controller.rb index cf5c0dc81..ebd44e28e 100644 --- a/app/controllers/admin/account_activities_controller.rb +++ b/app/controllers/admin/account_activities_controller.rb @@ -25,13 +25,12 @@ module Admin @account_activities = @q.result.page(params[:page]).per(params[:results_per_page]) @count = @q.result.count - if params[:page] && params[:page].to_i > 1 - @sum = @q.result.limit(@account_activities.offset_value).sum(:sum) + - @b.result.where("account_activities.id NOT IN (#{@q.result.select(:id).to_sql})") - .sum(:sum) - else - @sum = @b.result.where("account_activities.id NOT IN (#{@q.result.select(:id).to_sql})").sum(:sum) - end + @sum = if params[:page] && params[:page].to_i > 1 + @q.result.limit(@account_activities.offset_value).sum(:sum) + + @b.result.where("account_activities.id NOT IN (#{@q.result.select(:id).to_sql})").sum(:sum) + else + @b.result.where("account_activities.id NOT IN (#{@q.result.select(:id).to_sql})").sum(:sum) + end respond_to do |format| format.html diff --git a/app/controllers/admin/admin_users_controller.rb b/app/controllers/admin/admin_users_controller.rb index 43faee693..b2691f15b 100644 --- a/app/controllers/admin/admin_users_controller.rb +++ b/app/controllers/admin/admin_users_controller.rb @@ -63,7 +63,12 @@ module Admin def admin_user_params params.require(:admin_user).permit(:username, - :password, :password_confirmation, :identity_code, :email, :country_code, { roles: [] }) + :password, + :password_confirmation, + :identity_code, + :email, + :country_code, + { roles: [] }) end end end diff --git a/app/controllers/admin/bank_statements_controller.rb b/app/controllers/admin/bank_statements_controller.rb index e286f7f65..f65b9f727 100644 --- a/app/controllers/admin/bank_statements_controller.rb +++ b/app/controllers/admin/bank_statements_controller.rb @@ -61,9 +61,9 @@ module Admin end def bank_statement_params - params.require(:bank_statement).permit(:bank_code, :iban, bank_transactions_attributes: [ - :description, :sum, :currency, :reference_no, :paid_at - ]) + params.require(:bank_statement).permit(:bank_code, :iban, bank_transactions_attributes: %i[ + description sum currency reference_no paid_at + ]) end end end diff --git a/app/controllers/admin/blocked_domains_controller.rb b/app/controllers/admin/blocked_domains_controller.rb index 7be85f6fb..268eaca73 100644 --- a/app/controllers/admin/blocked_domains_controller.rb +++ b/app/controllers/admin/blocked_domains_controller.rb @@ -43,7 +43,6 @@ module Admin end end - def blocked_domain_params params.require(:blocked_domain).permit(:name) end diff --git a/app/controllers/admin/contact_versions_controller.rb b/app/controllers/admin/contact_versions_controller.rb index 0271fe30b..f8b180a65 100644 --- a/app/controllers/admin/contact_versions_controller.rb +++ b/app/controllers/admin/contact_versions_controller.rb @@ -11,20 +11,22 @@ module Admin @versions = @q.result.page(params[:page]) search_params = params[:q].deep_dup - whereS = "1=1" + where_s = "1=1" search_params.each do |key, value| next if value.empty? - case key - when 'event' - whereS += " AND event = '#{value}'" - else - whereS += create_where_string(key, value) - end + + where_s += case key + when 'event' + " AND event = '#{value}'" + else + create_where_string(key, value) + end end versions = Version::ContactVersion.includes(:item).where(whereS).order(created_at: :desc, id: :desc) @q = versions.ransack(params[:q]) + @versions = @q.result.page(params[:page]) @versions = @versions.per(params[:results_per_page]) if params[:results_per_page].to_i.positive? diff --git a/app/controllers/admin/contacts_controller.rb b/app/controllers/admin/contacts_controller.rb index 0b25d1c1d..192b86242 100644 --- a/app/controllers/admin/contacts_controller.rb +++ b/app/controllers/admin/contacts_controller.rb @@ -9,7 +9,8 @@ module Admin params[:q] ||= {} search_params = params[:q].deep_dup - if search_params[:domain_contacts_type_in].is_a?(Array) && search_params[:domain_contacts_type_in].delete('registrant') + if search_params[:domain_contacts_type_in].is_a?(Array) && + search_params[:domain_contacts_type_in].delete('registrant') search_params[:registrant_domains_id_not_null] = 1 end diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb index f48698780..69ed33431 100644 --- a/app/controllers/admin/dashboard_controller.rb +++ b/app/controllers/admin/dashboard_controller.rb @@ -4,4 +4,4 @@ module Admin def show; end end -end \ No newline at end of file +end diff --git a/app/controllers/admin/domain_versions_controller.rb b/app/controllers/admin/domain_versions_controller.rb index ee2bbf67b..99e4415a7 100644 --- a/app/controllers/admin/domain_versions_controller.rb +++ b/app/controllers/admin/domain_versions_controller.rb @@ -21,27 +21,33 @@ module Admin search_params.delete(:registrar) end - whereS = "1=1" + where_s = "1=1" search_params.each do |key, value| next if value.empty? - case key - when 'event' - whereS += " AND event = '#{value}'" - when 'name' - whereS += " AND (object->>'name' ~* '#{value}' OR object_changes->>'name' ~* '#{value}')" - else - whereS += create_where_string(key, value) - end + + where_s += case key + when 'event' + " AND event = '#{value}'" + when 'name' + " AND (object->>'name' ~* '#{value}' OR object_changes->>'name' ~* '#{value}')" + else + create_where_string(key, value) + end end - whereS += " AND object->>'registrant_id' IN (#{registrants.map { |r| "'#{r.id.to_s}'" }.join ','})" if registrants.present? - whereS += " AND 1=0" if registrants == [] - whereS += " AND object->>'registrar_id' IN (#{registrars.map { |r| "'#{r.id.to_s}'" }.join ','})" if registrars.present? - whereS += " AND 1=0" if registrars == [] + if registrants.present? + where_s += " AND object->>'registrant_id' IN (#{registrants.map { |r| "'#{r.id}'" }.join ','})" + end + where_s += " AND 1=0" if registrants == [] + if registrars.present? + where_s += " AND object->>'registrar_id' IN (#{registrars.map { |r| "'#{r.id}'" }.join ','})" + end + where_s += " AND 1=0" if registrars == [] versions = Version::DomainVersion.includes(:item).where(whereS).order(created_at: :desc, id: :desc) @q = versions.ransack(params[:q]) + @versions = @q.result.page(params[:page]) @versions = @versions.per(params[:results_per_page]) if params[:results_per_page].to_i.positive? diff --git a/app/controllers/admin/domains_controller.rb b/app/controllers/admin/domains_controller.rb index 934d6370c..8a086027b 100644 --- a/app/controllers/admin/domains_controller.rb +++ b/app/controllers/admin/domains_controller.rb @@ -5,20 +5,19 @@ module Admin def index params[:q] ||= {} - if params[:statuses_contains] - domains = Domain.includes(:registrar, :registrant).where( - "domains.statuses @> ?::varchar[]", "{#{params[:statuses_contains].join(',')}}" - ) - else - domains = Domain.includes(:registrar, :registrant) - end + domains = if params[:statuses_contains] + Domain.includes(:registrar, :registrant).where( + "domains.statuses @> ?::varchar[]", "{#{params[:statuses_contains].join(',')}}" + ) + else + Domain.includes(:registrar, :registrant) + end normalize_search_parameters do @q = domains.ransack(params[:q]) @domains = @q.result.page(params[:page]) - if @domains.count == 1 && params[:q][:name_matches].present? - redirect_to [:admin, @domains.first] and return - elsif @domains.count == 0 && params[:q][:name_matches] !~ /^%.+%$/ + (redirect_to [:admin, @domains.first] and return if @domains.count == 1 && params[:q][:name_matches].present?) + if @domains.count.zero? && params[:q][:name_matches] !~ /^%.+%$/ # if we do not get any results, add wildcards to the name field and search again n_cache = params[:q][:name_matches] params[:q][:name_matches] = "%#{params[:q][:name_matches]}%" @@ -51,7 +50,7 @@ module Admin redirect_to [:admin, @domain] else build_associations - flash.now[:alert] = I18n.t('failed_to_update_domain') + ' ' + @domain.errors.full_messages.join(", ") + flash.now[:alert] = "#{I18n.t('failed_to_update_domain')} #{@domain.errors.full_messages.join(', ')}" render 'edit' end end diff --git a/app/controllers/admin/epp_logs_controller.rb b/app/controllers/admin/epp_logs_controller.rb index 96e9851dc..279ff1ab8 100644 --- a/app/controllers/admin/epp_logs_controller.rb +++ b/app/controllers/admin/epp_logs_controller.rb @@ -3,17 +3,25 @@ module Admin load_and_authorize_resource class: ApiLog::EppLog before_action :set_default_dates, only: [:index] + # rubocop:disable Metrics/MethodLength def index @q = ApiLog::EppLog.ransack(params[:q]) @q.sorts = 'id desc' if @q.sorts.empty? @epp_logs = @q.result - @epp_logs = @epp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_gteq])) if params[:q][:created_at_gteq].present? - @epp_logs = @epp_logs.where("extract(epoch from created_at) <= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_lteq])) if params[:q][:created_at_lteq].present? + if params[:q][:created_at_gteq].present? + @epp_logs = @epp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)", + Time.parse(params[:q][:created_at_gteq])) + end + if params[:q][:created_at_lteq].present? + @epp_logs = @epp_logs.where("extract(epoch from created_at) <= extract(epoch from ?::timestamp)", + Time.parse(params[:q][:created_at_lteq])) + end @epp_logs = @epp_logs.page(params[:page]) render_by_format('admin/epp_logs/index', 'epp_logs') end + # rubocop:enable Metrics/MethodLength def show @epp_log = ApiLog::EppLog.find(params[:id]) diff --git a/app/controllers/admin/invoices/delivery_controller.rb b/app/controllers/admin/invoices/delivery_controller.rb index b53f80269..f9edc952f 100644 --- a/app/controllers/admin/invoices/delivery_controller.rb +++ b/app/controllers/admin/invoices/delivery_controller.rb @@ -10,4 +10,4 @@ module Admin end end end -end \ No newline at end of file +end diff --git a/app/controllers/admin/repp_logs_controller.rb b/app/controllers/admin/repp_logs_controller.rb index 8efbd5292..028dbffc8 100644 --- a/app/controllers/admin/repp_logs_controller.rb +++ b/app/controllers/admin/repp_logs_controller.rb @@ -3,19 +3,27 @@ module Admin load_and_authorize_resource class: ApiLog::ReppLog before_action :set_default_dates, only: [:index] + # rubocop:disable Metrics/MethodLength def index @q = ApiLog::ReppLog.ransack(params[:q]) @q.sorts = 'id desc' if @q.sorts.empty? @repp_logs = @q.result - @repp_logs = @repp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_gteq])) if params[:q][:created_at_gteq].present? - @repp_logs = @repp_logs.where("extract(epoch from created_at) <= extract(epoch from ?::timestamp)", Time.parse(params[:q][:created_at_lteq])) if params[:q][:created_at_lteq].present? + if params[:q][:created_at_gteq].present? + @repp_logs = @repp_logs.where("extract(epoch from created_at) >= extract(epoch from ?::timestamp)", + Time.parse(params[:q][:created_at_gteq])) + end + if params[:q][:created_at_lteq].present? + @repp_logs = @repp_logs.where("extract(epoch from created_at) <= extract(epoch from ?::timestamp)", + Time.parse(params[:q][:created_at_lteq])) + end @repp_logs = @repp_logs.page(params[:page]) @count = @q.result.count @repp_logs = @repp_logs.per(params[:results_per_page]) if paginate? render_by_format('admin/repp_logs/index', 'repp_logs') end + # rubocop:enable Metrics/MethodLength def show @repp_log = ApiLog::ReppLog.find(params[:id]) diff --git a/app/controllers/admin/sessions_controller.rb b/app/controllers/admin/sessions_controller.rb index 57d702059..114022675 100644 --- a/app/controllers/admin/sessions_controller.rb +++ b/app/controllers/admin/sessions_controller.rb @@ -14,4 +14,4 @@ module Admin current_admin_user ? current_admin_user.id_role_username : 'anonymous' end end -end \ No newline at end of file +end diff --git a/app/controllers/api/v1/registrant/auth_controller.rb b/app/controllers/api/v1/registrant/auth_controller.rb index 728ef696d..f508ceb49 100644 --- a/app/controllers/api/v1/registrant/auth_controller.rb +++ b/app/controllers/api/v1/registrant/auth_controller.rb @@ -45,8 +45,7 @@ module Api def create_token(user) token_creator = AuthTokenCreator.create_with_defaults(user) - hash = token_creator.token_in_hash - hash + token_creator.token_in_hash end def check_ip_whitelist diff --git a/app/controllers/api/v1/registrant/confirms_controller.rb b/app/controllers/api/v1/registrant/confirms_controller.rb index 057400c8e..c500019ea 100644 --- a/app/controllers/api/v1/registrant/confirms_controller.rb +++ b/app/controllers/api/v1/registrant/confirms_controller.rb @@ -15,9 +15,7 @@ module Api current_registrant: serialized_registrant(@domain.registrant), } - unless delete_action? - res[:new_registrant] = serialized_registrant(@domain.pending_registrant) - end + res[:new_registrant] = serialized_registrant(@domain.pending_registrant) unless delete_action? render json: res, status: :ok end @@ -103,9 +101,10 @@ module Api end def verify_action - action = if params[:template] == 'change' + action = case params[:template] + when 'change' @domain.registrant_update_confirmable?(verify_params[:token]) - elsif params[:template] == 'delete' + when 'delete' @domain.registrant_delete_confirmable?(verify_params[:token]) end diff --git a/app/controllers/api/v1/registrant/contacts_controller.rb b/app/controllers/api/v1/registrant/contacts_controller.rb index 73bd98cba..30096ab8a 100644 --- a/app/controllers/api/v1/registrant/contacts_controller.rb +++ b/app/controllers/api/v1/registrant/contacts_controller.rb @@ -77,9 +77,7 @@ module Api render json: { errors: [{ address: [error_msg] }] }, status: :bad_request and return end - if ENV['fax_enabled'] == 'true' - contact.fax = params[:fax] if params[:fax].present? - end + contact.fax = params[:fax] if ENV['fax_enabled'] == 'true' && params[:fax].present? logger.debug "ENV['fax_enabled'] is set to #{ENV['fax_enabled']}" if ENV['fax_enabled'] != 'true' && params[:fax] diff --git a/app/controllers/concerns/deliverable.rb b/app/controllers/concerns/deliverable.rb index 0ceae0067..28ef23d8a 100644 --- a/app/controllers/concerns/deliverable.rb +++ b/app/controllers/concerns/deliverable.rb @@ -23,4 +23,4 @@ module Deliverable def find_invoice @invoice = Invoice.find(params[:invoice_id]) end -end \ No newline at end of file +end diff --git a/app/controllers/epp/base_controller.rb b/app/controllers/epp/base_controller.rb index 4e9c7e9cf..44e38fe1c 100644 --- a/app/controllers/epp/base_controller.rb +++ b/app/controllers/epp/base_controller.rb @@ -1,5 +1,5 @@ module Epp - class BaseController < ActionController::Base + class BaseController < ApplicationController class AuthorizationError < StandardError; end skip_before_action :verify_authenticity_token check_authorization @@ -303,16 +303,25 @@ module Epp if request_command == 'login' && frame.present? frame.gsub!(/pw>.+<\//, 'pw>[FILTERED]]+)>([^<])+<\/eis:legalDocument>/, "[FILTERED]") if frame.present? + if frame.present? + trimmed_request = frame.gsub(/]+)>([^<])+<\/eis:legalDocument>/, + "[FILTERED]") + end ApiLog::EppLog.create({ request: trimmed_request, request_command: request_command, request_successful: epp_errors.empty?, - request_object: resource ? "#{params[:epp_object_type]}: #{resource.class} - #{resource.id} - #{resource.name}" : params[:epp_object_type], + request_object: if resource + "#{params[:epp_object_type]}: #{resource.class} - "\ + "#{resource.id} - #{resource.name}" + else + params[:epp_object_type] + end, response: @response, api_user_name: @api_user.try(:username) || current_user.try(:username) || 'api-public', - api_user_registrar: @api_user.try(:registrar).try(:to_s) || current_user.try(:registrar).try(:to_s), + api_user_registrar: @api_user.try(:registrar).try(:to_s) || + current_user.try(:registrar).try(:to_s), ip: request.ip, uuid: request.uuid }) diff --git a/app/controllers/epp/domains_controller.rb b/app/controllers/epp/domains_controller.rb index d017fbcce..39e0d7af5 100644 --- a/app/controllers/epp/domains_controller.rb +++ b/app/controllers/epp/domains_controller.rb @@ -155,16 +155,78 @@ module Epp end def validate_update - if element_count('update > chg > registrant') > 0 - requires 'extension > extdata > legalDocument' if current_user.legaldoc_mandatory? + if element_count('update > chg > registrant').positive? && current_user.legaldoc_mandatory? + requires 'extension > extdata > legalDocument' end @prefix = 'update > update >' requires 'name' + dnskey_update_enabled if Feature.obj_and_extensions_statuses_enabled? + dnkey_update_prohibited if Feature.obj_and_extensions_statuses_enabled? status_editing_disabled end + def parsed_response_for_dnskey(value) + doc = Nokogiri::Slop params[:parsed_frame].css(value).to_html + + return true if doc.document.children.empty? + + store = [] + + if value == 'add' + doc.document.add.children.each_with_index do |x, i| + store << doc.document.add.children[i].name + end + elsif value == 'chg' + doc.document.chg.children.each_with_index do |x, i| + store << doc.document.chg.children[i].name + end + else + doc.document.rem.children.each_with_index do |x, i| + store << doc.document.rem.children[i].name + end + end + + return true if store.size == 1 and store[0] == "keyData" + + store.empty? + end + + def dnskey_update_enabled + find_domain + + if @domain.dnskey_update_enabled? && !params[:parsed_frame].css('update').empty? + flag = true + + flag = false unless parsed_response_for_dnskey('chg') + + if flag + flag = false unless parsed_response_for_dnskey('add') + end + + if flag + return if parsed_response_for_dnskey('rem') + end + + return epp_errors.add(:epp_errors, + code: '2304', + msg: "#{I18n.t(:object_status_prohibits_operation)} + :serverObjUpdateEnabled") + end + end + + def dnkey_update_prohibited + find_domain + + if @domain.extension_update_prohibited? && !params[:parsed_frame].css('keyData').empty? + return epp_errors.add(:epp_errors, + code: '2304', + msg: "#{I18n.t(:object_status_prohibits_operation)} + :serverExtensionUpdateProhibited") + end + end + def validate_delete @prefix = 'delete > delete >' requires 'name' diff --git a/app/controllers/epp/polls_controller.rb b/app/controllers/epp/polls_controller.rb index 3886d2382..a674bcd45 100644 --- a/app/controllers/epp/polls_controller.rb +++ b/app/controllers/epp/polls_controller.rb @@ -51,6 +51,7 @@ module Epp end handle_errors(@notification) and return unless @notification.mark_as_read + render_epp_response 'epp/poll/poll_ack' end diff --git a/app/controllers/epp/sessions_controller.rb b/app/controllers/epp/sessions_controller.rb index 7e540bb89..8d8b56e62 100644 --- a/app/controllers/epp/sessions_controller.rb +++ b/app/controllers/epp/sessions_controller.rb @@ -14,38 +14,31 @@ module Epp webclient_request = ENV['webclient_ips'].split(',').map(&:strip).include?(request.ip) if webclient_request && !Rails.env.test? && !Rails.env.development? client_md5 = Certificate.parse_md_from_string(request.env['HTTP_SSL_CLIENT_CERT']) - if ENV['cert_path'].blank? - raise 'webclient cert (cert_path) missing, registrar (r)epp disabled' - end + raise 'webclient cert (cert_path) missing, registrar (r)epp disabled' if ENV['cert_path'].blank? server_md5 = Certificate.parse_md_from_string(File.read(ENV['cert_path'])) if client_md5 != server_md5 msg = 'Authentication error; server closing connection (certificate is not valid)' epp_errors.add(:epp_errors, - msg: msg, - code: '2501') + msg: msg, code: '2501') success = false end end - if !Rails.env.development? && (!webclient_request && @api_user) - unless @api_user.pki_ok?(request.env['HTTP_SSL_CLIENT_CERT'], - request.env['HTTP_SSL_CLIENT_S_DN_CN']) - msg = 'Authentication error; server closing connection (certificate is not valid)' - epp_errors.add(:epp_errors, - msg: msg, - code: '2501') + if !Rails.env.development? && (!webclient_request && @api_user) && + !@api_user.pki_ok?(request.env['HTTP_SSL_CLIENT_CERT'], request.env['HTTP_SSL_CLIENT_S_DN_CN']) + msg = 'Authentication error; server closing connection (certificate is not valid)' + epp_errors.add(:epp_errors, + msg: msg, code: '2501') - success = false - end + success = false end if success && !@api_user msg = 'Authentication error; server closing connection (API user not found)' epp_errors.add(:epp_errors, - msg: msg, - code: '2501') + msg: msg, code: '2501') success = false end @@ -53,8 +46,7 @@ module Epp if success && !@api_user.try(:active) msg = 'Authentication error; server closing connection (API user is not active)' epp_errors.add(:epp_errors, - msg: msg, - code: '2501') + msg: msg, code: '2501') success = false end @@ -62,8 +54,7 @@ module Epp if success && @api_user.cannot?(:create, :epp_login) msg = 'Authentication error; server closing connection (API user does not have epp role)' epp_errors.add(:epp_errors, - msg: msg, - code: '2501') + msg: msg, code: '2501') success = false end @@ -71,8 +62,7 @@ module Epp if success && !ip_white? msg = 'Authentication error; server closing connection (IP is not whitelisted)' epp_errors.add(:epp_errors, - msg: msg, - code: '2501') + msg: msg, code: '2501') success = false end @@ -80,8 +70,7 @@ module Epp if success && EppSession.limit_reached?(@api_user.registrar) msg = 'Session limit exceeded; server closing connection (connection limit reached)' epp_errors.add(:epp_errors, - msg: msg, - code: '2502') + msg: msg, code: '2502') success = false end @@ -99,8 +88,7 @@ module Epp if already_authenticated epp_errors.add(:epp_errors, - msg: 'Command use error; Already authenticated', - code: 2002) + msg: 'Command use error; Already authenticated', code: 2002) handle_errors return end @@ -118,17 +106,15 @@ module Epp def ip_white? webclient_request = ENV['webclient_ips'].split(',').map(&:strip).include?(request.ip) return true if webclient_request - if @api_user - return false unless @api_user.registrar.api_ip_white?(request.ip) - end + return false if @api_user && !@api_user.registrar.api_ip_white?(request.ip) + true end def logout unless signed_in? epp_errors.add(:epp_errors, - code: 2201, - msg: 'Authorization error') + code: 2201, msg: 'Authorization error') handle_errors return end diff --git a/app/controllers/registrar/account_controller.rb b/app/controllers/registrar/account_controller.rb index 2f486dccc..a7d135659 100644 --- a/app/controllers/registrar/account_controller.rb +++ b/app/controllers/registrar/account_controller.rb @@ -31,4 +31,4 @@ class Registrar current_registrar_user.registrar.settings['balance_auto_reload'] end end -end \ No newline at end of file +end diff --git a/app/controllers/registrar/bulk_change_controller.rb b/app/controllers/registrar/bulk_change_controller.rb index af35c2d97..9cd00e6cc 100644 --- a/app/controllers/registrar/bulk_change_controller.rb +++ b/app/controllers/registrar/bulk_change_controller.rb @@ -89,7 +89,7 @@ class Registrar end def domain_ids_for_bulk_renew - params.dig('domain_ids')&.reject { |id| id.blank? } + params['domain_ids']&.reject { |id| id.blank? } end def renew_task(domains) diff --git a/app/controllers/registrar/contacts_controller.rb b/app/controllers/registrar/contacts_controller.rb index 1688ea89c..ec4ce5129 100644 --- a/app/controllers/registrar/contacts_controller.rb +++ b/app/controllers/registrar/contacts_controller.rb @@ -13,7 +13,8 @@ class Registrar search_params = params[:q].deep_dup - if search_params[:domain_contacts_type_in].is_a?(Array) && search_params[:domain_contacts_type_in].delete('registrant') + if search_params[:domain_contacts_type_in].is_a?(Array) && + search_params[:domain_contacts_type_in].delete('registrant') search_params[:registrant_domains_id_not_null] = 1 end diff --git a/app/controllers/registrar/domains_controller.rb b/app/controllers/registrar/domains_controller.rb index 864467e0d..e5ab59fa2 100644 --- a/app/controllers/registrar/domains_controller.rb +++ b/app/controllers/registrar/domains_controller.rb @@ -21,9 +21,7 @@ class Registrar current_domain_scope end - if params[:contacts_ident_eq] - domains = domains.where(contacts: { ident: params[:contacts_ident_eq] }) - end + domains = domains.where(contacts: { ident: params[:contacts_ident_eq] }) if params[:contacts_ident_eq] normalize_search_parameters do @q = domains.ransack(search_params.except(:contacts_ident_eq)) diff --git a/app/controllers/registrar/invoices/delivery_controller.rb b/app/controllers/registrar/invoices/delivery_controller.rb index bdee23799..8cdbb9196 100644 --- a/app/controllers/registrar/invoices/delivery_controller.rb +++ b/app/controllers/registrar/invoices/delivery_controller.rb @@ -10,4 +10,4 @@ class Registrar end end end -end \ No newline at end of file +end diff --git a/app/controllers/registrar/nameservers_controller.rb b/app/controllers/registrar/nameservers_controller.rb index cc3c27ad7..37d95dbe2 100644 --- a/app/controllers/registrar/nameservers_controller.rb +++ b/app/controllers/registrar/nameservers_controller.rb @@ -35,9 +35,7 @@ class Registrar notices = ["#{t('.replaced')}. #{t('.affected_domains')}: " \ "#{res[:data][:affected_domains].join(', ')}"] - if res[:data][:skipped_domains] - notices << "#{t('.skipped_domains')}: #{res[:data][:skipped_domains].join(', ')}" - end + notices << "#{t('.skipped_domains')}: #{res[:data][:skipped_domains].join(', ')}" if res[:data][:skipped_domains] notices.join(', ') end diff --git a/app/controllers/registrar/polls_controller.rb b/app/controllers/registrar/polls_controller.rb index 3e17bf2b7..dde4bb8ea 100644 --- a/app/controllers/registrar/polls_controller.rb +++ b/app/controllers/registrar/polls_controller.rb @@ -16,9 +16,7 @@ class Registrar end def destroy - @data = depp_current_user.request(@ex.poll(poll: { - value: '', attrs: { op: 'ack', msgID: params[:id] } - })) + @data = depp_current_user.request(@ex.poll(poll: { value: '', attrs: { op: 'ack', msgID: params[:id] } })) @results = @data.css('result') diff --git a/app/controllers/registrar/sessions_controller.rb b/app/controllers/registrar/sessions_controller.rb index ec7cda148..c73ed799b 100644 --- a/app/controllers/registrar/sessions_controller.rb +++ b/app/controllers/registrar/sessions_controller.rb @@ -30,22 +30,18 @@ class Registrar show_error and return end - if @depp_user.pki - unless @api_user.pki_ok?(request.env['HTTP_SSL_CLIENT_CERT'], - request.env['HTTP_SSL_CLIENT_S_DN_CN'], api: false) - @depp_user.errors.add(:base, :invalid_cert) - end + if @depp_user.pki && !@api_user.pki_ok?(request.env['HTTP_SSL_CLIENT_CERT'], + request.env['HTTP_SSL_CLIENT_S_DN_CN'], api: false) + @depp_user.errors.add(:base, :invalid_cert) end - if @depp_user.errors.none? - if @api_user.active? - sign_in_and_redirect(:registrar_user, @api_user) - else - @depp_user.errors.add(:base, :not_active) - show_error and return - end + show_error and return unless @depp_user.errors.none? + + if @api_user.active? + sign_in_and_redirect(:registrar_user, @api_user) else - show_error and return + @depp_user.errors.add(:base, :not_active) + show_error end end @@ -65,9 +61,7 @@ class Registrar possible_users = ApiUser.where(identity_code: idc) || User.new possible_users.each do |selected_user| - if selected_user.registrar.white_ips.registrar_area.include_ip?(request.ip) - return selected_user - end + return selected_user if selected_user.registrar.white_ips.registrar_area.include_ip?(request.ip) end end diff --git a/app/controllers/registrar/settings/balance_auto_reload_controller.rb b/app/controllers/registrar/settings/balance_auto_reload_controller.rb index ad970855a..d6ace12ef 100644 --- a/app/controllers/registrar/settings/balance_auto_reload_controller.rb +++ b/app/controllers/registrar/settings/balance_auto_reload_controller.rb @@ -49,4 +49,4 @@ class Registrar end end end -end \ No newline at end of file +end diff --git a/app/controllers/registrar/xml_consoles_controller.rb b/app/controllers/registrar/xml_consoles_controller.rb index fd6804159..a27e3e3ee 100644 --- a/app/controllers/registrar/xml_consoles_controller.rb +++ b/app/controllers/registrar/xml_consoles_controller.rb @@ -22,7 +22,7 @@ class Registrar def load_xml cl_trid = "#{depp_current_user.tag}-#{Time.zone.now.to_i}" - xml_dir_path = Rails.root + 'app/views/registrar/xml_consoles/epp_requests' + xml_dir_path = Rails.root.join('app/views/registrar/xml_consoles/epp_requests').to_s xml = File.read("#{xml_dir_path}/#{params[:obj]}/#{params[:epp_action]}.xml") xml = prepare_payload(xml, cl_trid) @@ -49,12 +49,12 @@ class Registrar when 'contact-ee' insert_prefix_and_version(xml, pref, '1.1') else - insert_prefix_and_version(xml, pref, '1.1') + insert_prefix_and_version(xml, pref, '1.2') end end def insert_prefix_and_version(xml, pref, version) - xml.gsub!('"' + pref.to_s + '"', + xml.gsub!("\"#{pref}\"", "\"#{Xsd::Schema.filename(for_prefix: pref.to_s, for_version: version)}\"") xml end diff --git a/app/controllers/repp/v1/base_controller.rb b/app/controllers/repp/v1/base_controller.rb index 37d4b95be..c29f2137f 100644 --- a/app/controllers/repp/v1/base_controller.rb +++ b/app/controllers/repp/v1/base_controller.rb @@ -74,7 +74,7 @@ module Repp render_epp_error end - def render_epp_error(status = :bad_request, data = {}) + def render_epp_error(status = :bad_request, **data) @epp_errors ||= ActiveModel::Errors.new(self) @epp_errors.add(:epp_errors, msg: 'Command failed', code: '2304') if data != {} diff --git a/app/controllers/repp/v1/contacts_controller.rb b/app/controllers/repp/v1/contacts_controller.rb index 92f89a160..c19ca3967 100644 --- a/app/controllers/repp/v1/contacts_controller.rb +++ b/app/controllers/repp/v1/contacts_controller.rb @@ -43,7 +43,7 @@ module Repp return end - render_success(create_update_success_body) + render_success(**create_update_success_body) end api :PUT, '/repp/v1/contacts/:contact_code' @@ -58,7 +58,7 @@ module Repp return end - render_success(create_update_success_body) + render_success(**create_update_success_body) end api :DELETE, '/repp/v1/contacts/:contact_code' @@ -89,13 +89,11 @@ module Repp return contacts.pluck(:code) unless details - contacts = contacts.map do |contact| + contacts.map do |contact| serializer = ::Serializers::Repp::Contact.new(contact, show_address: Contact.address_processing?) serializer.to_json end - - contacts end def opt_addr? diff --git a/app/controllers/repp/v1/domains/nameservers_controller.rb b/app/controllers/repp/v1/domains/nameservers_controller.rb index 044e36a20..6f76f9e99 100644 --- a/app/controllers/repp/v1/domains/nameservers_controller.rb +++ b/app/controllers/repp/v1/domains/nameservers_controller.rb @@ -53,7 +53,7 @@ module Repp end def nameserver_params - params.permit(:domain_id, nameservers: [[:hostname, :action, ipv4: [], ipv6: []]]) + params.permit(:domain_id, nameservers: [[:hostname, :action, { ipv4: [], ipv6: [] }]]) end end end diff --git a/app/controllers/repp/v1/domains_controller.rb b/app/controllers/repp/v1/domains_controller.rb index c228bd328..ea00a5561 100644 --- a/app/controllers/repp/v1/domains_controller.rb +++ b/app/controllers/repp/v1/domains_controller.rb @@ -223,7 +223,7 @@ module Repp params.require(:domain).permit(:name, :registrant, :period, :period_unit, :registrar, :transfer_code, :reserved_pw, dnskeys_attributes: [%i[flags alg protocol public_key]], - nameservers_attributes: [[:hostname, ipv4: [], ipv6: []]], + nameservers_attributes: [[:hostname, { ipv4: [], ipv6: [] }]], admin_contacts: [], tech_contacts: []) end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 80c16a5a4..3bf305c9a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -6,7 +6,7 @@ module ApplicationHelper def env_style return '' if unstable_env.nil? - "background-image: url(#{image_path(unstable_env.to_s + '.png')});" + "background-image: url(#{image_path("#{unstable_env}.png")});" end def ident_for(contact) @@ -110,7 +110,7 @@ module ApplicationHelper end def verified_email_span(verification) - content_tag(:span, verification.email, class: verified_email_class(verification)) + tag.span(verification.email, class: verified_email_class(verification)) end def verified_email_class(verification) diff --git a/app/helpers/object_versions_helper.rb b/app/helpers/object_versions_helper.rb index be8ef1217..dae357cf6 100644 --- a/app/helpers/object_versions_helper.rb +++ b/app/helpers/object_versions_helper.rb @@ -2,9 +2,7 @@ module ObjectVersionsHelper def attach_existing_fields(version, new_object) version.object_changes.to_h.each do |key, value| method_name = "#{key}=".to_sym - if new_object.respond_to?(method_name) - new_object.public_send(method_name, event_value(version, value)) - end + new_object.public_send(method_name, event_value(version, value)) if new_object.respond_to?(method_name) end end diff --git a/app/interactions/actions/contact_delete.rb b/app/interactions/actions/contact_delete.rb index 69f803f6e..0b104f076 100644 --- a/app/interactions/actions/contact_delete.rb +++ b/app/interactions/actions/contact_delete.rb @@ -1,10 +1,6 @@ module Actions class ContactDelete - attr_reader :contact - attr_reader :new_attributes - attr_reader :legal_document - attr_reader :ident - attr_reader :user + attr_reader :contact, :new_attributes, :legal_document, :ident, :user def initialize(contact, legal_document = nil) @legal_document = legal_document diff --git a/app/interactions/actions/contact_update.rb b/app/interactions/actions/contact_update.rb index e96ea8afb..f66aae805 100644 --- a/app/interactions/actions/contact_update.rb +++ b/app/interactions/actions/contact_update.rb @@ -1,10 +1,6 @@ module Actions class ContactUpdate - attr_reader :contact - attr_reader :new_attributes - attr_reader :legal_document - attr_reader :ident - attr_reader :user + attr_reader :contact, :new_attributes, :legal_document, :ident, :user def initialize(contact, new_attributes, legal_document, ident, user) @contact = contact diff --git a/app/interactions/actions/do_request.rb b/app/interactions/actions/do_request.rb index 5784beee3..96fa37544 100644 --- a/app/interactions/actions/do_request.rb +++ b/app/interactions/actions/do_request.rb @@ -6,14 +6,13 @@ module Actions end def call - response = if Rails.env.test? - do_test_request(@request, @uri) - elsif Rails.env.development? - do_dev_request(@request, @uri) - else - do_live_request(@request, @uri) - end - response + if Rails.env.test? + do_test_request(@request, @uri) + elsif Rails.env.development? + do_dev_request(@request, @uri) + else + do_live_request(@request, @uri) + end rescue StandardError, OpenURI::HTTPError => e Rails.logger.debug e.message end diff --git a/app/interactions/actions/domain_delete.rb b/app/interactions/actions/domain_delete.rb index d7fd3496a..7790c25a9 100644 --- a/app/interactions/actions/domain_delete.rb +++ b/app/interactions/actions/domain_delete.rb @@ -1,8 +1,6 @@ module Actions class DomainDelete - attr_reader :domain - attr_reader :params - attr_reader :user + attr_reader :domain, :params, :user def initialize(domain, params, user) @domain = domain diff --git a/app/interactions/actions/domain_renew.rb b/app/interactions/actions/domain_renew.rb index 66e29c940..b829de188 100644 --- a/app/interactions/actions/domain_renew.rb +++ b/app/interactions/actions/domain_renew.rb @@ -1,8 +1,6 @@ module Actions class DomainRenew - attr_reader :domain - attr_reader :params - attr_reader :user + attr_reader :domain, :params, :user def initialize(domain, params, user) @domain = domain diff --git a/app/interactions/actions/domain_transfer.rb b/app/interactions/actions/domain_transfer.rb index 4da078d78..f72f7b5d7 100644 --- a/app/interactions/actions/domain_transfer.rb +++ b/app/interactions/actions/domain_transfer.rb @@ -1,10 +1,6 @@ module Actions class DomainTransfer - attr_reader :domain - attr_reader :transfer_code - attr_reader :legal_document - attr_reader :ident - attr_reader :user + attr_reader :domain, :transfer_code, :legal_document, :ident, :user def initialize(domain, transfer_code, user) @domain = domain diff --git a/app/interactions/actions/domain_update.rb b/app/interactions/actions/domain_update.rb index 5165a68c8..40b7876f6 100644 --- a/app/interactions/actions/domain_update.rb +++ b/app/interactions/actions/domain_update.rb @@ -43,9 +43,7 @@ module Actions end def assign_new_registrant - unless params[:registrant][:code] - domain.add_epp_error('2306', nil, nil, %i[registrant cannot_be_missing]) - end + domain.add_epp_error('2306', nil, nil, %i[registrant cannot_be_missing]) unless params[:registrant][:code] regt = Registrant.find_by(code: params[:registrant][:code]) unless regt diff --git a/app/interactions/domains/bulk_renew/single_domain_renew.rb b/app/interactions/domains/bulk_renew/single_domain_renew.rb index 5ae3826cd..290d585f6 100644 --- a/app/interactions/domains/bulk_renew/single_domain_renew.rb +++ b/app/interactions/domains/bulk_renew/single_domain_renew.rb @@ -11,9 +11,7 @@ module Domains renewed_expire_time = prepare_renewed_expire_time in_transaction_with_retries do check_balance - success = domain.renew(renewed_expire_time: renewed_expire_time, - period: period, - unit: unit) + success = domain.renew(renewed_expire_time, period, unit) if success check_balance reduce_balance @@ -39,11 +37,11 @@ module Domains price: domain_pricelist) end - def in_transaction_with_retries + def in_transaction_with_retries(&block) if Rails.env.test? yield else - transaction_wrapper { yield } + transaction_wrapper(&block) end rescue ActiveRecord::StatementInvalid => e log_error e @@ -72,8 +70,9 @@ module Domains max_reg_time = 11.years.from_now if renewed_expire_time >= max_reg_time - domain.add_epp_error('2105', nil, nil, I18n.t('epp.domains.object_is_not_eligible_for_renewal', - max_date: max_reg_time.to_date.to_s(:db))) + domain.add_epp_error('2105', nil, nil, + I18n.t('epp.domains.object_is_not_eligible_for_renewal', + max_date: max_reg_time.to_date.to_s(:db))) end renewed_expire_time end diff --git a/app/interactions/domains/client_hold/base.rb b/app/interactions/domains/client_hold/base.rb index c3c626b79..30c6532c6 100644 --- a/app/interactions/domains/client_hold/base.rb +++ b/app/interactions/domains/client_hold/base.rb @@ -3,7 +3,7 @@ module Domains class Base < ActiveInteraction::Base def to_stdout(message) time = Time.zone.now.utc - STDOUT << "#{time} - #{message}\n" unless Rails.env.test? + $stdout << "#{time} - #{message}\n" unless Rails.env.test? end end end diff --git a/app/interactions/domains/expire_period/base.rb b/app/interactions/domains/expire_period/base.rb index 609196488..3ba8d8e3c 100644 --- a/app/interactions/domains/expire_period/base.rb +++ b/app/interactions/domains/expire_period/base.rb @@ -3,11 +3,11 @@ module Domains class Base < ActiveInteraction::Base def to_stdout(message) time = Time.zone.now.utc - STDOUT << "#{time} - #{message}\n" unless Rails.env.test? + $stdout << "#{time} - #{message}\n" unless Rails.env.test? end def logger - @logger ||= Logger.new(Rails.root.join('log', 'domain_expire_period.log')) + @logger ||= Logger.new(Rails.root.join('log/domain_expire_period.log')) end end end diff --git a/app/interactions/domains/expired_pendings/base.rb b/app/interactions/domains/expired_pendings/base.rb index 7faa32050..a13459586 100644 --- a/app/interactions/domains/expired_pendings/base.rb +++ b/app/interactions/domains/expired_pendings/base.rb @@ -3,7 +3,7 @@ module Domains class Base < ActiveInteraction::Base def to_stdout(message) time = Time.zone.now.utc - STDOUT << "#{time} - #{message}\n" unless Rails.env.test? + $stdout << "#{time} - #{message}\n" unless Rails.env.test? end end end diff --git a/app/interactions/domains/expired_pendings/clean_all.rb b/app/interactions/domains/expired_pendings/clean_all.rb index 1dbab266c..e5e8ec046 100644 --- a/app/interactions/domains/expired_pendings/clean_all.rb +++ b/app/interactions/domains/expired_pendings/clean_all.rb @@ -9,6 +9,7 @@ module Domains count = 0 expired_pending_domains.each do |domain| log_error(domain) && next unless need_to_be_cleared?(domain) + count += 1 Domains::ExpiredPendings::ProcessClean.run(domain: domain) end diff --git a/app/interactions/domains/force_delete_email/base.rb b/app/interactions/domains/force_delete_email/base.rb index 291dcd136..4078a7b3d 100644 --- a/app/interactions/domains/force_delete_email/base.rb +++ b/app/interactions/domains/force_delete_email/base.rb @@ -37,7 +37,7 @@ module Domains def added_additional_email_into_notes(domain) return if domain.status_notes[DomainStatus::FORCE_DELETE].include? email - domain.status_notes[DomainStatus::FORCE_DELETE].concat(' ' + email) + domain.status_notes[DomainStatus::FORCE_DELETE].concat(" #{email}") domain.save(validate: false) end diff --git a/app/interactions/domains/redemption_grace_period/base.rb b/app/interactions/domains/redemption_grace_period/base.rb index 5d1ede289..42c691fc5 100644 --- a/app/interactions/domains/redemption_grace_period/base.rb +++ b/app/interactions/domains/redemption_grace_period/base.rb @@ -3,7 +3,7 @@ module Domains class Base < ActiveInteraction::Base def to_stdout(message) time = Time.zone.now.utc - STDOUT << "#{time} - #{message}\n" unless Rails.env.test? + $stdout << "#{time} - #{message}\n" unless Rails.env.test? end end end diff --git a/app/interactions/domains/update_confirm/process_update_confirmed.rb b/app/interactions/domains/update_confirm/process_update_confirmed.rb index 734dbf5d8..62d3e4651 100644 --- a/app/interactions/domains/update_confirm/process_update_confirmed.rb +++ b/app/interactions/domains/update_confirm/process_update_confirmed.rb @@ -38,7 +38,7 @@ module Domains private def user_id - @user_id ||= domain.pending_json.dig('current_user_id') + @user_id ||= domain.pending_json['current_user_id'] end end end diff --git a/app/jobs/csync_job.rb b/app/jobs/csync_job.rb index 12a34c551..2cbada3de 100644 --- a/app/jobs/csync_job.rb +++ b/app/jobs/csync_job.rb @@ -5,7 +5,7 @@ class CsyncJob < ApplicationJob @store = {} @input_store = { secure: {}, insecure: {} } @results = {} - @logger = Rails.env.test? ? Rails.logger : Logger.new(STDOUT) + @logger = Rails.env.test? ? Rails.logger : Logger.new($stdout) generate ? generate_scanner_input : process_scanner_results @logger.info 'CsyncJob: Finished.' @@ -37,9 +37,7 @@ class CsyncJob < ApplicationJob def unqualification_reason(nss, key, result_types) return 'no CDNSKEY / nameservers reported different CDNSKEYs' unless key - if result_types.include? 'untrustworthy' - return 'current DNSSEC config invalid (required for rollover/delete)' - end + return 'current DNSSEC config invalid (required for rollover/delete)' if result_types.include? 'untrustworthy' "Nameserver(s) not reachable / invalid data (#{result_types.join(', ')})" unless nss end @@ -47,7 +45,7 @@ class CsyncJob < ApplicationJob def process_scanner_results scanner_results - @results.keys.each do |domain| + @results.each_key do |domain| begin next unless qualified_for_monitoring?(domain, @results[domain]) @@ -121,7 +119,7 @@ class CsyncJob < ApplicationJob end out_file.close - @logger.info 'CsyncJob Generate: Finished writing output to ' + ENV['cdns_scanner_input_file'] + @logger.info "CsyncJob Generate: Finished writing output to #{ENV['cdns_scanner_input_file']}" end def check_directory @@ -134,7 +132,7 @@ class CsyncJob < ApplicationJob end def create_input_lines(out_file, state) - @input_store[state].keys.each do |nameserver| + @input_store[state].each_key do |nameserver| domains = @input_store[state][nameserver].join(' ') next unless domains.length.positive? diff --git a/app/jobs/directo_invoice_forward_job.rb b/app/jobs/directo_invoice_forward_job.rb index e52caac20..43a537ade 100644 --- a/app/jobs/directo_invoice_forward_job.rb +++ b/app/jobs/directo_invoice_forward_job.rb @@ -44,9 +44,7 @@ class DirectoInvoiceForwardJob < ApplicationJob end def assign_monthly_numbers - if directo_counter_exceedable?(@client.invoices.count) - raise 'Directo Counter is going to be out of period!' - end + raise 'Directo Counter is going to be out of period!' if directo_counter_exceedable?(@client.invoices.count) min_directo = Setting.directo_monthly_number_min.presence.try(:to_i) directo_number = [Setting.directo_monthly_number_last.presence.try(:to_i), diff --git a/app/jobs/dispute_status_update_job.rb b/app/jobs/dispute_status_update_job.rb index a1596aecb..5e42f29e1 100644 --- a/app/jobs/dispute_status_update_job.rb +++ b/app/jobs/dispute_status_update_job.rb @@ -1,5 +1,5 @@ class DisputeStatusUpdateJob < ApplicationJob - def perform(logger: Logger.new(STDOUT)) + def perform(logger: Logger.new($stdout)) @logger = logger @backlog = { 'activated': 0, 'closed': 0, 'activate_fail': [], 'close_fail': [] } diff --git a/app/jobs/domain_expire_email_job.rb b/app/jobs/domain_expire_email_job.rb index 1aad4aed9..11bd41047 100644 --- a/app/jobs/domain_expire_email_job.rb +++ b/app/jobs/domain_expire_email_job.rb @@ -12,9 +12,9 @@ class DomainExpireEmailJob < ApplicationJob } if domain.force_delete_scheduled? - DomainExpireMailer.expired_soft(attrs).deliver_now + DomainExpireMailer.expired_soft(**attrs).deliver_now else - DomainExpireMailer.expired(attrs).deliver_now + DomainExpireMailer.expired(**attrs).deliver_now end end end diff --git a/app/jobs/migrate_before_force_delete_statuses_job.rb b/app/jobs/migrate_before_force_delete_statuses_job.rb index f65538d50..7e6a1e1c0 100644 --- a/app/jobs/migrate_before_force_delete_statuses_job.rb +++ b/app/jobs/migrate_before_force_delete_statuses_job.rb @@ -31,6 +31,6 @@ class MigrateBeforeForceDeleteStatusesJob < ApplicationJob end def logger - @logger ||= Logger.new(Rails.root.join('log', 'migrate_before_force_delete_statuses.log')) + @logger ||= Logger.new(Rails.root.join('log/migrate_before_force_delete_statuses.log')) end end diff --git a/app/jobs/migrate_statuses_to_domain_history_job.rb b/app/jobs/migrate_statuses_to_domain_history_job.rb index a1750c1e6..f35c986b6 100644 --- a/app/jobs/migrate_statuses_to_domain_history_job.rb +++ b/app/jobs/migrate_statuses_to_domain_history_job.rb @@ -31,6 +31,6 @@ class MigrateStatusesToDomainHistoryJob < ApplicationJob end def logger - @logger ||= Logger.new(Rails.root.join('log', 'migrate_statuses_to_domain_history.log')) + @logger ||= Logger.new(Rails.root.join('log/migrate_statuses_to_domain_history.log')) end end diff --git a/app/jobs/registrant_change_confirm_email_job.rb b/app/jobs/registrant_change_confirm_email_job.rb index 09cf0caa4..e92b11c22 100644 --- a/app/jobs/registrant_change_confirm_email_job.rb +++ b/app/jobs/registrant_change_confirm_email_job.rb @@ -13,7 +13,8 @@ class RegistrantChangeConfirmEmailJob < ApplicationJob private def log(domain) - message = "Send RegistrantChangeMailer#confirm email for domain #{domain.name} (##{domain.id}) to #{domain.registrant.email}" + message = 'Send RegistrantChangeMailer#confirm email for domain '\ + "#{domain.name} (##{domain.id}) to #{domain.registrant.email}" logger.info(message) end diff --git a/app/jobs/registrant_change_notice_email_job.rb b/app/jobs/registrant_change_notice_email_job.rb index cb0da5d06..545b0dfed 100644 --- a/app/jobs/registrant_change_notice_email_job.rb +++ b/app/jobs/registrant_change_notice_email_job.rb @@ -12,7 +12,8 @@ class RegistrantChangeNoticeEmailJob < ApplicationJob private def log(domain, new_registrant) - message = "Send RegistrantChangeMailer#notice email for domain #{domain.name} (##{domain.id}) to #{new_registrant.email}" + message = 'Send RegistrantChangeMailer#notice email for domain '\ + "#{domain.name} (##{domain.id}) to #{new_registrant.email}" logger.info(message) end diff --git a/app/jobs/send_e_invoice_job.rb b/app/jobs/send_e_invoice_job.rb index 4ef503d59..33a2745c6 100644 --- a/app/jobs/send_e_invoice_job.rb +++ b/app/jobs/send_e_invoice_job.rb @@ -1,7 +1,7 @@ class SendEInvoiceJob < ApplicationJob discard_on HTTPClient::TimeoutError - def perform(invoice_id, payable = true) + def perform(invoice_id, payable: true) logger.info "Started to process e-invoice for invoice_id #{invoice_id}" invoice = Invoice.find_by(id: invoice_id) return unless need_to_process_invoice?(invoice: invoice, payable: payable) diff --git a/app/jobs/verify_emails_job.rb b/app/jobs/verify_emails_job.rb index 0d3ec2078..1de244221 100644 --- a/app/jobs/verify_emails_job.rb +++ b/app/jobs/verify_emails_job.rb @@ -26,7 +26,7 @@ class VerifyEmailsJob < ApplicationJob end def logger - @logger ||= Logger.new(Rails.root.join('log', 'email_verification.log')) + @logger ||= Logger.new(Rails.root.join('log/email_verification.log')) end def log_success(verification) diff --git a/app/lib/to_stdout.rb b/app/lib/to_stdout.rb index eeab82c15..2a47a1677 100644 --- a/app/lib/to_stdout.rb +++ b/app/lib/to_stdout.rb @@ -1,6 +1,6 @@ class ToStdout def self.msg(message) time = Time.zone.now.utc - STDOUT << "#{time} - #{message}\n" unless Rails.env.test? + $stdout << "#{time} - #{message}\n" unless Rails.env.test? end end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 2fdb84366..ae15d0374 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,5 +1,5 @@ class ApplicationMailer < ActionMailer::Base - append_view_path Rails.root.join('app', 'views', 'mailers') + append_view_path Rails.root.join('app/views/mailers') layout 'mailer' def registrant_confirm_url(domain:, method:) diff --git a/app/mailers/contact_mailer.rb b/app/mailers/contact_mailer.rb index d8d722844..81d215386 100644 --- a/app/mailers/contact_mailer.rb +++ b/app/mailers/contact_mailer.rb @@ -14,4 +14,4 @@ class ContactMailer < ApplicationMailer def address_processing Contact.address_processing? end -end \ No newline at end of file +end diff --git a/app/models/ability.rb b/app/models/ability.rb index febde4e8b..baa26e4cb 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -58,7 +58,7 @@ class Ability can(:delete, Epp::Domain) { |d, pw| d.registrar_id == @user.registrar_id || d.transfer_code == pw } # Epp::Contact - can(:info, Epp::Contact) { |c, pw| c.registrar_id == @user.registrar_id || pw.blank? ? true : c.auth_info == pw } + can(:info, Epp::Contact) { |c, pw| c.registrar_id == @user.registrar_id || pw.blank? ? true : c.auth_info == pw } can(:view_full_info, Epp::Contact) { |c, pw| c.registrar_id == @user.registrar_id || c.auth_info == pw } can(:check, Epp::Contact) can(:create, Epp::Contact) diff --git a/app/models/account_activity.rb b/app/models/account_activity.rb index 432d444d8..05873a2a6 100644 --- a/app/models/account_activity.rb +++ b/app/models/account_activity.rb @@ -39,4 +39,3 @@ class AccountActivity < ApplicationRecord end end end - diff --git a/app/models/actions/contact_delete.rb b/app/models/actions/contact_delete.rb index 60d3252c4..6543cd191 100644 --- a/app/models/actions/contact_delete.rb +++ b/app/models/actions/contact_delete.rb @@ -1,10 +1,6 @@ module Actions class ContactDelete - attr_reader :contact - attr_reader :new_attributes - attr_reader :legal_document - attr_reader :ident - attr_reader :user + attr_reader :contact, :new_attributes, :legal_document, :ident, :user def initialize(contact, legal_document = nil) @legal_document = legal_document diff --git a/app/models/actions/contact_update.rb b/app/models/actions/contact_update.rb index 7ca7b6b04..929235c69 100644 --- a/app/models/actions/contact_update.rb +++ b/app/models/actions/contact_update.rb @@ -1,10 +1,6 @@ module Actions class ContactUpdate - attr_reader :contact - attr_reader :new_attributes - attr_reader :legal_document - attr_reader :ident - attr_reader :user + attr_reader :contact, :new_attributes, :legal_document, :ident, :user def initialize(contact, new_attributes, legal_document, ident, user) @contact = contact diff --git a/app/models/actions/domain_transfer.rb b/app/models/actions/domain_transfer.rb index 1ff9aafe9..75bb251c4 100644 --- a/app/models/actions/domain_transfer.rb +++ b/app/models/actions/domain_transfer.rb @@ -1,10 +1,6 @@ module Actions class DomainTransfer - attr_reader :domain - attr_reader :transfer_code - attr_reader :legal_document - attr_reader :ident - attr_reader :user + attr_reader :domain, :transfer_code, :legal_document, :ident, :user def initialize(domain, transfer_code, user) @domain = domain diff --git a/app/models/api_user.rb b/app/models/api_user.rb index 61dd12387..8ae131a6e 100644 --- a/app/models/api_user.rb +++ b/app/models/api_user.rb @@ -44,6 +44,7 @@ class ApiUser < User after_initialize :set_defaults def set_defaults return unless new_record? + self.active = true unless saved_change_to_active? end @@ -76,7 +77,7 @@ class ApiUser < User end def linked_with?(another_api_user) - another_api_user.identity_code == self.identity_code + another_api_user.identity_code == identity_code end private diff --git a/app/models/balance_auto_reload_types/threshold.rb b/app/models/balance_auto_reload_types/threshold.rb index e14f8886b..d55cb977a 100644 --- a/app/models/balance_auto_reload_types/threshold.rb +++ b/app/models/balance_auto_reload_types/threshold.rb @@ -2,8 +2,7 @@ module BalanceAutoReloadTypes class Threshold include ActiveModel::Model - attr_accessor :amount - attr_accessor :threshold + attr_accessor :amount, :threshold validates :amount, numericality: { greater_than_or_equal_to: :min_amount } validates :threshold, numericality: { greater_than_or_equal_to: 0 } @@ -22,4 +21,4 @@ module BalanceAutoReloadTypes self.class.name.demodulize.underscore end end -end \ No newline at end of file +end diff --git a/app/models/billing/price.rb b/app/models/billing/price.rb index cc42d643b..519d53001 100644 --- a/app/models/billing/price.rb +++ b/app/models/billing/price.rb @@ -9,7 +9,8 @@ module Billing validates :price, :valid_from, :operation_category, :duration, presence: true validates :operation_category, inclusion: { in: Proc.new { |price| price.class.operation_categories } } - validates :duration, inclusion: { in: Proc.new { |price| price.class.durations.values } }, if: :should_validate_duration? + validates :duration, inclusion: { in: Proc.new { |price| price.class.durations.values } }, + if: :should_validate_duration? alias_attribute :effect_time, :valid_from alias_attribute :expire_time, :valid_to diff --git a/app/models/billing/reference_no.rb b/app/models/billing/reference_no.rb index d164f7565..fbb9218c4 100644 --- a/app/models/billing/reference_no.rb +++ b/app/models/billing/reference_no.rb @@ -1,7 +1,7 @@ module Billing class ReferenceNo - REGEXP = /\A\d{2,20}\z/.freeze - MULTI_REGEXP = /(\d{2,20})/.freeze + REGEXP = /\A\d{2,20}\z/ + MULTI_REGEXP = /(\d{2,20})/ def self.generate base = Base.generate diff --git a/app/models/blocked_domain.rb b/app/models/blocked_domain.rb index 286345ea4..fb50a8b52 100644 --- a/app/models/blocked_domain.rb +++ b/app/models/blocked_domain.rb @@ -8,7 +8,7 @@ class BlockedDomain < ApplicationRecord class << self - def by_domain name + def by_domain(name) where(name: name) end end @@ -29,7 +29,7 @@ class BlockedDomain < ApplicationRecord def generate_json h = HashWithIndifferentAccess.new - h[:name] = self.name + h[:name] = name h[:status] = ['Blocked'] h end diff --git a/app/models/certificate.rb b/app/models/certificate.rb index 3bea9e9fc..8dabc1b5a 100644 --- a/app/models/certificate.rb +++ b/app/models/certificate.rb @@ -67,9 +67,7 @@ class Certificate < ApplicationRecord @cached_status = SIGNED - if parsed_crt.not_before > Time.zone.now.utc && parsed_crt.not_after < Time.zone.now.utc - @cached_status = EXPIRED - end + @cached_status = EXPIRED if parsed_crt.not_before > Time.zone.now.utc && parsed_crt.not_after < Time.zone.now.utc crl = OpenSSL::X509::CRL.new(File.open("#{ENV['crl_dir']}/crl.pem").read) return @cached_status unless crl.revoked.map(&:serial).include?(parsed_crt.serial) @@ -83,10 +81,11 @@ class Certificate < ApplicationRecord csr_file.rewind crt_file = Tempfile.new('client_crt') - _out, err, _st = Open3.capture3("openssl ca -config #{ENV['openssl_config_path']} -keyfile #{ENV['ca_key_path']} \ - -cert #{ENV['ca_cert_path']} \ - -extensions usr_cert -notext -md sha256 \ - -in #{csr_file.path} -out #{crt_file.path} -key '#{ENV['ca_key_password']}' -batch") + _out, err, _st = Open3.capture3('openssl', 'ca', '-config', ENV['openssl_config_path'], + '-keyfile', ENV['ca_key_path'], '-cert', ENV['ca_cert_path'], + '-extensions', 'usr_cert', '-notext', '-md sha256', + '-in', csr_file.path, '-out', crt_file.path, '-key', ENV['ca_key_password'], + '-batch') if err.match?(/Data Base Updated/) crt_file.rewind @@ -103,7 +102,7 @@ class Certificate < ApplicationRecord end logger.error(err) puts "Certificate sign issue: #{err.inspect}" if Rails.env.test? - return false + false end end @@ -112,7 +111,8 @@ class Certificate < ApplicationRecord crt_file.write(crt) crt_file.rewind - _out, err, _st = Open3.capture3("openssl ca -config #{ENV['openssl_config_path']} -keyfile #{ENV['ca_key_path']} \ + _out, err, _st = Open3.capture3("openssl ca -config #{ENV['openssl_config_path']} \ + -keyfile #{ENV['ca_key_path']} \ -cert #{ENV['ca_cert_path']} \ -revoke #{crt_file.path} -key '#{ENV['ca_key_password']}' -batch") @@ -134,7 +134,7 @@ class Certificate < ApplicationRecord class << self def tostdout(message) time = Time.zone.now.utc - STDOUT << "#{time} - #{message}\n" unless Rails.env.test? + $stdout << "#{time} - #{message}\n" unless Rails.env.test? end def update_crl diff --git a/app/models/certification_request.rb b/app/models/certification_request.rb index 1ea81c120..c3477ab35 100644 --- a/app/models/certification_request.rb +++ b/app/models/certification_request.rb @@ -1,3 +1,3 @@ class CertificationRequest extend ActiveModel::Translation -end \ No newline at end of file +end diff --git a/app/models/concerns/contact/archivable.rb b/app/models/concerns/contact/archivable.rb index ca2d19b1b..31f79395b 100644 --- a/app/models/concerns/contact/archivable.rb +++ b/app/models/concerns/contact/archivable.rb @@ -16,9 +16,7 @@ module Contact::Archivable end def archive(verified: false, notify: true, extra_log: false) - unless verified - raise 'Contact cannot be archived' unless archivable?(post: true) - end + raise 'Contact cannot be archived' if !verified && !archivable?(post: true) notify_registrar_about_archivation if notify write_to_registrar_log if extra_log @@ -35,9 +33,7 @@ module Contact::Archivable end def inactive? - if Version::DomainVersion.contact_unlinked_more_than?(contact_id: id, period: inactivity_period) - return true - end + return true if Version::DomainVersion.contact_unlinked_more_than?(contact_id: id, period: inactivity_period) Version::DomainVersion.was_contact_linked?(id) ? false : created_at <= inactivity_period.ago end @@ -47,7 +43,7 @@ module Contact::Archivable end def log(msg) - @log ||= Logger.new(STDOUT) + @log ||= Logger.new($stdout) @log.info(msg) end diff --git a/app/models/concerns/domain/expirable.rb b/app/models/concerns/domain/expirable.rb index 1710f9dcd..f8e06f89f 100644 --- a/app/models/concerns/domain/expirable.rb +++ b/app/models/concerns/domain/expirable.rb @@ -22,9 +22,7 @@ module Domain::Expirable def expirable? return false if expire_time > Time.zone.now - if statuses.include?(DomainStatus::EXPIRED) && outzone_at.present? && delete_date.present? - return false - end + return false if statuses.include?(DomainStatus::EXPIRED) && outzone_at.present? && delete_date.present? true end diff --git a/app/models/concerns/domain/force_delete.rb b/app/models/concerns/domain/force_delete.rb index b31b02eac..3fa3bf627 100644 --- a/app/models/concerns/domain/force_delete.rb +++ b/app/models/concerns/domain/force_delete.rb @@ -5,6 +5,9 @@ module Domain::ForceDelete DomainStatus::SERVER_RENEW_PROHIBITED, DomainStatus::SERVER_TRANSFER_PROHIBITED].freeze + HOLD_STATUSES = [DomainStatus::SERVER_HOLD, + DomainStatus::CLIENT_HOLD].freeze + included do store_accessor :force_delete_data, :force_delete_type, @@ -15,11 +18,6 @@ module Domain::ForceDelete lambda { where("(force_delete_data->>'contact_notification_sent_date') is null") } - - HOLD_STATUSES = [ - DomainStatus::SERVER_HOLD, - DomainStatus::CLIENT_HOLD, - ].freeze end class_methods do diff --git a/app/models/concerns/epp_errors.rb b/app/models/concerns/epp_errors.rb index 90d742609..cdb3c5d80 100644 --- a/app/models/concerns/epp_errors.rb +++ b/app/models/concerns/epp_errors.rb @@ -121,7 +121,7 @@ module EppErrors err = { code: code, msg: t } val = check_for_status(code, obj, val) err[:value] = { val: val, obj: obj } if val.present? - self.errors.add(:epp_errors, err) + errors.add(:epp_errors, **err) end def check_for_status(code, obj, val) diff --git a/app/models/concerns/registrar/book_keeping.rb b/app/models/concerns/registrar/book_keeping.rb index 710f48e3c..76535ce12 100644 --- a/app/models/concerns/registrar/book_keeping.rb +++ b/app/models/concerns/registrar/book_keeping.rb @@ -68,13 +68,10 @@ module Registrar::BookKeeping def finalize_invoice_line(line, price:, activity:, duration:) yearly = price.duration.in_years.to_i >= 1 - line['price'] = yearly ? (price.price.amount / price.duration.in_years.to_i) : price.price.amount line['description'] = description_in_language(price: price, yearly: yearly) - if duration.present? - add_product_timeframe(line: line, activity: activity, duration: duration) if duration > 1 - end + add_product_timeframe(line: line, activity: activity, duration: duration) if duration.present? && (duration > 1) line end diff --git a/app/models/concerns/user_events.rb b/app/models/concerns/user_events.rb index afce650fe..80775f256 100644 --- a/app/models/concerns/user_events.rb +++ b/app/models/concerns/user_events.rb @@ -5,26 +5,25 @@ module UserEvents # EPP requires a server defined creator ID, which should be registrar code if we have one def cr_id # try this, rebuild user for registrar before searching history? really? - registrar = self.creator.try(:registrar) + registrar = creator.try(:registrar) if registrar.present? # Did creator return a kind of User that has a registrar? registrar.code else - if self.versions.first.try(:object).nil? - changes = self.versions.first.try(:object_changes) + if versions.first.try(:object).nil? + changes = versions.first.try(:object_changes) cr_registrar_id = changes['registrar_id'].second if changes.present? else # untested, expected never to execute - cr_registrar_id = self.versions.first.object['registrar_id'] + cr_registrar_id = versions.first.object['registrar_id'] end if cr_registrar_id.present? Registrar.find(cr_registrar_id).code else # cr_id optional for domain, but required for contact; but we want something here anyway - self.creator_str || self.registrar.code # Fallback + creator_str || self.registrar.code # Fallback end end end end - end diff --git a/app/models/contact.rb b/app/models/contact.rb index ea422041e..f33c22c74 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -11,7 +11,7 @@ class Contact < ApplicationRecord include Contact::Archivable include EmailVerifable - belongs_to :original, class_name: self.name + belongs_to :original, class_name: 'Contact' belongs_to :registrar, required: true has_many :domain_contacts has_many :domains, through: :domain_contacts @@ -20,6 +20,7 @@ class Contact < ApplicationRecord has_many :actions, dependent: :destroy attr_accessor :legal_document_id + alias_attribute :kind, :ident_type alias_attribute :copy_from_id, :original_id # Old attribute name; for PaperTrail @@ -29,7 +30,7 @@ class Contact < ApplicationRecord } NAME_REGEXP = /([\u00A1-\u00B3\u00B5-\u00BF\u0021-\u0026\u0028-\u002C\u003A-\u0040]| - [\u005B-\u005F\u007B-\u007E\u2040-\u206F\u20A0-\u20BF\u2100-\u218F])/x.freeze + [\u005B-\u005F\u007B-\u007E\u2040-\u206F\u20A0-\u20BF\u2100-\u218F])/x validates :name, :email, presence: true validates :name, format: { without: NAME_REGEXP, message: :invalid }, if: -> { priv? } @@ -43,9 +44,9 @@ class Contact < ApplicationRecord validate :correct_email_format, if: proc { |c| c.will_save_change_to_email? } validates :code, - uniqueness: { message: :epp_id_taken }, - format: { with: /\A[\w\-\:\.\_]*\z/i, message: :invalid }, - length: { maximum: 100, message: :too_long_contact_code } + uniqueness: { message: :epp_id_taken }, + format: { with: /\A[\w\-\:\.\_]*\z/i, message: :invalid }, + length: { maximum: 100, message: :too_long_contact_code } validates_associated :identifier validate :validate_html @@ -164,7 +165,9 @@ class Contact < ApplicationRecord scope = all # all contacts has state ok, so no need to filter by it - scope = scope.where("NOT contacts.statuses && ?::varchar[]", "{#{(STATUSES - [OK, LINKED]).join(',')}}") if states.delete(OK) + if states.delete(OK) + scope = scope.where("NOT contacts.statuses && ?::varchar[]", "{#{(STATUSES - [OK, LINKED]).join(',')}}") + end scope = scope.linked if states.delete(LINKED) scope = scope.where("contacts.statuses @> ?::varchar[]", "{#{states.join(',')}}") if states.any? scope @@ -385,7 +388,6 @@ class Contact < ApplicationRecord self.email = email.to_s.strip end - # what we can do load firstly by registrant # if total is smaller than needed, the load more # we also need to sort by valid_to diff --git a/app/models/contact/address.rb b/app/models/contact/address.rb index f7a6cfdab..ca736c045 100644 --- a/app/models/contact/address.rb +++ b/app/models/contact/address.rb @@ -1,10 +1,6 @@ class Contact class Address - attr_reader :street - attr_reader :zip - attr_reader :city - attr_reader :state - attr_reader :country_code + attr_reader :street, :zip, :city, :state, :country_code def initialize(street, zip, city, state, country_code) @street = street @@ -22,4 +18,4 @@ class Contact (country_code == other.country_code) end end -end \ No newline at end of file +end diff --git a/app/models/contact/ident.rb b/app/models/contact/ident.rb index c2e1790f7..71d73f3b6 100644 --- a/app/models/contact/ident.rb +++ b/app/models/contact/ident.rb @@ -1,9 +1,7 @@ class Contact::Ident include ActiveModel::Model - attr_accessor :code - attr_accessor :type - attr_accessor :country_code + attr_accessor :code, :type, :country_code validates :code, presence: true validates :code, national_id: true, if: :national_id? diff --git a/app/models/csync_record.rb b/app/models/csync_record.rb index c31418364..0ce389e5c 100644 --- a/app/models/csync_record.rb +++ b/app/models/csync_record.rb @@ -122,7 +122,7 @@ class CsyncRecord < ApplicationRecord end def self.log - Rails.env.test? ? logger : Logger.new(STDOUT) + Rails.env.test? ? logger : Logger.new($stdout) end def validate_csync_action diff --git a/app/models/depp/contact.rb b/app/models/depp/contact.rb index 33b7545b7..7deb36562 100644 --- a/app/models/depp/contact.rb +++ b/app/models/depp/contact.rb @@ -34,10 +34,10 @@ module Depp org_name: params[:org_name], # address - street: params[:street], - city: params[:city], - zip: params[:zip], - state: params[:state], + street: params[:street], + city: params[:city], + zip: params[:zip], + state: params[:state], country_code: params[:country_code] ) end @@ -61,10 +61,10 @@ module Depp org_name: res.css('postalInfo org').text, # address - street: res.css('postalInfo addr street').text, - city: res.css('postalInfo addr city').text, - zip: res.css('postalInfo addr pc').text, - state: res.css('postalInfo addr sp').text, + street: res.css('postalInfo addr street').text, + city: res.css('postalInfo addr city').text, + zip: res.css('postalInfo addr pc').text, + state: res.css('postalInfo addr sp').text, country_code: res.css('postalInfo addr cc').text, # authInfo @@ -116,10 +116,11 @@ module Depp xml.with_indifferent_access end - def extract_disclosure_hash(cpd) # cpd = contact_params[:disclose] + # cpd = contact_params[:disclose] + def extract_disclosure_hash(cpd) return {} unless cpd - cpd = cpd.delete_if { |k, v| v if v != '1' && k == 'flag' } - cpd + + cpd.delete_if { |k, v| v if v != '1' && k == 'flag' } end def extract_info_disclosure(data) @@ -147,7 +148,7 @@ module Depp id: { value: code }, postalInfo: { name: { value: name }, - org: { value: org_name }, + org: { value: org_name }, }, voice: { value: phone }, email: { value: email } @@ -195,7 +196,7 @@ module Depp chg: { postalInfo: { name: { value: name }, - org: { value: org_name }, + org: { value: org_name }, }, voice: { value: phone }, email: { value: email }, @@ -240,7 +241,7 @@ module Depp ident = ident_xml[:_anonymus].try(:first) when :update # detect if any ident has changed, nb! ident and self.ident is not always same - if !(ident == self.ident && ident == self.ident_type && ident_country_code == self.ident_country_code) + unless ident == self.ident && ident == ident_type && ident_country_code == self.ident_country_code ident = ident_xml[:_anonymus].try(:first) end end diff --git a/app/models/depp/domain.rb b/app/models/depp/domain.rb index 398839f80..0df6ae2b1 100644 --- a/app/models/depp/domain.rb +++ b/app/models/depp/domain.rb @@ -109,11 +109,9 @@ module Depp period = params[:period].to_i.to_s period_unit = params[:period][-1].to_s - current_user.request(epp_xml.renew( - name: { value: params[:domain_name] }, - curExpDate: { value: params[:cur_exp_date] }, - period: { value: period, attrs: { unit: period_unit } } - )) + current_user.request(epp_xml.renew(name: { value: params[:domain_name] }, + curExpDate: { value: params[:cur_exp_date] }, + period: { value: period, attrs: { unit: period_unit } })) end def transfer(params) diff --git a/app/models/depp/user.rb b/app/models/depp/user.rb index babbd2868..60c6f6c3d 100644 --- a/app/models/depp/user.rb +++ b/app/models/depp/user.rb @@ -11,7 +11,7 @@ module Depp validate :validate_existance_in_server def initialize(args = {}) - args.each { |k, v| send(k.to_s + '=', v) } + args.each { |k, v| send("#{k}=", v) } end def server @@ -20,13 +20,13 @@ module Depp port = ENV['epp_port'] || '700' @server_cache ||= Epp::Server.new({ - server: ENV['epp_hostname'], - tag: tag, - password: password, - port: port, - cert: OpenSSL::X509::Certificate.new(client_cert), - key: OpenSSL::PKey::RSA.new(client_key) - }) + server: ENV['epp_hostname'], + tag: tag, + password: password, + port: port, + cert: OpenSSL::X509::Certificate.new(client_cert), + key: OpenSSL::PKey::RSA.new(client_key) + }) end def request(xml) diff --git a/app/models/dns/zone.rb b/app/models/dns/zone.rb index 6e18b84bb..fb54abd02 100644 --- a/app/models/dns/zone.rb +++ b/app/models/dns/zone.rb @@ -20,7 +20,7 @@ module DNS def self.generate_zonefile(origin) filename = "#{origin}.zone" - STDOUT << "#{Time.zone.now.utc} - Generating zonefile #{filename}\n" + $stdout << "#{Time.zone.now.utc} - Generating zonefile #{filename}\n" zf = ActiveRecord::Base.connection.execute( "select generate_zonefile('#{origin}')" @@ -28,7 +28,7 @@ module DNS File.open("#{ENV['zonefile_export_dir']}/#{filename}", 'w') { |f| f.write(zf) } - STDOUT << "#{Time.zone.now.utc} - Successfully generated zonefile #{filename}\n" + $stdout << "#{Time.zone.now.utc} - Successfully generated zonefile #{filename}\n" end def self.origins diff --git a/app/models/dnskey.rb b/app/models/dnskey.rb index 348bddde7..5fa1243f6 100644 --- a/app/models/dnskey.rb +++ b/app/models/dnskey.rb @@ -24,7 +24,8 @@ class Dnskey < ApplicationRecord end } - ALGORITHMS = Depp::Dnskey::ALGORITHMS.map {|pair| pair[1].to_s}.freeze # IANA numbers, single authority list + # IANA numbers, single authority list + ALGORITHMS = Depp::Dnskey::ALGORITHMS.map {|pair| pair[1].to_s}.freeze PROTOCOLS = %w(3) FLAGS = %w(0 256 257) # 256 = ZSK, 257 = KSK DS_DIGEST_TYPE = [1,2] @@ -75,13 +76,15 @@ class Dnskey < ApplicationRecord def validate_flags return if flags.blank? return if FLAGS.include?(flags.to_s) + errors.add(:flags, :invalid, values: "Valid flags are: #{FLAGS.join(', ')}") end def generate_digest return unless flags == 257 || flags == 256 # require ZoneFlag, but optional SecureEntryPoint + self.ds_alg = alg - self.ds_digest_type = Setting.ds_digest_type if self.ds_digest_type.blank? || !DS_DIGEST_TYPE.include?(ds_digest_type) + self.ds_digest_type = Setting.ds_digest_type if ds_digest_type.blank? || !DS_DIGEST_TYPE.include?(ds_digest_type) flags_hex = self.class.int_to_hex(flags) protocol_hex = self.class.int_to_hex(protocol) @@ -90,9 +93,10 @@ class Dnskey < ApplicationRecord hex = [domain.name_in_wire_format, flags_hex, protocol_hex, alg_hex, public_key_hex].join bin = self.class.hex_to_bin(hex) - if self.ds_digest_type == 1 + case ds_digest_type + when 1 self.ds_digest = Digest::SHA1.hexdigest(bin).upcase - elsif self.ds_digest_type == 2 + when 2 self.ds_digest = Digest::SHA256.hexdigest(bin).upcase end end @@ -109,11 +113,11 @@ class Dnskey < ApplicationRecord c = 0 wire_format.each_byte.with_index do |b, i| - if i.even? - c += b << 8 - else - c += b - end + c += if i.even? + b << 8 + else + b + end end self.ds_key_tag = ((c & 0xFFFF) + (c >> 16)) & 0xFFFF @@ -146,21 +150,21 @@ class Dnskey < ApplicationRecord end class << self - def int_to_hex(s) - s = s.to_s(16) - s.prepend('0') if s.length.odd? + def int_to_hex(num) + num = num.to_s(16) + num.prepend('0') if num.length.odd? end - def hex_to_bin(s) - s.scan(/../).map(&:hex).pack('c*') + def hex_to_bin(num) + num.scan(/../).map(&:hex).pack('c*') end - def bin_to_hex(s) - s.each_byte.map { |b| format('%02X', b) }.join + def bin_to_hex(num) + num.each_byte.map { |b| format('%02X', b) }.join end def pub_key_base64?(pub) - return unless pub&.is_a?(String) + return unless pub.is_a?(String) Base64.strict_encode64(Base64.strict_decode64(pub)) == pub rescue ArgumentError diff --git a/app/models/domain.rb b/app/models/domain.rb index 4686e270f..703bfadcf 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -13,9 +13,14 @@ class Domain < ApplicationRecord include Domain::Disputable include Domain::BulkUpdatable - attr_accessor :roles - - attr_accessor :legal_document_id + attr_accessor :roles, + :legal_document_id, + :is_admin, + :registrant_typeahead, + :update_me, + :epp_pending_update, + :epp_pending_delete, + :reserved_pw alias_attribute :on_hold_time, :outzone_at alias_attribute :outzone_time, :outzone_at @@ -27,16 +32,18 @@ class Domain < ApplicationRecord :admin_store_statuses_history # TODO: whois requests ip whitelist for full info for own domains and partial info for other domains - # TODO: most inputs should be trimmed before validatation, probably some global logic? + # TODO: most inputs should be trimmed before validation, probably some global logic? belongs_to :registrar, required: true belongs_to :registrant, required: true # TODO: should we user validates_associated :registrant here? has_many :admin_domain_contacts - accepts_nested_attributes_for :admin_domain_contacts, allow_destroy: true, reject_if: :admin_change_prohibited? + accepts_nested_attributes_for :admin_domain_contacts, + allow_destroy: true, reject_if: :admin_change_prohibited? has_many :tech_domain_contacts - accepts_nested_attributes_for :tech_domain_contacts, allow_destroy: true, reject_if: :tech_change_prohibited? + accepts_nested_attributes_for :tech_domain_contacts, + allow_destroy: true, reject_if: :tech_change_prohibited? def registrant_change_prohibited? statuses.include? DomainStatus::SERVER_REGISTRANT_CHANGE_PROHIBITED @@ -114,16 +121,12 @@ class Domain < ApplicationRecord validate :status_is_consistant def status_is_consistant has_error = (hold_status? && statuses.include?(DomainStatus::SERVER_MANUAL_INZONE)) - unless has_error - if (statuses & DELETE_STATUSES).any? - has_error = statuses.include? DomainStatus::SERVER_DELETE_PROHIBITED - end + if !has_error && (statuses & DELETE_STATUSES).any? + has_error = statuses.include? DomainStatus::SERVER_DELETE_PROHIBITED end errors.add(:domains, I18n.t(:object_status_prohibits_operation)) if has_error end - attr_accessor :is_admin - # Removed to comply new ForceDelete procedure # at https://github.com/internetee/registry/issues/1428#issuecomment-570561967 # @@ -204,12 +207,10 @@ class Domain < ApplicationRecord def statuses_uniqueness return if statuses.uniq == statuses + errors.add(:statuses, :taken) end - attr_accessor :registrant_typeahead, :update_me, - :epp_pending_update, :epp_pending_delete, :reserved_pw - self.ignored_columns = %w[legacy_id legacy_registrar_id legacy_registrant_id] def subordinate_nameservers @@ -220,6 +221,14 @@ class Domain < ApplicationRecord nameservers.select { |x| !x.hostname.end_with?(name) } end + def extension_update_prohibited? + statuses.include? DomainStatus::SERVER_EXTENSION_UPDATE_PROHIBITED + end + + def dnskey_update_enabled? + statuses.include? DomainStatus::SERVER_OBJ_UPDATE_PROHIBITED + end + def admin_change_prohibited? statuses.include? DomainStatus::SERVER_ADMIN_CHANGE_PROHIBITED end @@ -342,10 +351,10 @@ class Domain < ApplicationRecord # find by internationalized domain name # internet domain name => ascii or puny, but db::domains.name is unicode def self.find_by_idn(name) - domain = self.find_by_name name + domain = find_by(name: name) if domain.blank? && name.include?('-') unicode = SimpleIDN.to_unicode name # we have no index on domains.name_puny - domain = self.find_by_name unicode + domain = find_by(name: unicode) end domain end @@ -378,9 +387,7 @@ class Domain < ApplicationRecord return true unless Setting.days_to_renew_domain_before_expire != 0 # if you can renew domain at days_to_renew before domain expiration - if (expire_time.to_date - Time.zone.today) + 1 > Setting.days_to_renew_domain_before_expire - return false - end + return false if (expire_time.to_date - Time.zone.today) + 1 > Setting.days_to_renew_domain_before_expire true end @@ -423,9 +430,11 @@ class Domain < ApplicationRecord def pending_update! return true if pending_update? + self.epp_pending_update = true # for epp return true unless registrant_verification_asked? + pending_json_cache = pending_json token = registrant_verification_token asked_at = registrant_verification_asked_at @@ -582,20 +591,19 @@ class Domain < ApplicationRecord # special handling for admin changing status def admin_status_update(update) update_unless_locked_by_registrant(update) - update_not_by_locked_statuses(update) # check for deleted status statuses.each do |s| unless update.include? s case s - when DomainStatus::PENDING_DELETE - self.delete_date = nil - when DomainStatus::SERVER_MANUAL_INZONE # removal causes server hold to set - self.outzone_at = Time.zone.now if force_delete_scheduled? - when DomainStatus::EXPIRED # removal causes server hold to set - self.outzone_at = self.expire_time + 15.day - when DomainStatus::SERVER_HOLD # removal causes server hold to set - self.outzone_at = nil + when DomainStatus::PENDING_DELETE + self.delete_date = nil + when DomainStatus::SERVER_MANUAL_INZONE # removal causes server hold to set + self.outzone_at = Time.zone.now if force_delete_scheduled? + when DomainStatus::EXPIRED # removal causes server hold to set + self.outzone_at = expire_time + 15.day + when DomainStatus::SERVER_HOLD # removal causes server hold to set + self.outzone_at = nil end end end diff --git a/app/models/domain_status.rb b/app/models/domain_status.rb index 6210da2fa..d8d750799 100644 --- a/app/models/domain_status.rb +++ b/app/models/domain_status.rb @@ -9,6 +9,8 @@ class DomainStatus < ApplicationRecord # Requests to delete the object MUST be rejected. CLIENT_DELETE_PROHIBITED = 'clientDeleteProhibited' SERVER_DELETE_PROHIBITED = 'serverDeleteProhibited' + SERVER_EXTENSION_UPDATE_PROHIBITED = 'serverExtensionUpdateProhibited' + SERVER_OBJ_UPDATE_PROHIBITED = 'serverObjUpdateProhibited' # DNS delegation information MUST NOT be published for the object. CLIENT_HOLD = 'clientHold' @@ -80,10 +82,12 @@ class DomainStatus < ApplicationRecord CLIENT_DELETE_PROHIBITED, SERVER_DELETE_PROHIBITED, CLIENT_HOLD, SERVER_HOLD, CLIENT_RENEW_PROHIBITED, SERVER_RENEW_PROHIBITED, CLIENT_TRANSFER_PROHIBITED, SERVER_TRANSFER_PROHIBITED, CLIENT_UPDATE_PROHIBITED, SERVER_UPDATE_PROHIBITED, - INACTIVE, OK, PENDING_CREATE, PENDING_DELETE, PENDING_DELETE_CONFIRMATION, PENDING_RENEW, PENDING_TRANSFER, - PENDING_UPDATE, SERVER_MANUAL_INZONE, SERVER_REGISTRANT_CHANGE_PROHIBITED, - SERVER_ADMIN_CHANGE_PROHIBITED, SERVER_TECH_CHANGE_PROHIBITED, FORCE_DELETE, - DELETE_CANDIDATE, EXPIRED, DISPUTED, SERVER_RELEASE_PROHIBITED + INACTIVE, OK, PENDING_CREATE, PENDING_DELETE, PENDING_DELETE_CONFIRMATION, + PENDING_RENEW, PENDING_TRANSFER, PENDING_UPDATE, SERVER_MANUAL_INZONE, + SERVER_REGISTRANT_CHANGE_PROHIBITED, SERVER_ADMIN_CHANGE_PROHIBITED, + SERVER_TECH_CHANGE_PROHIBITED, FORCE_DELETE, DELETE_CANDIDATE, EXPIRED, DISPUTED, + SERVER_RELEASE_PROHIBITED, SERVER_EXTENSION_UPDATE_PROHIBITED, + SERVER_OBJ_UPDATE_PROHIBITED ].freeze CLIENT_STATUSES = [ @@ -94,28 +98,29 @@ class DomainStatus < ApplicationRecord SERVER_STATUSES = [ SERVER_DELETE_PROHIBITED, SERVER_HOLD, SERVER_RENEW_PROHIBITED, SERVER_TRANSFER_PROHIBITED, SERVER_UPDATE_PROHIBITED, SERVER_MANUAL_INZONE, SERVER_REGISTRANT_CHANGE_PROHIBITED, - SERVER_ADMIN_CHANGE_PROHIBITED, SERVER_TECH_CHANGE_PROHIBITED, SERVER_RELEASE_PROHIBITED + SERVER_ADMIN_CHANGE_PROHIBITED, SERVER_TECH_CHANGE_PROHIBITED, SERVER_RELEASE_PROHIBITED, + SERVER_EXTENSION_UPDATE_PROHIBITED, SERVER_OBJ_UPDATE_PROHIBITED ].freeze UPDATE_PROHIBIT_STATES = [ - DomainStatus::PENDING_DELETE_CONFIRMATION, - DomainStatus::CLIENT_UPDATE_PROHIBITED, - DomainStatus::SERVER_UPDATE_PROHIBITED, - DomainStatus::PENDING_CREATE, - DomainStatus::PENDING_UPDATE, - DomainStatus::PENDING_DELETE, - DomainStatus::PENDING_RENEW, - DomainStatus::PENDING_TRANSFER - ] + DomainStatus::PENDING_DELETE_CONFIRMATION, + DomainStatus::CLIENT_UPDATE_PROHIBITED, + DomainStatus::SERVER_UPDATE_PROHIBITED, + DomainStatus::PENDING_CREATE, + DomainStatus::PENDING_UPDATE, + DomainStatus::PENDING_DELETE, + DomainStatus::PENDING_RENEW, + DomainStatus::PENDING_TRANSFER + ].freeze DELETE_PROHIBIT_STATES = [ - DomainStatus::CLIENT_DELETE_PROHIBITED, - DomainStatus::SERVER_DELETE_PROHIBITED, - DomainStatus::PENDING_CREATE, - DomainStatus::PENDING_RENEW, - DomainStatus::PENDING_TRANSFER, - DomainStatus::PENDING_UPDATE, - DomainStatus::PENDING_DELETE + DomainStatus::CLIENT_DELETE_PROHIBITED, + DomainStatus::SERVER_DELETE_PROHIBITED, + DomainStatus::PENDING_CREATE, + DomainStatus::PENDING_RENEW, + DomainStatus::PENDING_TRANSFER, + DomainStatus::PENDING_UPDATE, + DomainStatus::PENDING_DELETE ].freeze def epp_code_map @@ -148,9 +153,8 @@ class DomainStatus < ApplicationRecord admin_statuses_map.map(&:second) end - def admin_statuses_map - [ + admin_statuses = [ ['Hold', SERVER_HOLD], ['ManualInzone', SERVER_MANUAL_INZONE], ['RenewProhibited', SERVER_RENEW_PROHIBITED], @@ -162,6 +166,13 @@ class DomainStatus < ApplicationRecord ['DeleteProhibited', SERVER_DELETE_PROHIBITED], ['ReleaseProhibited', SERVER_RELEASE_PROHIBITED], ] + + if Feature.obj_and_extensions_statuses_enabled? + admin_statuses << ['ExtensionUpdateProhibited', SERVER_EXTENSION_UPDATE_PROHIBITED] + admin_statuses << ['ObjUpdateProhibited', SERVER_OBJ_UPDATE_PROHIBITED] + end + + admin_statuses end def admin_not_deletable_statuses diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index 6bd5507b9..614be201b 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -98,8 +98,8 @@ class Epp::Contact < Contact return unless legal_document_data legal_documents.create( - document_type: legal_document_data[:type], - body: legal_document_data[:body] + document_type: legal_document_data[:type], + body: legal_document_data[:body] ) end @@ -108,9 +108,9 @@ class Epp::Contact < Contact return unless legal_document_data doc = LegalDocument.create( - documentable_type: Contact, - document_type: legal_document_data[:type], - body: legal_document_data[:body] + documentable_type: Contact, + document_type: legal_document_data[:type], + body: legal_document_data[:body] ) self.legal_documents = [doc] diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index 0b3f1ad7f..d434c843c 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -15,7 +15,8 @@ class Epp::Domain < Domain return true if is_transfer || is_renewal return unless update_prohibited? - stat = (statuses & (DomainStatus::UPDATE_PROHIBIT_STATES + DomainStatus::DELETE_PROHIBIT_STATES)).first + stat = (statuses & + (DomainStatus::UPDATE_PROHIBIT_STATES + DomainStatus::DELETE_PROHIBIT_STATES)).first add_epp_error('2304', 'status', stat, I18n.t(:object_status_prohibits_operation)) throw(:abort) end @@ -143,8 +144,8 @@ class Epp::Domain < Domain return end - if doc = attach_legal_document(::Deserializers::Xml::LegalDocument.new(frame).call) - frame.css("legalDocument").first.content = doc.path if doc&.persisted? + if doc = attach_legal_document(::Deserializers::Xml::LegalDocument.new(frame).call) && doc&.persisted? + frame.css("legalDocument").first.content = doc.path end if Setting.request_confirmation_on_domain_deletion_enabled && @@ -173,7 +174,7 @@ class Epp::Domain < Domain ### RENEW ### - def renew(renewed_expire_time:, period:, unit:) + def renew(renewed_expire_time, period, unit) @is_renewal = true add_renew_epp_errors unless renewable? @@ -215,7 +216,8 @@ class Epp::Domain < Domain return transfers.last if transfers.any? when 'request' return pending_transfer if pending_transfer - return query_transfer(frame, current_user) + + query_transfer(frame, current_user) when 'approve' return approve_transfer(frame, current_user) if pending_transfer when 'reject' @@ -307,10 +309,12 @@ class Epp::Domain < Domain begin return if cur_exp_date.to_date == valid_to.to_date rescue - add_epp_error('2306', 'curExpDate', cur_exp_date, I18n.t('errors.messages.epp_exp_dates_do_not_match')) + add_epp_error('2306', 'curExpDate', cur_exp_date, + I18n.t('errors.messages.epp_exp_dates_do_not_match')) return end - add_epp_error('2306', 'curExpDate', cur_exp_date, I18n.t('errors.messages.epp_exp_dates_do_not_match')) + add_epp_error('2306', 'curExpDate', cur_exp_date, + I18n.t('errors.messages.epp_exp_dates_do_not_match')) end ### ABILITIES ### @@ -322,10 +326,10 @@ class Epp::Domain < Domain return false end - begin + if (statuses & [DomainStatus::CLIENT_DELETE_PROHIBITED, DomainStatus::SERVER_DELETE_PROHIBITED]).any? errors.add(:base, :domain_status_prohibits_operation) return false - end if (statuses & [DomainStatus::CLIENT_DELETE_PROHIBITED, DomainStatus::SERVER_DELETE_PROHIBITED]).any? + end true end diff --git a/app/models/feature.rb b/app/models/feature.rb new file mode 100644 index 000000000..098949045 --- /dev/null +++ b/app/models/feature.rb @@ -0,0 +1,7 @@ +class Feature + def self.obj_and_extensions_statuses_enabled? + return false if ENV['obj_and_extensions_prohibited'] == 'false' + + ENV['obj_and_extensions_prohibited'] || false + end +end diff --git a/app/models/iban.rb b/app/models/iban.rb index 260aca827..395f61bfa 100644 --- a/app/models/iban.rb +++ b/app/models/iban.rb @@ -2,4 +2,4 @@ class Iban def self.max_length 34 end -end \ No newline at end of file +end diff --git a/app/models/inactive_contacts.rb b/app/models/inactive_contacts.rb index c7888e7d9..ddc8374cb 100644 --- a/app/models/inactive_contacts.rb +++ b/app/models/inactive_contacts.rb @@ -14,7 +14,7 @@ class InactiveContacts end def log(msg) - @log ||= Logger.new(STDOUT) + @log ||= Logger.new($stdout) @log.info(msg) end end diff --git a/app/models/invoice.rb b/app/models/invoice.rb index bb82d0fcb..df8b7aff8 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -12,22 +12,26 @@ class Invoice < ApplicationRecord has_many :payment_orders accepts_nested_attributes_for :items - - scope :all_columns, ->{select("invoices.*")} - scope :sort_due_date_column, ->{all_columns.select("CASE WHEN invoices.cancelled_at is not null THEN + # rubocop:disable Layout/LineLength + # rubocop:disable Style/MultilineBlockLayout + scope :all_columns, -> { select("invoices.*") } + scope :sort_due_date_column, -> { all_columns.select("CASE WHEN invoices.cancelled_at is not null THEN (invoices.cancelled_at + interval '100 year') ELSE - invoices.due_date END AS sort_due_date")} - scope :sort_by_sort_due_date_asc, ->{sort_due_date_column.order("sort_due_date ASC")} - scope :sort_by_sort_due_date_desc, ->{sort_due_date_column.order("sort_due_date DESC")} - scope :sort_receipt_date_column, ->{all_columns.includes(:account_activity).references(:account_activity).select(%Q{ + invoices.due_date END AS sort_due_date") + } + scope :sort_by_sort_due_date_asc, -> { sort_due_date_column.order("sort_due_date ASC") } + scope :sort_by_sort_due_date_desc, -> { sort_due_date_column.order("sort_due_date DESC") } + scope :sort_receipt_date_column, -> { all_columns.includes(:account_activity).references(:account_activity).select(%( CASE WHEN account_activities.created_at is not null THEN account_activities.created_at WHEN invoices.cancelled_at is not null THEN invoices.cancelled_at + interval '100 year' - ELSE NULL END AS sort_receipt_date })} - scope :sort_by_sort_receipt_date_asc, ->{sort_receipt_date_column.order("sort_receipt_date ASC")} - scope :sort_by_sort_receipt_date_desc, ->{sort_receipt_date_column.order("sort_receipt_date DESC")} + ELSE NULL END AS sort_receipt_date )) + } + scope :sort_by_sort_receipt_date_asc, -> { sort_receipt_date_column.order("sort_receipt_date ASC") } + scope :sort_by_sort_receipt_date_desc, -> { sort_receipt_date_column.order("sort_receipt_date DESC") } scope :overdue, -> { unpaid.non_cancelled.where('due_date < ?', Time.zone.today) } - + # rubocop:enable Layout/LineLength + # rubocop:enable Style/MultilineBlockLayout validates :due_date, :currency, :seller_name, :seller_iban, :buyer_name, :items, presence: true @@ -38,7 +42,7 @@ class Invoice < ApplicationRecord attribute :vat_rate, ::Type::VatRate.new def set_invoice_number - last_no = Invoice.order(number: :desc).limit(1).pluck(:number).first + last_no = Invoice.order(number: :desc).limit(1).pick(:number) if last_no && last_no >= Setting.invoice_number_min.to_i self.number = last_no + 1 @@ -91,8 +95,8 @@ class Invoice < ApplicationRecord read_attribute(:total) end - def each - items.each { |item| yield item } + def each(&block) + items.each(&block) end def as_pdf diff --git a/app/models/invoice/e_invoice_generator.rb b/app/models/invoice/e_invoice_generator.rb index d2963b93e..2361656a7 100644 --- a/app/models/invoice/e_invoice_generator.rb +++ b/app/models/invoice/e_invoice_generator.rb @@ -1,7 +1,6 @@ class Invoice class EInvoiceGenerator - attr_reader :invoice - attr_reader :payable + attr_reader :invoice, :payable def initialize(invoice, payable) @invoice = invoice diff --git a/app/models/invoice/vat_rate_calculator.rb b/app/models/invoice/vat_rate_calculator.rb index a1339e762..e09dcad0c 100644 --- a/app/models/invoice/vat_rate_calculator.rb +++ b/app/models/invoice/vat_rate_calculator.rb @@ -1,7 +1,6 @@ class Invoice class VatRateCalculator - attr_reader :registry - attr_reader :registrar + attr_reader :registry, :registrar def initialize(registry: Registry.current, registrar:) @registry = registry @@ -16,4 +15,4 @@ class Invoice end end end -end \ No newline at end of file +end diff --git a/app/models/legal_document.rb b/app/models/legal_document.rb index 07c50c5dc..cafd04af7 100644 --- a/app/models/legal_document.rb +++ b/app/models/legal_document.rb @@ -65,7 +65,6 @@ class LegalDocument < ApplicationRecord true end - def self.remove_duplicates start = Time.zone.now.to_f Rails.logger.info '-----> Removing legal documents duplicates' @@ -84,7 +83,8 @@ class LegalDocument < ApplicationRecord File.delete(new_legal.path) if File.exist?(new_legal.path) new_legal.update(path: orig_legal.path) count += 1 - Rails.logger.info "File #{new_legal.path} has been removed by Domain #{new_legal.documentable_id}. Document id: #{new_legal.id}" + Rails.logger.info "File #{new_legal.path} has been removed by Domain "\ + "#{new_legal.documentable_id}. Document id: #{new_legal.id}" end end @@ -107,7 +107,8 @@ class LegalDocument < ApplicationRecord File.delete(new_legal.path) if File.exist?(new_legal.path) new_legal.update(path: orig_legal.path) count += 1 - Rails.logger.info "File #{new_legal.path} has been removed by Contact #{new_legal.documentable_id}. Document id: #{new_legal.id}" + Rails.logger.info "File #{new_legal.path} has been removed by Contact "\ + "#{new_legal.documentable_id}. Document id: #{new_legal.id}" end end end diff --git a/app/models/nameserver.rb b/app/models/nameserver.rb index d19e1d548..75255eb89 100644 --- a/app/models/nameserver.rb +++ b/app/models/nameserver.rb @@ -38,18 +38,18 @@ class Nameserver < ApplicationRecord def epp_code_map { - '2302' => [ - [:hostname, :taken, { value: { obj: 'hostAttr', val: {'hostName': hostname} } }] - ], - '2005' => [ - [:hostname, :invalid, { value: { obj: 'hostAttr', val: hostname } }], - [:hostname, :puny_to_long, { value: { obj: 'hostAttr', val: hostname } }], - [:ipv4, :invalid, { value: { obj: 'hostAddr', val: ipv4 } }], - [:ipv6, :invalid, { value: { obj: 'hostAddr', val: ipv6 } }] - ], - '2003' => [ - %i[base ip_required], - ] + '2302' => [ + [:hostname, :taken, { value: { obj: 'hostAttr', val: { 'hostName': hostname } } }] + ], + '2005' => [ + [:hostname, :invalid, { value: { obj: 'hostAttr', val: hostname } }], + [:hostname, :puny_to_long, { value: { obj: 'hostAttr', val: hostname } }], + [:ipv4, :invalid, { value: { obj: 'hostAddr', val: ipv4 } }], + [:ipv6, :invalid, { value: { obj: 'hostAddr', val: ipv6 } }] + ], + '2003' => [ + %i[base ip_required], + ] } end @@ -63,11 +63,10 @@ class Nameserver < ApplicationRecord end class << self - def from_hash_params params + def from_hash_params(params) params = params.with_indifferent_access rel = all - rel = rel.where(hostname: params[:hostname]) - rel + rel.where(hostname: params[:hostname]) end def hostnames diff --git a/app/models/payment_order.rb b/app/models/payment_order.rb index 4317abb38..fd6684347 100644 --- a/app/models/payment_order.rb +++ b/app/models/payment_order.rb @@ -23,7 +23,7 @@ class PaymentOrder < ApplicationRecord supported = [] PAYMENT_METHODS.each do |method| - class_name = ('PaymentOrders::' + method.camelize).constantize + class_name = "PaymentOrders::#{method.camelize}".constantize raise(NoMethodError, class_name) unless class_name < PaymentOrder supported << class_name @@ -33,7 +33,7 @@ class PaymentOrder < ApplicationRecord end def self.new_with_type(type:, invoice:) - channel = ('PaymentOrders::' + type.camelize).constantize + channel = "PaymentOrders::#{type.camelize}".constantize PaymentOrder.new(type: channel, invoice: invoice) end @@ -55,7 +55,7 @@ class PaymentOrder < ApplicationRecord def self.supported_method?(name, shortname: false) some_class = if shortname - ('PaymentOrders::' + name.camelize).constantize + "PaymentOrders::#{name.camelize}".constantize else name.constantize end diff --git a/app/models/payment_orders/bank_link.rb b/app/models/payment_orders/bank_link.rb index c8714d245..5195c3604 100644 --- a/app/models/payment_orders/bank_link.rb +++ b/app/models/payment_orders/bank_link.rb @@ -104,9 +104,8 @@ module PaymentOrders def sign(data) private_key = OpenSSL::PKey::RSA.new(File.read(seller_certificate)) - signed_data = private_key.sign(OpenSSL::Digest::SHA1.new, data) - signed_data = Base64.encode64(signed_data).gsub(/\n|\r/, '') - signed_data + signed_data = private_key.sign(OpenSSL::Digest.new('SHA1'), data) + Base64.encode64(signed_data).gsub(/\n|\r/, '') end def calc_mac(fields) @@ -122,7 +121,7 @@ module PaymentOrders def verify_mac(data, mac) bank_public_key = OpenSSL::X509::Certificate.new(File.read(bank_certificate)).public_key - bank_public_key.verify(OpenSSL::Digest::SHA1.new, Base64.decode64(mac), data) + bank_public_key.verify(OpenSSL::Digest.new('SHA1'), Base64.decode64(mac), data) end def prepend_size(value) diff --git a/app/models/registrar.rb b/app/models/registrar.rb index 62c824f4f..18c549e41 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -28,7 +28,7 @@ class Registrar < ApplicationRecord validates :vat_rate, absence: true, if: :vat_liable_locally? validates :vat_rate, absence: true, if: -> { vat_liable_in_foreign_country? && vat_no? } validates :vat_rate, numericality: { greater_than_or_equal_to: 0, less_than: 100 }, - allow_nil: true + allow_nil: true attribute :vat_rate, ::Type::VatRate.new after_initialize :set_defaults @@ -105,7 +105,7 @@ class Registrar < ApplicationRecord .deliver_later(wait: 1.minute) end - SendEInvoiceJob.set(wait: 1.minute).perform_now(invoice.id, payable) + SendEInvoiceJob.set(wait: 1.minute).perform_now(invoice.id, payable: payable) invoice end diff --git a/app/models/registry.rb b/app/models/registry.rb index 38037c01b..68422a028 100644 --- a/app/models/registry.rb +++ b/app/models/registry.rb @@ -1,8 +1,7 @@ class Registry include ActiveModel::Model - attr_accessor :vat_rate - attr_accessor :vat_country + attr_accessor :vat_rate, :vat_country def self.current vat_rate = Setting.registry_vat_prc.to_d * 100 @@ -10,4 +9,4 @@ class Registry new(vat_rate: vat_rate, vat_country: vat_country) end -end \ No newline at end of file +end diff --git a/app/models/reserved_domain.rb b/app/models/reserved_domain.rb index 97fe84b72..5d585e5d9 100644 --- a/app/models/reserved_domain.rb +++ b/app/models/reserved_domain.rb @@ -37,7 +37,7 @@ class ReservedDomain < ApplicationRecord end def fill_empty_passwords - regenerate_password if self.password.blank? + regenerate_password if password.blank? end def regenerate_password diff --git a/app/models/user.rb b/app/models/user.rb index 18ab410d0..cca07ca14 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -8,7 +8,7 @@ class User < ApplicationRecord self.ignored_columns = %w[legacy_id] def id_role_username - "#{self.id}-#{self.class}: #{self.username}" + "#{id}-#{self.class}: #{username}" end def self.from_omniauth(omniauth_hash) diff --git a/app/models/white_ip.rb b/app/models/white_ip.rb index 38cee7b6b..7bbd8c18f 100644 --- a/app/models/white_ip.rb +++ b/app/models/white_ip.rb @@ -54,12 +54,8 @@ class WhiteIp < ApplicationRecord def ids_including(ip) ipv4 = ipv6 = [] - if check_ip4(ip).present? - ipv4 = select { |white_ip| check_ip4(white_ip.ipv4) === check_ip4(ip) } - end - if check_ip6(ip).present? - ipv6 = select { |white_ip| check_ip6(white_ip.ipv6) === check_ip6(ip) } - end + ipv4 = select { |white_ip| check_ip4(white_ip.ipv4) === check_ip4(ip) } if check_ip4(ip).present? + ipv6 = select { |white_ip| check_ip6(white_ip.ipv6) === check_ip6(ip) } if check_ip6(ip).present? (ipv4 + ipv6).pluck(:id).flatten.uniq end # rubocop:enable Style/CaseEquality diff --git a/app/models/whois_record.rb b/app/models/whois_record.rb index 9a6229fcb..8d30110b4 100644 --- a/app/models/whois_record.rb +++ b/app/models/whois_record.rb @@ -28,7 +28,7 @@ class WhoisRecord < ApplicationRecord end status_map = { - 'ok' => 'ok (paid and in zone)' + 'ok' => 'ok (paid and in zone)' } registrant = domain.registrant @@ -75,7 +75,7 @@ class WhoisRecord < ApplicationRecord h[:nameservers] = domain.nameservers.hostnames.uniq.select(&:present?) h[:nameservers_changed] = domain.nameservers.pluck(:updated_at).max.try(:to_s, :iso8601) - h[:dnssec_keys] = domain.dnskeys.map{|key| "#{key.flags} #{key.protocol} #{key.alg} #{key.public_key}" } + h[:dnssec_keys] = domain.dnskeys.map { |key| "#{key.flags} #{key.protocol} #{key.alg} #{key.public_key}" } h[:dnssec_changed] = domain.dnskeys.pluck(:updated_at).max.try(:to_s, :iso8601) rescue nil diff --git a/app/presenters/domain_presenter.rb b/app/presenters/domain_presenter.rb index 6ded9a30b..812881742 100644 --- a/app/presenters/domain_presenter.rb +++ b/app/presenters/domain_presenter.rb @@ -10,12 +10,12 @@ class DomainPresenter html = domain.name if domain.discarded? - label = view.content_tag(:span, 'deleteCandidate', class: 'label label-warning') + label = view.tag.span('deleteCandidate', class: 'label label-warning') html += " #{label}" end if domain.locked_by_registrant? - label = view.content_tag(:span, 'registryLock', class: 'label label-danger') + label = view.tag.span('registryLock', class: 'label label-danger') html += " #{label}" end @@ -78,12 +78,12 @@ class DomainPresenter private def schedule_force_delete_btn - view.content_tag(:a, view.t('admin.domains.force_delete_toggle_btn.schedule'), - class: 'dropdown-item', - data: { - toggle: 'modal', - target: '.domain-edit-force-delete-dialog', - }) + view.tag.a(view.t('admin.domains.force_delete_toggle_btn.schedule'), + class: 'dropdown-item', + data: { + toggle: 'modal', + target: '.domain-edit-force-delete-dialog', + }) end def cancel_force_delete_btn @@ -91,18 +91,17 @@ class DomainPresenter view.admin_domain_force_delete_path(domain), method: :delete, data: { - confirm: view.t('admin.domains.force_delete_toggle_btn.cancel_confirm'), + confirm: view.t('admin.domains.force_delete_toggle_btn.cancel_confirm'), }, class: 'dropdown-item' end def inactive_schedule_force_delete_btn - view.content_tag :button, view.t('admin.domains.force_delete_toggle_btn.schedule'), - title: view.t('admin.domains.force_delete_toggle_btn.unable_to_schedule'), - disabled: true, - class: 'dropdown-item' + view.tag.button(view.t('admin.domains.force_delete_toggle_btn.schedule'), + title: view.t('admin.domains.force_delete_toggle_btn.unable_to_schedule'), + disabled: true, + class: 'dropdown-item') end - attr_reader :domain - attr_reader :view + attr_reader :domain, :view end diff --git a/app/presenters/registrant_presenter.rb b/app/presenters/registrant_presenter.rb index 4adf698e6..e3ef9ba12 100644 --- a/app/presenters/registrant_presenter.rb +++ b/app/presenters/registrant_presenter.rb @@ -37,6 +37,5 @@ class RegistrantPresenter private - attr_reader :registrant - attr_reader :view + attr_reader :registrant, :view end diff --git a/app/presenters/registrar/domain_list_csv_presenter.rb b/app/presenters/registrar/domain_list_csv_presenter.rb index 5f32bd022..e38f3f54e 100644 --- a/app/presenters/registrar/domain_list_csv_presenter.rb +++ b/app/presenters/registrar/domain_list_csv_presenter.rb @@ -42,6 +42,5 @@ class Registrar::DomainListCsvPresenter CSV::Row.new([], row) end - attr_reader :domains - attr_reader :view + attr_reader :domains, :view end diff --git a/app/presenters/registrar_presenter.rb b/app/presenters/registrar_presenter.rb index 40d26f063..c349ea74b 100644 --- a/app/presenters/registrar_presenter.rb +++ b/app/presenters/registrar_presenter.rb @@ -26,6 +26,5 @@ class RegistrarPresenter private - attr_reader :registrar - attr_reader :view + attr_reader :registrar, :view end diff --git a/app/presenters/user_presenter.rb b/app/presenters/user_presenter.rb index 29aeaa187..809c9f78c 100644 --- a/app/presenters/user_presenter.rb +++ b/app/presenters/user_presenter.rb @@ -14,6 +14,5 @@ class UserPresenter user.roles.first end - attr_reader :user - attr_reader :view + attr_reader :user, :view end diff --git a/app/services/overdue_invoice_canceller.rb b/app/services/overdue_invoice_canceller.rb index 17401c9dd..b7fcfb7c4 100644 --- a/app/services/overdue_invoice_canceller.rb +++ b/app/services/overdue_invoice_canceller.rb @@ -1,6 +1,5 @@ class OverdueInvoiceCanceller - attr_reader :invoices - attr_reader :delay + attr_reader :invoices, :delay def initialize(invoices: Invoice.overdue, delay: self.class.delay) @invoices = invoices @@ -30,4 +29,4 @@ class OverdueInvoiceCanceller due_date_with_delay = invoice.due_date + delay due_date_with_delay.past? end -end \ No newline at end of file +end diff --git a/app/services/registrant_change.rb b/app/services/registrant_change.rb index fdee7654a..d9d298e97 100644 --- a/app/services/registrant_change.rb +++ b/app/services/registrant_change.rb @@ -15,6 +15,5 @@ class RegistrantChange RegistrantChangeMailer.accepted(domain: domain, old_registrant: old_registrant).deliver_now end - attr_reader :domain - attr_reader :old_registrant + attr_reader :domain, :old_registrant end diff --git a/app/validators/contact/ident/birth_date_validator.rb b/app/validators/contact/ident/birth_date_validator.rb index 38cfc98f9..93d7e0940 100644 --- a/app/validators/contact/ident/birth_date_validator.rb +++ b/app/validators/contact/ident/birth_date_validator.rb @@ -1,7 +1,4 @@ class Contact::Ident::BirthDateValidator < ActiveModel::Validator - VALID_BIRTH_DATE_FROM = Time.zone.today - 150.years - VALID_BIRTH_DATE_TO = Time.zone.tomorrow - def validate(record) record.errors.add(:code, :invalid_birth_date) if birth_date_wrong?(record) end @@ -11,16 +8,21 @@ class Contact::Ident::BirthDateValidator < ActiveModel::Validator def birth_date_wrong?(record) return unless record.birthday? - begin - Date.parse(record.code) - rescue ArgumentError - return true - end + return true if birth_date_format_wrong?(record.code) contact_ident_date = Date.parse(record.code) - valid_time_range = VALID_BIRTH_DATE_FROM...VALID_BIRTH_DATE_TO + date_from = Time.zone.today - 150.years + date_to = Time.zone.tomorrow + valid_time_range = date_from...date_to return if valid_time_range.cover?(contact_ident_date) true end + + def birth_date_format_wrong?(date) + Date.parse(date) + false + rescue ArgumentError + true + end end diff --git a/app/validators/domain_nameserver_validator.rb b/app/validators/domain_nameserver_validator.rb index 55ceb1c96..9603b924e 100644 --- a/app/validators/domain_nameserver_validator.rb +++ b/app/validators/domain_nameserver_validator.rb @@ -7,6 +7,6 @@ class DomainNameserverValidator < ActiveModel::EachValidator return if values.size.between?(min, max) association = options[:association] || attribute - record.errors.add(association, :out_of_range, { min: min, max: max }) + record.errors.add(association, :out_of_range, **{ min: min, max: max }) end end diff --git a/app/validators/object_count_validator.rb b/app/validators/object_count_validator.rb index d2d880fea..01d6a55f8 100644 --- a/app/validators/object_count_validator.rb +++ b/app/validators/object_count_validator.rb @@ -5,6 +5,6 @@ class ObjectCountValidator < ActiveModel::EachValidator return if values.size.between?(min, max) association = options[:association] || attribute - record.errors.add(association, :out_of_range, { min: min, max: max }) + record.errors.add(association, :out_of_range, **{ min: min, max: max }) end end diff --git a/app/views/epp/contacts/info.xml.builder b/app/views/epp/contacts/info.xml.builder index 053565c09..ba7acd632 100644 --- a/app/views/epp/contacts/info.xml.builder +++ b/app/views/epp/contacts/info.xml.builder @@ -65,9 +65,9 @@ xml.epp_head do xml.tag!('contact:crDate', @contact.created_at.try(:iso8601)) if @contact.updated_at > @contact.created_at - upID = @contact.updator.try(:registrar) - upID = upID.code if upID.present? # Did updator return a kind of User that has a registrar? - xml.tag!('contact:upID', upID) if upID.present? # optional upID + up_id = @contact.updator.try(:registrar) + up_id = up_id.code if up_id.present? # Did updator return a kind of User that has a registrar? + xml.tag!('contact:upID', up_id) if up_id.present? # optional upID xml.tag!('contact:upDate', @contact.updated_at.try(:iso8601)) end if can? :view_password, @contact, @password diff --git a/app/views/epp/domains/info.xml.builder b/app/views/epp/domains/info.xml.builder index 01641af8e..b154752e9 100644 --- a/app/views/epp/domains/info.xml.builder +++ b/app/views/epp/domains/info.xml.builder @@ -29,13 +29,9 @@ xml.epp_head do @nameservers.each do |x| xml.tag!('domain:hostAttr') do xml.tag!('domain:hostName', x.hostname) - if x.ipv4.present? - x.ipv4.each { |ip| xml.tag!('domain:hostAddr', ip, 'ip' => 'v4') } - end + x.ipv4.each { |ip| xml.tag!('domain:hostAddr', ip, 'ip' => 'v4') } if x.ipv4.present? - if x.ipv6.present? - x.ipv6.each { |ip| xml.tag!('domain:hostAddr', ip, 'ip' => 'v6') } - end + x.ipv6.each { |ip| xml.tag!('domain:hostAddr', ip, 'ip' => 'v6') } if x.ipv6.present? end end end diff --git a/app/views/epp/error.xml.builder b/app/views/epp/error.xml.builder index 609c323ff..72dd83e7d 100644 --- a/app/views/epp/error.xml.builder +++ b/app/views/epp/error.xml.builder @@ -7,7 +7,7 @@ xml.epp_head do xml.result('code' => x[:code]) do xml.msg(x[:msg], 'lang' => 'en') model_name = resource ? resource.model_name.singular.sub('epp_','') : controller.controller_name.singularize - prefix = model_name == 'poll' ? 'changePoll' : model_name + '-ee' + prefix = model_name == 'poll' ? 'changePoll' : "#{model_name}-ee" xml.value("xmlns:#{model_name}" => Xsd::Schema.filename(for_prefix: prefix)) do value = x[:value][:val] diff --git a/app/views/epp/poll/poll_req.xml.builder b/app/views/epp/poll/poll_req.xml.builder index 9f8173dea..a1f12fd65 100644 --- a/app/views/epp/poll/poll_req.xml.builder +++ b/app/views/epp/poll/poll_req.xml.builder @@ -9,10 +9,10 @@ xml.epp_head do xml.msg @notification.text end - if @notification.attached_obj_type == 'DomainTransfer' + if @notification.attached_obj_type == 'DomainTransfer' && @object xml.resData do xml << render('epp/domains/partials/transfer', builder: xml, dt: @object) - end if @object + end end if @notification.action&.contact || @notification.registry_lock? diff --git a/config/application.yml.sample b/config/application.yml.sample index 4bf0bb384..7d0cbc864 100644 --- a/config/application.yml.sample +++ b/config/application.yml.sample @@ -59,6 +59,7 @@ contact_org_enabled: 'false' # System default for legal document types is: pdf,asice,sce,asics,scs,adoc,edoc,bdoc,ddoc,zip,rar,gz,tar,7z,odt,doc,docx # legal_document_types: "pdf,asice,sce,asics,scs,adoc,edoc,bdoc,ddoc,zip,rar,gz,tar,7z,odt,doc,docx" +# obj_and_extensions_prohibited: 'true' # # REGISTRAR configuration (DEPP) diff --git a/config/initializers/load_schemas.rb b/config/initializers/load_schemas.rb index 1f34d58df..e07f08331 100644 --- a/config/initializers/load_schemas.rb +++ b/config/initializers/load_schemas.rb @@ -1 +1 @@ -EPP_ALL_SCHEMA = Nokogiri::XML::Schema(File.read('lib/schemas/all-ee-1.2.xsd')) +EPP_ALL_SCHEMA = Nokogiri::XML::Schema(File.read('lib/schemas/all-ee-1.3.xsd')) diff --git a/lib/auth_token/auth_token_creator.rb b/lib/auth_token/auth_token_creator.rb index 741cc3e8a..0c10b3fa8 100644 --- a/lib/auth_token/auth_token_creator.rb +++ b/lib/auth_token/auth_token_creator.rb @@ -1,9 +1,7 @@ class AuthTokenCreator DEFAULT_VALIDITY = 2.hours - attr_reader :user - attr_reader :key - attr_reader :expires_at + attr_reader :user, :key, :expires_at def self.create_with_defaults(user) new(user, Rails.application.config.secret_key_base, Time.now + DEFAULT_VALIDITY) @@ -24,7 +22,7 @@ class AuthTokenCreator end def encrypted_token - encryptor = OpenSSL::Cipher::AES.new(256, :CBC) + encryptor = OpenSSL::Cipher.new('aes-256-cbc') encryptor.encrypt # OpenSSL used to automatically shrink oversized keys, it does not do that any longer. diff --git a/lib/auth_token/auth_token_decryptor.rb b/lib/auth_token/auth_token_decryptor.rb index acd67be99..04a48fc18 100644 --- a/lib/auth_token/auth_token_decryptor.rb +++ b/lib/auth_token/auth_token_decryptor.rb @@ -1,8 +1,5 @@ class AuthTokenDecryptor - attr_reader :decrypted_data - attr_reader :token - attr_reader :key - attr_reader :user + attr_reader :decrypted_data, :token, :key, :user def self.create_with_defaults(token) new(token, Rails.application.config.secret_key_base) @@ -14,7 +11,7 @@ class AuthTokenDecryptor end def decrypt_token - decipher = OpenSSL::Cipher::AES.new(256, :CBC) + decipher = OpenSSL::Cipher.new('aes-256-cbc') decipher.decrypt # OpenSSL used to automatically shrink oversized keys, it does not do that any longer. diff --git a/lib/deserializers/xml/dnssec.rb b/lib/deserializers/xml/dnssec.rb index 562d05c7a..d0564c89c 100644 --- a/lib/deserializers/xml/dnssec.rb +++ b/lib/deserializers/xml/dnssec.rb @@ -46,9 +46,7 @@ module Deserializers @ds_data = [] # schema validation prevents both in the same parent node - if frame.css('dsData').present? - frame.css('dsData').each { |k| @ds_data << key_from_params(k, dsa: true) } - end + frame.css('dsData').each { |k| @ds_data << key_from_params(k, dsa: true) } if frame.css('dsData').present? if frame.css('all')&.text == 'true' keys_from_domain_name(domain_name) diff --git a/lib/deserializers/xml/domain_create.rb b/lib/deserializers/xml/domain_create.rb index 78642d892..2eef5240a 100644 --- a/lib/deserializers/xml/domain_create.rb +++ b/lib/deserializers/xml/domain_create.rb @@ -5,8 +5,7 @@ require 'deserializers/xml/dnssec' module Deserializers module Xml class DomainCreate - attr_reader :frame - attr_reader :registrar + attr_reader :frame, :registrar def initialize(frame, registrar) @frame = frame diff --git a/lib/gem_monkey_patches/i18n.rb b/lib/gem_monkey_patches/i18n.rb index 7d0613247..194a11733 100644 --- a/lib/gem_monkey_patches/i18n.rb +++ b/lib/gem_monkey_patches/i18n.rb @@ -6,7 +6,7 @@ module I18n def localize(object, options = {}) options.merge!({ default: '-' }) - object.present? ? original_localize(object, options) : '' + object.present? ? original_localize(object, **options) : '' end end end diff --git a/lib/schemas/all-ee-1.3.xsd b/lib/schemas/all-ee-1.3.xsd new file mode 100644 index 000000000..305cce231 --- /dev/null +++ b/lib/schemas/all-ee-1.3.xsd @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + Extensible Provisioning Protocol v1.0 + all schema's grouped together + + + + diff --git a/lib/schemas/domain-ee-1.2.xsd b/lib/schemas/domain-ee-1.2.xsd index 073986ac7..0420dd134 100644 --- a/lib/schemas/domain-ee-1.2.xsd +++ b/lib/schemas/domain-ee-1.2.xsd @@ -1,7 +1,7 @@ - + + diff --git a/lib/serializers/registrant_api/domain.rb b/lib/serializers/registrant_api/domain.rb index b087a3a88..8d7e765f2 100644 --- a/lib/serializers/registrant_api/domain.rb +++ b/lib/serializers/registrant_api/domain.rb @@ -81,12 +81,11 @@ module Serializers end def contacts(type) - contact_pool = begin - if type == :tech - domain.tech_contacts - elsif type == :admin - domain.admin_contacts - end + contact_pool = case type + when :tech + domain.tech_contacts + when :admin + domain.admin_contacts end array_of_contacts = [] diff --git a/lib/tasks/contacts/archive.rake b/lib/tasks/contacts/archive.rake index 9e9568f56..9dfc0f38a 100644 --- a/lib/tasks/contacts/archive.rake +++ b/lib/tasks/contacts/archive.rake @@ -26,7 +26,7 @@ namespace :contacts do end def log(msg) - @log ||= Logger.new(STDOUT) + @log ||= Logger.new($stdout) @log.info(msg) end end diff --git a/lib/tasks/dev/create_bank_transactions/create_bank_transactions.rake b/lib/tasks/dev/create_bank_transactions/create_bank_transactions.rake index 17b7586e2..5bc3aa65d 100644 --- a/lib/tasks/dev/create_bank_transactions/create_bank_transactions.rake +++ b/lib/tasks/dev/create_bank_transactions/create_bank_transactions.rake @@ -26,7 +26,7 @@ namespace :dev do http.ca_file = ENV['lhv_ca_file'] http.start do - response = http.post(api_base_uri.path + '/payment', request_body, request_headers) + response = http.post("#{api_base_uri.path}/payment", request_body, request_headers) if response.is_a?(Net::HTTPSuccess) puts 'Success' diff --git a/lib/tasks/invoices/cancel_overdue.rake b/lib/tasks/invoices/cancel_overdue.rake index 5b049d853..d3872ddeb 100644 --- a/lib/tasks/invoices/cancel_overdue.rake +++ b/lib/tasks/invoices/cancel_overdue.rake @@ -10,4 +10,4 @@ namespace :invoices do puts "Cancelled total: #{cancelled_invoice_count}" end -end \ No newline at end of file +end diff --git a/lib/tasks/invoices/process_payments.rake b/lib/tasks/invoices/process_payments.rake index 0d8f7c7d4..74646eae4 100644 --- a/lib/tasks/invoices/process_payments.rake +++ b/lib/tasks/invoices/process_payments.rake @@ -41,7 +41,7 @@ namespace :invoices do end def log(msg) - @log ||= Logger.new(STDOUT) + @log ||= Logger.new($stdout) @log.info(msg) end diff --git a/lib/tasks/registrars/reload_balance.rake b/lib/tasks/registrars/reload_balance.rake index d08f7fee3..937af45f7 100644 --- a/lib/tasks/registrars/reload_balance.rake +++ b/lib/tasks/registrars/reload_balance.rake @@ -29,4 +29,4 @@ namespace :registrars do puts "Invoiced total: #{invoiced_registrar_count}" end -end \ No newline at end of file +end diff --git a/lib/validators/iso8601_validator.rb b/lib/validators/iso8601_validator.rb index bbcf63798..37d82d5d0 100644 --- a/lib/validators/iso8601_validator.rb +++ b/lib/validators/iso8601_validator.rb @@ -1,8 +1,6 @@ class Iso8601Validator < ActiveModel::EachValidator def validate_each(record, attribute, value) - if options[:date_only] - record.errors.add(attribute, :invalid_iso8601_date) unless value =~ date_format - end + record.errors.add(attribute, :invalid_iso8601_date) if options[:date_only] && value !~ date_format end private diff --git a/lib/validators/phone_validator.rb b/lib/validators/phone_validator.rb index a2a91e9f7..b4b004031 100644 --- a/lib/validators/phone_validator.rb +++ b/lib/validators/phone_validator.rb @@ -6,9 +6,7 @@ class PhoneValidator < ActiveModel::EachValidator country_code = phone_parts.first subscriber_no = phone_parts.second - if zeros_only?(country_code) || zeros_only?(subscriber_no) - record.errors.add(attribute, :invalid) - end + record.errors.add(attribute, :invalid) if zeros_only?(country_code) || zeros_only?(subscriber_no) end private diff --git a/lib/xsd/schema.rb b/lib/xsd/schema.rb index b48237053..2f409c55b 100644 --- a/lib/xsd/schema.rb +++ b/lib/xsd/schema.rb @@ -3,8 +3,8 @@ module Xsd SCHEMA_PATH = 'lib/schemas/'.freeze BASE_URL = 'https://epp.tld.ee/schema/'.freeze - REGEX_PREFIX_WITH_DASH = /(?\w+-\w+)-(?\w.\w).xsd/.freeze - REGEX_PREFIX_WITHOUT_DASH = /(?\w+)-(?\w.\w).xsd/.freeze + REGEX_PREFIX_WITH_DASH = /(?\w+-\w+)-(?\w.\w).xsd/ + REGEX_PREFIX_WITHOUT_DASH = /(?\w+)-(?\w.\w).xsd/ PREFIXES = %w[ domain-ee @@ -82,8 +82,8 @@ module Xsd end def schemas_by_name - prefixes.each_with_object({}) do |prefix, hash| - hash[prefix] = xsd_schemas.select { |filename| prefix_check(prefix, filename) }.uniq.sort + prefixes.index_with do |prefix| + xsd_schemas.select { |filename| prefix_check(prefix, filename) }.uniq.sort end end diff --git a/test/integration/admin_area/domain_update_confirms_test.rb b/test/integration/admin_area/domain_update_confirms_test.rb index 3cd64a872..55b00005f 100644 --- a/test/integration/admin_area/domain_update_confirms_test.rb +++ b/test/integration/admin_area/domain_update_confirms_test.rb @@ -18,7 +18,7 @@ class AdminAreaBlockedDomainsIntegrationTest < JavaScriptApplicationSystemTestCa - + #{@domain.name} #{new_registrant.code} @@ -53,7 +53,7 @@ class AdminAreaBlockedDomainsIntegrationTest < JavaScriptApplicationSystemTestCa - + #{@domain.name} #{new_registrant.code} diff --git a/test/integration/epp/base_test.rb b/test/integration/epp/base_test.rb index 4aa89e1ed..400702b28 100644 --- a/test/integration/epp/base_test.rb +++ b/test/integration/epp/base_test.rb @@ -91,7 +91,7 @@ class EppBaseTest < EppTestCase - + #{domains(:shop).name} @@ -115,7 +115,7 @@ class EppBaseTest < EppTestCase - + #{domains(:shop).name} @@ -141,7 +141,7 @@ class EppBaseTest < EppTestCase - + #{domains(:shop).name} @@ -168,7 +168,7 @@ class EppBaseTest < EppTestCase - + #{domains(:shop).name} diff --git a/test/integration/epp/domain/base_test.rb b/test/integration/epp/domain/base_test.rb index 9b117f3d4..4e19dcd77 100644 --- a/test/integration/epp/domain/base_test.rb +++ b/test/integration/epp/domain/base_test.rb @@ -7,7 +7,7 @@ class EppDomainBaseTest < EppTestCase - + non-existent.test diff --git a/test/integration/epp/domain/check/auction_test.rb b/test/integration/epp/domain/check/auction_test.rb index ad134794a..df0430287 100644 --- a/test/integration/epp/domain/check/auction_test.rb +++ b/test/integration/epp/domain/check/auction_test.rb @@ -20,7 +20,7 @@ class EppDomainCheckAuctionTest < EppTestCase - + auction.test @@ -34,8 +34,8 @@ class EppDomainCheckAuctionTest < EppTestCase response_xml = Nokogiri::XML(response.body) assert_correct_against_schema response_xml assert_epp_response :completed_successfully - assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}")['avail'] - assert_equal 'Domain is at auction', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}").text + assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}")['avail'] + assert_equal 'Domain is at auction', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}").text end def test_idn_ascii_domain_is_unavailable_when_at_auction @@ -46,7 +46,7 @@ class EppDomainCheckAuctionTest < EppTestCase - + xn--pramiid-n2a.test @@ -60,8 +60,8 @@ class EppDomainCheckAuctionTest < EppTestCase response_xml = Nokogiri::XML(response.body) assert_correct_against_schema response_xml assert_epp_response :completed_successfully - assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}")['avail'] - assert_equal 'Domain is at auction', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}").text + assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}")['avail'] + assert_equal 'Domain is at auction', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}").text end def test_idn_unicode_domain_is_unavailable_when_at_auction @@ -72,7 +72,7 @@ class EppDomainCheckAuctionTest < EppTestCase - + püramiid.test @@ -86,8 +86,8 @@ class EppDomainCheckAuctionTest < EppTestCase response_xml = Nokogiri::XML(response.body) assert_correct_against_schema response_xml assert_epp_response :completed_successfully - assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}")['avail'] - assert_equal 'Domain is at auction', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}").text + assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}")['avail'] + assert_equal 'Domain is at auction', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}").text end def test_domain_is_unavailable_when_awaiting_payment @@ -98,7 +98,7 @@ class EppDomainCheckAuctionTest < EppTestCase - + auction.test @@ -112,8 +112,8 @@ class EppDomainCheckAuctionTest < EppTestCase response_xml = Nokogiri::XML(response.body) assert_correct_against_schema response_xml assert_epp_response :completed_successfully - assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}")['avail'] - assert_equal 'Awaiting payment', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}").text + assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}")['avail'] + assert_equal 'Awaiting payment', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}").text end def test_domain_is_available_when_payment_received @@ -124,7 +124,7 @@ class EppDomainCheckAuctionTest < EppTestCase - + auction.test @@ -138,7 +138,7 @@ class EppDomainCheckAuctionTest < EppTestCase response_xml = Nokogiri::XML(response.body) assert_correct_against_schema response_xml assert_epp_response :completed_successfully - assert_equal '1', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}")['avail'] - assert_nil response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}") + assert_equal '1', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}")['avail'] + assert_nil response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}") end end diff --git a/test/integration/epp/domain/check/base_test.rb b/test/integration/epp/domain/check/base_test.rb index 3a5b9bd76..7a1c20c88 100644 --- a/test/integration/epp/domain/check/base_test.rb +++ b/test/integration/epp/domain/check/base_test.rb @@ -7,7 +7,7 @@ class EppDomainCheckBaseTest < EppTestCase - + some.test @@ -21,7 +21,7 @@ class EppDomainCheckBaseTest < EppTestCase response_xml = Nokogiri::XML(response.body) assert_epp_response :completed_successfully assert_correct_against_schema response_xml - assert_equal 'some.test', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}").text + assert_equal 'some.test', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}").text end def test_domain_is_available_when_not_registered_or_blocked @@ -30,7 +30,7 @@ class EppDomainCheckBaseTest < EppTestCase - + available.test @@ -43,8 +43,8 @@ class EppDomainCheckBaseTest < EppTestCase response_xml = Nokogiri::XML(response.body) assert_correct_against_schema response_xml - assert_equal '1', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}")['avail'] - assert_nil response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}") + assert_equal '1', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}")['avail'] + assert_nil response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}") end def test_domain_is_available_when_reserved @@ -55,7 +55,7 @@ class EppDomainCheckBaseTest < EppTestCase - + reserved.test @@ -68,8 +68,8 @@ class EppDomainCheckBaseTest < EppTestCase response_xml = Nokogiri::XML(response.body) assert_correct_against_schema response_xml - assert_equal '1', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}")['avail'] - assert_nil response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}") + assert_equal '1', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}")['avail'] + assert_nil response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}") end def test_domain_is_unavailable_when_format_is_invalid @@ -78,7 +78,7 @@ class EppDomainCheckBaseTest < EppTestCase - + invalid @@ -91,8 +91,8 @@ class EppDomainCheckBaseTest < EppTestCase response_xml = Nokogiri::XML(response.body) assert_correct_against_schema response_xml - assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}")['avail'] - assert_equal 'invalid format', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}").text + assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}")['avail'] + assert_equal 'invalid format', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}").text end def test_domain_is_unavailable_when_registered @@ -103,7 +103,7 @@ class EppDomainCheckBaseTest < EppTestCase - + shop.test @@ -116,8 +116,8 @@ class EppDomainCheckBaseTest < EppTestCase response_xml = Nokogiri::XML(response.body) assert_correct_against_schema response_xml - assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}")['avail'] - assert_equal 'in use', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}").text + assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}")['avail'] + assert_equal 'in use', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}").text end def test_domain_is_unavailable_when_blocked @@ -128,7 +128,7 @@ class EppDomainCheckBaseTest < EppTestCase - + blocked.test @@ -141,8 +141,8 @@ class EppDomainCheckBaseTest < EppTestCase response_xml = Nokogiri::XML(response.body) assert_correct_against_schema response_xml - assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}")['avail'] - assert_equal 'Blocked', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}").text + assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}")['avail'] + assert_equal 'Blocked', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}").text end def test_domain_is_unavailable_when_zone_with_the_same_origin_exists @@ -153,7 +153,7 @@ class EppDomainCheckBaseTest < EppTestCase - + test @@ -166,8 +166,8 @@ class EppDomainCheckBaseTest < EppTestCase response_xml = Nokogiri::XML(response.body) assert_correct_against_schema response_xml - assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}")['avail'] - assert_equal 'Zone with the same origin exists', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}").text + assert_equal '0', response_xml.at_xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}")['avail'] + assert_equal 'Zone with the same origin exists', response_xml.at_xpath('//domain:reason', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}").text end def test_multiple_domains @@ -176,7 +176,7 @@ class EppDomainCheckBaseTest < EppTestCase - + one.test two.test three.test @@ -191,6 +191,6 @@ class EppDomainCheckBaseTest < EppTestCase response_xml = Nokogiri::XML(response.body) assert_correct_against_schema response_xml - assert_equal 3, response_xml.xpath('//domain:cd', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}").size + assert_equal 3, response_xml.xpath('//domain:cd', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}").size end end diff --git a/test/integration/epp/domain/create/auction_idn_test.rb b/test/integration/epp/domain/create/auction_idn_test.rb index 604b74c7d..76532ca51 100644 --- a/test/integration/epp/domain/create/auction_idn_test.rb +++ b/test/integration/epp/domain/create/auction_idn_test.rb @@ -24,7 +24,7 @@ class EppDomainCreateAuctionIdnTest < EppTestCase - + xn--pramiid-n2a.test #{contacts(:john).code} @@ -62,7 +62,7 @@ class EppDomainCreateAuctionIdnTest < EppTestCase - + püramiid.test #{contacts(:john).code} @@ -99,7 +99,7 @@ class EppDomainCreateAuctionIdnTest < EppTestCase - + xn--pramiid-n2a.test #{contacts(:john).code} @@ -136,7 +136,7 @@ class EppDomainCreateAuctionIdnTest < EppTestCase - + püramiid.test #{contacts(:john).code} @@ -174,7 +174,7 @@ class EppDomainCreateAuctionIdnTest < EppTestCase - + püramiid.test #{contacts(:john).code} @@ -214,7 +214,7 @@ class EppDomainCreateAuctionIdnTest < EppTestCase - + xn--pramiid-n2a.test #{contacts(:john).code} diff --git a/test/integration/epp/domain/create/auction_test.rb b/test/integration/epp/domain/create/auction_test.rb index cd20f2dac..ebebfb9bf 100644 --- a/test/integration/epp/domain/create/auction_test.rb +++ b/test/integration/epp/domain/create/auction_test.rb @@ -16,7 +16,7 @@ class EppDomainCreateAuctionTest < EppTestCase - + not-at-auction.test #{contacts(:john).code} @@ -53,7 +53,7 @@ class EppDomainCreateAuctionTest < EppTestCase - + auction.test #{contacts(:john).code} @@ -88,7 +88,7 @@ class EppDomainCreateAuctionTest < EppTestCase - + auction.test #{contacts(:john).code} @@ -126,7 +126,7 @@ class EppDomainCreateAuctionTest < EppTestCase - + auction.test #{contacts(:john).code} @@ -158,7 +158,7 @@ class EppDomainCreateAuctionTest < EppTestCase - + auction.test #{contacts(:john).code} @@ -192,7 +192,7 @@ class EppDomainCreateAuctionTest < EppTestCase - + auction.test #{contacts(:john).code} @@ -226,7 +226,7 @@ class EppDomainCreateAuctionTest < EppTestCase - + auction.test diff --git a/test/integration/epp/domain/create/base_test.rb b/test/integration/epp/domain/create/base_test.rb index de36e7a02..63212d2fa 100644 --- a/test/integration/epp/domain/create/base_test.rb +++ b/test/integration/epp/domain/create/base_test.rb @@ -17,7 +17,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} @@ -59,7 +59,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} @@ -94,7 +94,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} @@ -132,7 +132,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} @@ -170,7 +170,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} @@ -201,7 +201,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} #{contacts(:jane).code} @@ -239,7 +239,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} #{contact.code} @@ -279,7 +279,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} #{contact.code} @@ -318,7 +318,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} #{contact.code} @@ -358,7 +358,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} #{contact.code} @@ -398,7 +398,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} #{contact_two.code} @@ -437,7 +437,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} @@ -487,7 +487,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} @@ -525,7 +525,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{registrant.code} @@ -562,7 +562,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{reserved_domain.name} #{contacts(:john).code} @@ -600,7 +600,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{name} #{contacts(:john).code} @@ -635,7 +635,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{blocked_domain} #{contacts(:john).code} @@ -667,7 +667,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{SimpleIDN.to_ascii('blockedäöüõ.test')} #{contacts(:john).code} @@ -696,7 +696,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{reserved_domains(:one).name} #{contacts(:john).code} @@ -730,7 +730,7 @@ class EppDomainCreateBaseTest < EppTestCase - + #{reserved_domain.name} #{contacts(:john).code} @@ -762,7 +762,7 @@ class EppDomainCreateBaseTest < EppTestCase - + new.test #{contacts(:john).code} @@ -792,7 +792,7 @@ class EppDomainCreateBaseTest < EppTestCase - + new.test 2 john-001 diff --git a/test/integration/epp/domain/delete/base_test.rb b/test/integration/epp/domain/delete/base_test.rb index 04c6fe714..95e5e6afd 100644 --- a/test/integration/epp/domain/delete/base_test.rb +++ b/test/integration/epp/domain/delete/base_test.rb @@ -21,7 +21,7 @@ class EppDomainDeleteBaseTest < EppTestCase - + invalid.test @@ -50,7 +50,7 @@ class EppDomainDeleteBaseTest < EppTestCase - + shop.test @@ -80,7 +80,7 @@ class EppDomainDeleteBaseTest < EppTestCase - + shop.test @@ -116,7 +116,7 @@ class EppDomainDeleteBaseTest < EppTestCase - + shop.test @@ -153,7 +153,7 @@ class EppDomainDeleteBaseTest < EppTestCase - + shop.test @@ -189,7 +189,7 @@ class EppDomainDeleteBaseTest < EppTestCase - + shop.test @@ -224,7 +224,7 @@ class EppDomainDeleteBaseTest < EppTestCase - + shop.test @@ -248,7 +248,7 @@ class EppDomainDeleteBaseTest < EppTestCase - + shop.test diff --git a/test/integration/epp/domain/info/base_test.rb b/test/integration/epp/domain/info/base_test.rb index 3e4178054..da3be1d38 100644 --- a/test/integration/epp/domain/info/base_test.rb +++ b/test/integration/epp/domain/info/base_test.rb @@ -13,7 +13,7 @@ class EppDomainInfoBaseTest < EppTestCase - + shop.test @@ -30,22 +30,22 @@ class EppDomainInfoBaseTest < EppTestCase assert assert_schema_is_bigger(response_xml, 'domain-ee', 1.1) assert_equal 'shop.test', response_xml.at_xpath('//domain:name', - 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1').to_s).text + 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2').to_s).text assert_equal 'ok', response_xml.at_xpath('//domain:status', - 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1').to_s)['s'] + 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2').to_s)['s'] assert_equal 'john-001', response_xml.at_xpath('//domain:registrant', - 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1').to_s).text + 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2').to_s).text assert_equal '2010-07-05T00:00:00+03:00', response_xml.at_xpath('//domain:crDate', - 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1').to_s).text + 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2').to_s).text assert_equal '2010-07-06T00:00:00+03:00', response_xml.at_xpath('//domain:upDate', - 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1').to_s).text + 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2').to_s).text assert_equal '2010-07-07T00:00:00+03:00', response_xml.at_xpath('//domain:exDate', - 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1').to_s).text + 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2').to_s).text end def test_return_wrong_schema_with_invalid_version @@ -74,7 +74,7 @@ class EppDomainInfoBaseTest < EppTestCase - + shop.test @@ -164,7 +164,7 @@ class EppDomainInfoBaseTest < EppTestCase - + shop.test @@ -192,7 +192,7 @@ class EppDomainInfoBaseTest < EppTestCase - + shop.test @@ -216,7 +216,7 @@ class EppDomainInfoBaseTest < EppTestCase - + shop.test @@ -230,7 +230,7 @@ class EppDomainInfoBaseTest < EppTestCase response_xml = Nokogiri::XML(response.body) assert_equal '65078d5', response_xml.at_xpath('//domain:authInfo/domain:pw', - 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1').to_s).text + 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2').to_s).text assert_correct_against_schema response_xml end @@ -244,7 +244,7 @@ class EppDomainInfoBaseTest < EppTestCase - + shop.test 65078d5 @@ -261,7 +261,7 @@ class EppDomainInfoBaseTest < EppTestCase response_xml = Nokogiri::XML(response.body) assert_equal '65078d5', response_xml.at_xpath('//domain:authInfo/domain:pw', - 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1').to_s).text + 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2').to_s).text assert_correct_against_schema response_xml end @@ -271,7 +271,7 @@ class EppDomainInfoBaseTest < EppTestCase - + shop.test @@ -288,6 +288,6 @@ class EppDomainInfoBaseTest < EppTestCase response_xml = Nokogiri::XML(response.body) assert_correct_against_schema response_xml assert_nil response_xml.at_xpath('//domain:authInfo/domain:pw', - 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1').to_s) + 'domain' => Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2').to_s) end end diff --git a/test/integration/epp/domain/renew/base_test.rb b/test/integration/epp/domain/renew/base_test.rb index 6cbe619d4..68d4f7d2a 100644 --- a/test/integration/epp/domain/renew/base_test.rb +++ b/test/integration/epp/domain/renew/base_test.rb @@ -14,7 +14,7 @@ class EppDomainRenewBaseTest < EppTestCase - + #{domain.name} #{domain.expire_time.to_date} 1 @@ -48,7 +48,7 @@ class EppDomainRenewBaseTest < EppTestCase - + #{domain.name} #{domain.expire_time.to_date} 1 @@ -78,7 +78,7 @@ class EppDomainRenewBaseTest < EppTestCase - + #{domain.name} #{domain.valid_to.to_date} 1 @@ -109,7 +109,7 @@ class EppDomainRenewBaseTest < EppTestCase - + #{domain.name} #{domain.valid_to.to_date} 1 @@ -140,7 +140,7 @@ class EppDomainRenewBaseTest < EppTestCase - + #{domain.name} #{domain.expire_time.to_date} 1 @@ -170,7 +170,7 @@ class EppDomainRenewBaseTest < EppTestCase - + #{domain.name} #{domain.expire_time.to_date} 2 @@ -201,7 +201,7 @@ class EppDomainRenewBaseTest < EppTestCase - + #{domain.name} #{provided_expiration_date} @@ -235,7 +235,7 @@ class EppDomainRenewBaseTest < EppTestCase - + #{domain.name} #{domain.expire_time.to_date} 1 diff --git a/test/integration/epp/domain/transfer/query_test.rb b/test/integration/epp/domain/transfer/query_test.rb index 7635d8a8b..6f9ad9516 100644 --- a/test/integration/epp/domain/transfer/query_test.rb +++ b/test/integration/epp/domain/transfer/query_test.rb @@ -9,10 +9,10 @@ class EppDomainTransferQueryTest < EppTestCase assert_correct_against_schema xml_doc assert_epp_response :completed_successfully - assert_equal 'shop.test', xml_doc.xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}").text - assert_equal 'serverApproved', xml_doc.xpath('//domain:trStatus', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}").text - assert_equal 'goodnames', xml_doc.xpath('//domain:reID', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}").text - assert_equal 'bestnames', xml_doc.xpath('//domain:acID', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}").text + assert_equal 'shop.test', xml_doc.xpath('//domain:name', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}").text + assert_equal 'serverApproved', xml_doc.xpath('//domain:trStatus', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}").text + assert_equal 'goodnames', xml_doc.xpath('//domain:reID', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}").text + assert_equal 'bestnames', xml_doc.xpath('//domain:acID', 'domain' => "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}").text end def test_wrong_transfer_code @@ -21,7 +21,7 @@ class EppDomainTransferQueryTest < EppTestCase - + shop.test wrong @@ -57,7 +57,7 @@ class EppDomainTransferQueryTest < EppTestCase - + shop.test 65078d5 diff --git a/test/integration/epp/domain/transfer/request_test.rb b/test/integration/epp/domain/transfer/request_test.rb index 1e706ce6b..b1be6a97b 100644 --- a/test/integration/epp/domain/transfer/request_test.rb +++ b/test/integration/epp/domain/transfer/request_test.rb @@ -133,7 +133,7 @@ class EppDomainTransferRequestTest < EppTestCase response_xml = Nokogiri::XML(response.body) assert_correct_against_schema response_xml assert_equal 'serverApproved', Nokogiri::XML(response.body).xpath('//domain:trStatus', 'domain' => - "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')}").text + "#{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')}").text end def test_assigns_new_registrar @@ -236,7 +236,7 @@ class EppDomainTransferRequestTest < EppTestCase - + shop.test wrong @@ -265,7 +265,7 @@ class EppDomainTransferRequestTest < EppTestCase - + shop.test 65078d5 diff --git a/test/integration/epp/domain/update/base_test.rb b/test/integration/epp/domain/update/base_test.rb index bff325307..fa1ed1f79 100644 --- a/test/integration/epp/domain/update/base_test.rb +++ b/test/integration/epp/domain/update/base_test.rb @@ -23,7 +23,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + shop.test @@ -48,13 +48,236 @@ class EppDomainUpdateBaseTest < EppTestCase assert_epp_response :parameter_value_syntax_error end + def test_set_false_for_obj_and_extensions_prohibited + ENV['obj_and_extensions_prohibited'] = 'false' + @domain = domains(:shop) + @domain.statuses << DomainStatus::SERVER_OBJ_UPDATE_PROHIBITED + @domain.save + @dnskey = dnskeys(:one) + @dnskey.update(domain: @domain) + + request_xml = <<-XML + + + + + + shop.test + + + + #{nameservers(:shop_ns1).hostname} + + + #{nameservers(:shop_ns2).hostname} + + + + #{@dnskey.flags} + #{@dnskey.protocol} + #{@dnskey.alg} + #{@dnskey.public_key} + + + + + + + XML + + post epp_update_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + response_xml = Nokogiri::XML(response.body) + p response.body + assert_correct_against_schema response_xml + @domain.reload + + assert_epp_response :completed_successfully + ENV['obj_and_extensions_prohibited'] = nil + end + + def test_set_nil_for_obj_and_extensions_prohibited + ENV['obj_and_extensions_prohibited'] = nil + @domain = domains(:shop) + @domain.statuses << DomainStatus::SERVER_OBJ_UPDATE_PROHIBITED + @domain.save + @dnskey = dnskeys(:one) + @dnskey.update(domain: @domain) + + request_xml = <<-XML + + + + + + shop.test + + + + #{nameservers(:shop_ns1).hostname} + + + #{nameservers(:shop_ns2).hostname} + + + + #{@dnskey.flags} + #{@dnskey.protocol} + #{@dnskey.alg} + #{@dnskey.public_key} + + + + + + + XML + + post epp_update_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + response_xml = Nokogiri::XML(response.body) + assert_correct_against_schema response_xml + @domain.reload + + assert_epp_response :completed_successfully + end + + def test_update_domain_data_out_of_extension_block_with_serverObjUpdateProhibited + ENV['obj_and_extensions_prohibited'] = 'true' + @domain = domains(:shop) + @domain.statuses << DomainStatus::SERVER_OBJ_UPDATE_PROHIBITED + @domain.save + @dnskey = dnskeys(:one) + @dnskey.update(domain: @domain) + + request_xml = <<-XML + + + + + + shop.test + + + + #{nameservers(:shop_ns1).hostname} + + + #{nameservers(:shop_ns2).hostname} + + + + #{@dnskey.flags} + #{@dnskey.protocol} + #{@dnskey.alg} + #{@dnskey.public_key} + + + + + + + XML + + post epp_update_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + response_xml = Nokogiri::XML(response.body) + assert_correct_against_schema response_xml + @domain.reload + + assert_epp_response :object_status_prohibits_operation + ENV['obj_and_extensions_prohibited'] = nil + end + + def test_update_domain_data_out_of_extension_block_with_extension_update_prohibited + ENV['obj_and_extensions_prohibited'] = 'true' + @domain = domains(:shop) + @domain.statuses << DomainStatus::SERVER_EXTENSION_UPDATE_PROHIBITED + @domain.save + + request_xml = <<-XML + + + + + + shop.test + + + + #{nameservers(:shop_ns1).hostname} + + + #{nameservers(:shop_ns2).hostname} + + + + + + + + XML + + post epp_update_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + response_xml = Nokogiri::XML(response.body) + assert_correct_against_schema response_xml + @domain.reload + + assert_epp_response :completed_successfully + ENV['obj_and_extensions_prohibited'] = nil + end + + def test_update_domain_dns_with_extension_update_prohibited + ENV['obj_and_extensions_prohibited'] = 'true' + @domain = domains(:shop) + @domain.statuses << DomainStatus::SERVER_EXTENSION_UPDATE_PROHIBITED + @domain.save + @dnskey = dnskeys(:one) + @dnskey.update(domain: @domain) + + request_xml = <<-XML + + + + + + shop.test + + + + + + + #{@dnskey.flags} + #{@dnskey.protocol} + #{@dnskey.alg} + #{@dnskey.public_key} + + + + + + + XML + + post epp_update_path, params: { frame: request_xml }, + headers: { 'HTTP_COOKIE' => 'session=api_bestnames' } + response_xml = Nokogiri::XML(response.body) + assert_correct_against_schema response_xml + @domain.reload + + assert_epp_response :object_status_prohibits_operation + ENV['obj_and_extensions_prohibited'] = nil + end + def test_update_domain request_xml = <<-XML - + shop.test @@ -84,7 +307,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + shop.test @@ -105,7 +328,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + shop.test @@ -128,7 +351,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} @@ -155,7 +378,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} #{new_registrant.code} @@ -201,7 +424,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} #{new_registrant.code} @@ -238,7 +461,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} #{new_registrant.code} @@ -283,7 +506,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} #{new_registrant.code} @@ -321,7 +544,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} #{new_registrant.code} @@ -357,7 +580,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} #{new_registrant.code} @@ -393,7 +616,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} #{@domain.registrant.code} @@ -434,7 +657,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} #{new_registrant.code} @@ -479,7 +702,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} #{new_registrant.code} @@ -520,7 +743,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} #{new_registrant.code} @@ -559,7 +782,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} #{new_registrant.code} @@ -607,7 +830,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} #{new_registrant.code} @@ -644,7 +867,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} #{new_registrant.code} @@ -683,7 +906,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} @@ -718,7 +941,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + shop.test Test @@ -749,7 +972,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + shop.test Test @@ -777,7 +1000,7 @@ class EppDomainUpdateBaseTest < EppTestCase - + #{@domain.name} diff --git a/test/integration/epp/domain/update/rem_dns_test.rb b/test/integration/epp/domain/update/rem_dns_test.rb index a34b52063..fd46338e7 100644 --- a/test/integration/epp/domain/update/rem_dns_test.rb +++ b/test/integration/epp/domain/update/rem_dns_test.rb @@ -25,7 +25,7 @@ class EppDomainUpdateRemDnsTest < EppTestCase - + shop.test @@ -65,7 +65,7 @@ class EppDomainUpdateRemDnsTest < EppTestCase - + shop.test diff --git a/test/integration/epp/login_test.rb b/test/integration/epp/login_test.rb index 4ac3ad6e6..80d7251d6 100644 --- a/test/integration/epp/login_test.rb +++ b/test/integration/epp/login_test.rb @@ -25,7 +25,7 @@ class EppLoginTest < EppTestCase en - #{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')} + #{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')} #{Xsd::Schema.filename(for_prefix: 'contact-ee', for_version: '1.1')} urn:ietf:params:xml:ns:host-1.0 urn:ietf:params:xml:ns:keyrelay-1.0 @@ -60,7 +60,7 @@ class EppLoginTest < EppTestCase en - #{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')} + #{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')} #{Xsd::Schema.filename(for_prefix: 'contact-ee', for_version: '1.1')} urn:ietf:params:xml:ns:host-1.0 urn:ietf:params:xml:ns:keyrelay-1.0 @@ -94,7 +94,7 @@ class EppLoginTest < EppTestCase en - #{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')} + #{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')} #{Xsd::Schema.filename(for_prefix: 'contact-ee', for_version: '1.1')} urn:ietf:params:xml:ns:host-1.0 urn:ietf:params:xml:ns:keyrelay-1.0 @@ -129,7 +129,7 @@ class EppLoginTest < EppTestCase en - #{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')} + #{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')} #{Xsd::Schema.filename(for_prefix: 'contact-ee', for_version: '1.1')} urn:ietf:params:xml:ns:host-1.0 urn:ietf:params:xml:ns:keyrelay-1.0 @@ -164,7 +164,7 @@ class EppLoginTest < EppTestCase en - #{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.1')} + #{Xsd::Schema.filename(for_prefix: 'domain-ee', for_version: '1.2')} #{Xsd::Schema.filename(for_prefix: 'contact-ee', for_version: '1.1')} urn:ietf:params:xml:ns:host-1.0 urn:ietf:params:xml:ns:keyrelay-1.0 diff --git a/test/integration/registrar_area/xml_consoles_test.rb b/test/integration/registrar_area/xml_consoles_test.rb index 442e6f2c0..443abfb78 100644 --- a/test/integration/registrar_area/xml_consoles_test.rb +++ b/test/integration/registrar_area/xml_consoles_test.rb @@ -58,7 +58,7 @@ class RegistrarXmlConsolesIntegrationTest < ApplicationIntegrationTest + xmlns:domain="https://epp.tld.ee/schema/domain-ee-1.2.xsd"> example.ee diff --git a/test/jobs/send_e_invoice_job_test.rb b/test/jobs/send_e_invoice_job_test.rb index ca1e50eb7..0f2c683f2 100644 --- a/test/jobs/send_e_invoice_job_test.rb +++ b/test/jobs/send_e_invoice_job_test.rb @@ -15,7 +15,7 @@ class SendEInvoiceJobTest < ActiveJob::TestCase assert_nothing_raised do perform_enqueued_jobs do - SendEInvoiceJob.perform_now(@invoice.id, true) + SendEInvoiceJob.perform_now(@invoice.id, payable: true) end end @invoice.reload diff --git a/test/models/feature_test.rb b/test/models/feature_test.rb new file mode 100644 index 000000000..23fd86171 --- /dev/null +++ b/test/models/feature_test.rb @@ -0,0 +1,30 @@ +require 'test_helper' + +class FeatureTest < ActiveSupport::TestCase + def test_if_obj_and_extensions_prohibited_enabled + ENV['obj_and_extensions_prohibited'] = 'true' + + assert Feature.obj_and_extensions_statuses_enabled? + + statuses = DomainStatus.admin_statuses + assert statuses.include? DomainStatus::SERVER_OBJ_UPDATE_PROHIBITED + end + + def test_if_obj_and_extensions_prohibited_is_nil + ENV['obj_and_extensions_prohibited'] = nil + + assert_not Feature.obj_and_extensions_statuses_enabled? + + statuses = DomainStatus.admin_statuses + assert_not statuses.include? DomainStatus::SERVER_OBJ_UPDATE_PROHIBITED + end + + def test_if_obj_and_extensions_prohibited_is_false + ENV['obj_and_extensions_prohibited'] = 'false' + + assert_not Feature.obj_and_extensions_statuses_enabled? + + statuses = DomainStatus.admin_statuses + assert_not statuses.include? DomainStatus::SERVER_OBJ_UPDATE_PROHIBITED + end +end diff --git a/test/system/admin_area/bank_statement_test.rb b/test/system/admin_area/bank_statement_test.rb index 8630049dc..1405081e2 100644 --- a/test/system/admin_area/bank_statement_test.rb +++ b/test/system/admin_area/bank_statement_test.rb @@ -10,7 +10,7 @@ class AdminAreaBankStatementTest < ApplicationSystemTestCase def test_update_bank_statement visit admin_bank_statement_path(id: @invoice.id) - + click_link_or_button 'Add' fill_in 'Description', with: 'Invoice with id 123' @@ -55,7 +55,7 @@ class AdminAreaBankStatementTest < ApplicationSystemTestCase def test_can_bind_statement_transactions registrar = registrars(:bestnames) - registrar.issue_prepayment_invoice(amount: 500) + registrar.issue_prepayment_invoice(500) invoice = registrar.invoices.last create_bank_statement diff --git a/test/system/registrar_area/xml_consoles_test.rb b/test/system/registrar_area/xml_consoles_test.rb index 6fe855a5b..51cc362eb 100644 --- a/test/system/registrar_area/xml_consoles_test.rb +++ b/test/system/registrar_area/xml_consoles_test.rb @@ -22,7 +22,7 @@ class RegistrarAreaXmlConsolesTest < ApplicationSystemTestCase - + auction.test