mirror of
https://github.com/internetee/registry.git
synced 2025-07-01 16:53:37 +02:00
Rubocop upgraded #2711
This commit is contained in:
parent
59c73fca9e
commit
7530d6ecab
33 changed files with 115 additions and 91 deletions
10
.rubocop.yml
10
.rubocop.yml
|
@ -106,4 +106,12 @@ Style/EmptyLinesAroundBlockBody:
|
|||
|
||||
# The ABC size is a calculated magnitude, so this number can be a Fixnum or a Float.
|
||||
Metrics/AbcSize:
|
||||
Max: 25
|
||||
Max: 35
|
||||
|
||||
# Very strange intention requirement, disabled for now
|
||||
Style/FirstParameterIndentation:
|
||||
Enabled: false
|
||||
|
||||
# old school regex // works fine
|
||||
Style/RegexpLiteral:
|
||||
Enabled: false
|
||||
|
|
4
Gemfile
4
Gemfile
|
@ -106,8 +106,8 @@ group :development do
|
|||
gem 'guard', '~> 2.6.1' # run tests automatically
|
||||
gem 'guard-rspec', '~> 4.3.1'
|
||||
gem 'guard-rails', '~> 0.7.0' # run EPP server automatically
|
||||
gem 'rubocop', '~> 0.26.1'
|
||||
gem 'guard-rubocop', '~> 1.1.0'
|
||||
gem 'rubocop', '~> 0.32.1'
|
||||
gem 'guard-rubocop', '~> 1.2.0'
|
||||
|
||||
# improved errors
|
||||
gem 'better_errors', '~> 2.1.1' # webconsole replacement
|
||||
|
|
16
Gemfile.lock
16
Gemfile.lock
|
@ -217,7 +217,7 @@ GEM
|
|||
guard-rspec (4.3.1)
|
||||
guard (~> 2.1)
|
||||
rspec (>= 2.14, < 4.0)
|
||||
guard-rubocop (1.1.0)
|
||||
guard-rubocop (1.2.0)
|
||||
guard (~> 2.0)
|
||||
rubocop (~> 0.20)
|
||||
gyoku (1.3.1)
|
||||
|
@ -304,7 +304,7 @@ GEM
|
|||
nprogress-rails (0.1.6.7)
|
||||
open4 (1.3.4)
|
||||
orm_adapter (0.5.0)
|
||||
parser (2.3.0.pre.2)
|
||||
parser (2.2.2.5)
|
||||
ast (>= 1.1, < 3.0)
|
||||
pdfkit (0.6.2)
|
||||
pg (0.18.2)
|
||||
|
@ -318,7 +318,7 @@ GEM
|
|||
websocket-driver (>= 0.2.0)
|
||||
polyamorous (1.2.0)
|
||||
activerecord (>= 3.0)
|
||||
powerpack (0.0.9)
|
||||
powerpack (0.1.1)
|
||||
pry (0.10.1)
|
||||
coderay (~> 1.1.0)
|
||||
method_source (~> 0.8.1)
|
||||
|
@ -406,10 +406,10 @@ GEM
|
|||
rspec-mocks (~> 3.0.0)
|
||||
rspec-support (~> 3.0.0)
|
||||
rspec-support (3.0.4)
|
||||
rubocop (0.26.1)
|
||||
rubocop (0.32.1)
|
||||
astrolabe (~> 1.3)
|
||||
parser (>= 2.2.0.pre.4, < 3.0)
|
||||
powerpack (~> 0.0.6)
|
||||
parser (>= 2.2.2.5, < 3.0)
|
||||
powerpack (~> 0.1)
|
||||
rainbow (>= 1.99.1, < 3.0)
|
||||
ruby-progressbar (~> 1.4)
|
||||
ruby-progressbar (1.7.5)
|
||||
|
@ -546,7 +546,7 @@ DEPENDENCIES
|
|||
guard (~> 2.6.1)
|
||||
guard-rails (~> 0.7.0)
|
||||
guard-rspec (~> 4.3.1)
|
||||
guard-rubocop (~> 1.1.0)
|
||||
guard-rubocop (~> 1.2.0)
|
||||
haml-rails (~> 0.9.0)
|
||||
hashie-forbidden_attributes (~> 0.1.1)
|
||||
html2haml (~> 2.0.0)
|
||||
|
@ -579,7 +579,7 @@ DEPENDENCIES
|
|||
rake
|
||||
ransack (~> 1.5.1)
|
||||
rspec-rails (~> 3.0.2)
|
||||
rubocop (~> 0.26.1)
|
||||
rubocop (~> 0.32.1)
|
||||
rubycritic (~> 1.1.1)
|
||||
sass-rails (~> 5.0.3)
|
||||
sdoc (~> 0.4.0)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
class Admin::ZonefilesController < ApplicationController
|
||||
authorize_resource class: false
|
||||
# TODO: Refactor this
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
|
||||
def create
|
||||
if ZonefileSetting.pluck(:origin).include?(params[:origin])
|
||||
|
|
|
@ -29,7 +29,6 @@ class Epp::DomainsController < EppController
|
|||
end
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/CyclomaticComplexity
|
||||
def update
|
||||
authorize! :update, @domain, @password
|
||||
|
||||
|
@ -44,7 +43,6 @@ class Epp::DomainsController < EppController
|
|||
end
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/CyclomaticComplexity
|
||||
def delete
|
||||
authorize! :delete, @domain, @password
|
||||
|
||||
|
@ -66,7 +64,6 @@ class Epp::DomainsController < EppController
|
|||
handle_errors(@domain)
|
||||
end
|
||||
end
|
||||
# rubocop:enbale Metrics/CyclomaticComplexity
|
||||
|
||||
def check
|
||||
authorize! :check, Epp::Domain
|
||||
|
@ -88,8 +85,6 @@ class Epp::DomainsController < EppController
|
|||
render_epp_response '/epp/domains/renew'
|
||||
end
|
||||
|
||||
# rubocop: disable Metrics/PerceivedComplexity
|
||||
# rubocop: disable Metrics/MethodLength
|
||||
def transfer
|
||||
authorize! :transfer, @domain, @password
|
||||
action = params[:parsed_frame].css('transfer').first[:op]
|
||||
|
@ -102,8 +97,6 @@ class Epp::DomainsController < EppController
|
|||
handle_errors(@domain)
|
||||
end
|
||||
end
|
||||
# rubocop: enable Metrics/MethodLength
|
||||
# rubocop: enable Metrics/CyclomaticComplexity
|
||||
|
||||
private
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
class Epp::KeyrelaysController < EppController
|
||||
skip_authorization_check # TODO: move authorization under ability
|
||||
|
||||
# rubocop: disable Metrics/PerceivedComplexity
|
||||
# rubocop: disable Metrics/CyclomaticComplexity
|
||||
def keyrelay
|
||||
# keyrelay temp turned off
|
||||
|
@ -30,7 +29,6 @@ class Epp::KeyrelaysController < EppController
|
|||
|
||||
exactly_one_of 'expiry > relative', 'expiry > absolute'
|
||||
end
|
||||
# rubocop: enable Metrics/PerceivedComplexity
|
||||
# rubocop: enable Metrics/CyclomaticComplexity
|
||||
|
||||
def find_domain
|
||||
|
|
|
@ -7,6 +7,7 @@ class Epp::SessionsController < EppController
|
|||
|
||||
# rubocop: disable Metrics/PerceivedComplexity
|
||||
# rubocop: disable Metrics/CyclomaticComplexity
|
||||
# rubocop: disable Metrics/AbcSize
|
||||
def login
|
||||
cert_valid = true
|
||||
@api_user = ApiUser.find_by(login_params)
|
||||
|
@ -33,6 +34,9 @@ class Epp::SessionsController < EppController
|
|||
render_epp_response('login_fail')
|
||||
end
|
||||
end
|
||||
# rubocop: enable Metrics/AbcSize
|
||||
# rubocop: enable Metrics/PerceivedComplexity
|
||||
# rubocop: enable Metrics/CyclomaticComplexity
|
||||
|
||||
def ip_white?
|
||||
return true if request.ip == ENV['webclient_ip']
|
||||
|
@ -58,9 +62,6 @@ class Epp::SessionsController < EppController
|
|||
true
|
||||
end
|
||||
|
||||
# rubocop: enable Metrics/PerceivedComplexity
|
||||
# rubocop: enable Metrics/CyclomaticComplexity
|
||||
|
||||
def logout
|
||||
@api_user = current_user # cache current_user for logging
|
||||
epp_session.destroy
|
||||
|
|
|
@ -272,7 +272,6 @@ class EppController < ApplicationController
|
|||
end
|
||||
# rubocop: enable Style/PredicateName
|
||||
|
||||
# rubocop: disable Metrics/PerceivedComplexity
|
||||
# rubocop: disable Metrics/CyclomaticComplexity
|
||||
def write_to_epp_log
|
||||
# return nil if EPP_LOG_ENABLED
|
||||
|
@ -295,7 +294,6 @@ class EppController < ApplicationController
|
|||
ip: request.ip
|
||||
})
|
||||
end
|
||||
# rubocop: enable Metrics/PerceivedComplexity
|
||||
# rubocop: enable Metrics/CyclomaticComplexity
|
||||
|
||||
def iptables_counter_update
|
||||
|
|
|
@ -9,7 +9,7 @@ class Registrant::DomainDeleteConfirmsController < RegistrantController
|
|||
end
|
||||
|
||||
# rubocop: disable Metrics/PerceivedComplexity
|
||||
# rubocop: disable Metrics/CyclomaticComplexity
|
||||
# rubocop: disable Metrics/AbcSize
|
||||
def update
|
||||
@domain = Domain.find(params[:id])
|
||||
unless @domain.registrant_delete_confirmable?(params[:token])
|
||||
|
@ -39,5 +39,5 @@ class Registrant::DomainDeleteConfirmsController < RegistrantController
|
|||
end
|
||||
end
|
||||
# rubocop: enable Metrics/PerceivedComplexity
|
||||
# rubocop: enable Metrics/CyclomaticComplexity
|
||||
# rubocop: enable Metrics/AbcSize
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ class Registrant::DomainUpdateConfirmsController < RegistrantController
|
|||
end
|
||||
|
||||
# rubocop: disable Metrics/PerceivedComplexity
|
||||
# rubocop: disable Metrics/CyclomaticComplexity
|
||||
# rubocop: disable Metrics/AbcSize
|
||||
def update
|
||||
@domain = Domain.find(params[:id])
|
||||
unless @domain.registrant_update_confirmable?(params[:token])
|
||||
|
@ -39,5 +39,5 @@ class Registrant::DomainUpdateConfirmsController < RegistrantController
|
|||
end
|
||||
end
|
||||
# rubocop: enable Metrics/PerceivedComplexity
|
||||
# rubocop: enable Metrics/CyclomaticComplexity
|
||||
# rubocop: enable Metrics/AbcSize
|
||||
end
|
||||
|
|
|
@ -4,6 +4,7 @@ class Registrant::SessionsController < Devise::SessionsController
|
|||
def login
|
||||
end
|
||||
|
||||
# rubocop: disable Metrics/AbcSize
|
||||
def id
|
||||
if Rails.env.development?
|
||||
sign_in(RegistrantUser.find_or_create_by_idc_data('test'), event: :authentication)
|
||||
|
@ -22,12 +23,14 @@ class Registrant::SessionsController < Devise::SessionsController
|
|||
redirect_to registrant_login_url
|
||||
end
|
||||
end
|
||||
# rubocop: enable Metrics/AbcSize
|
||||
|
||||
def login_mid
|
||||
@user = User.new
|
||||
end
|
||||
|
||||
def mid # rubocop: disable Metrics/MethodLength
|
||||
# rubocop: disable Metrics/MethodLength
|
||||
def mid
|
||||
phone = params[:user][:phone]
|
||||
endpoint = "#{ENV['sk_digi_doc_service_endpoint']}"
|
||||
client = Digidoc::Client.new(endpoint)
|
||||
|
@ -64,8 +67,9 @@ class Registrant::SessionsController < Devise::SessionsController
|
|||
render json: { message: t(:no_such_user) }, status: :unauthorized
|
||||
end
|
||||
end
|
||||
# rubocop: enable Metrics/MethodLength
|
||||
|
||||
# rubocop: disable Metrics/PerceivedComplexity
|
||||
# rubocop: disable Metrics/AbcSize
|
||||
# rubocop: disable Metrics/CyclomaticComplexity
|
||||
# rubocop: disable Metrics/MethodLength
|
||||
def mid_status
|
||||
|
@ -104,7 +108,7 @@ class Registrant::SessionsController < Devise::SessionsController
|
|||
render json: { message: t(:internal_error) }, status: :bad_request
|
||||
end
|
||||
end
|
||||
# rubocop: enable Metrics/PerceivedComplexity
|
||||
# rubocop: enable Metrics/AbcSize
|
||||
# rubocop: enable Metrics/CyclomaticComplexity
|
||||
# rubocop: enable Metrics/MethodLength
|
||||
|
||||
|
|
|
@ -14,11 +14,9 @@ class Registrar::SessionsController < Devise::SessionsController
|
|||
# rubocop:disable Metrics/PerceivedComplexity
|
||||
# rubocop:disable Metrics/CyclomaticComplexity
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
def create
|
||||
@depp_user = Depp::User.new(params[:depp_user].merge(
|
||||
pki: !(Rails.env.development? || Rails.env.test?)
|
||||
)
|
||||
)
|
||||
@depp_user = Depp::User.new(params[:depp_user].merge(pki: !(Rails.env.development? || Rails.env.test?)))
|
||||
|
||||
if @depp_user.pki && request.env['HTTP_SSL_CLIENT_S_DN_CN'].blank?
|
||||
@depp_user.errors.add(:base, :webserver_missing_user_name_directive)
|
||||
|
@ -64,6 +62,7 @@ class Registrar::SessionsController < Devise::SessionsController
|
|||
# rubocop:enable Metrics/CyclomaticComplexity
|
||||
# rubocop:enable Metrics/PerceivedComplexity
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
|
||||
def id
|
||||
@user = ApiUser.find_by_idc_data(request.env['SSL_CLIENT_S_DN'])
|
||||
|
@ -119,9 +118,9 @@ class Registrar::SessionsController < Devise::SessionsController
|
|||
render json: { message: t(:no_such_user) }, status: :unauthorized
|
||||
end
|
||||
end
|
||||
# rubocop: enable Metrics/MethodLength
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
|
||||
# rubocop: disable Metrics/PerceivedComplexity
|
||||
# rubocop: disable Metrics/AbcSize
|
||||
# rubocop: disable Metrics/CyclomaticComplexity
|
||||
# rubocop: disable Metrics/MethodLength
|
||||
def mid_status
|
||||
|
@ -159,7 +158,7 @@ class Registrar::SessionsController < Devise::SessionsController
|
|||
render json: { message: t(:internal_error) }, status: :bad_request
|
||||
end
|
||||
end
|
||||
# rubocop: enable Metrics/PerceivedComplexity
|
||||
# rubocop: enable Metrics/AbcSize
|
||||
# rubocop: enable Metrics/CyclomaticComplexity
|
||||
# rubocop: enable Metrics/MethodLength
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ class Ability
|
|||
# rubocop: disable Metrics/CyclomaticComplexity
|
||||
# rubocop: disable Metrics/PerceivedComplexity
|
||||
# rubocop: disable Metrics/LineLength
|
||||
# rubocop: disable Metrics/AbcSize
|
||||
def initialize(user)
|
||||
alias_action :show, to: :view
|
||||
alias_action :show, :create, :update, :destroy, to: :crud
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
require 'open3'
|
||||
|
||||
# rubocop: disable Metrics/ClassLength
|
||||
class ApiUser < User
|
||||
include EppErrors
|
||||
def epp_code_map # rubocop:disable Metrics/MethodLength
|
||||
|
||||
def epp_code_map
|
||||
{
|
||||
'2306' => [ # Parameter policy error
|
||||
[:password, :blank]
|
||||
|
@ -77,4 +77,3 @@ class ApiUser < User
|
|||
end
|
||||
end
|
||||
end
|
||||
# rubocop: enable Metrics/ClassLength
|
||||
|
|
|
@ -27,6 +27,7 @@ class BankStatement < ActiveRecord::Base
|
|||
File.open(import_file_path, 'w') { |f| f.write(th6_file.open.read) }
|
||||
end
|
||||
|
||||
# rubocop: disable Metrics/AbcSize
|
||||
def parse_th6_row(row)
|
||||
return parse_th6_header(row) if row[4, 3].strip == '000'
|
||||
return if row[4, 3].strip == '999' # skip footer
|
||||
|
@ -47,6 +48,7 @@ class BankStatement < ActiveRecord::Base
|
|||
reference_no: row[280, 35].strip
|
||||
}
|
||||
end
|
||||
# rubocop: enable Metrics/AbcSize
|
||||
|
||||
def parse_th6_header(row)
|
||||
self.bank_code = row[7, 3].strip
|
||||
|
|
|
@ -76,6 +76,7 @@ class Certificate < ActiveRecord::Base
|
|||
@cached_status = REVOKED
|
||||
end
|
||||
|
||||
# rubocop: disable Metrics/AbcSize
|
||||
def sign!
|
||||
csr_file = Tempfile.new('client_csr')
|
||||
csr_file.write(csr)
|
||||
|
@ -107,6 +108,7 @@ class Certificate < ActiveRecord::Base
|
|||
return false
|
||||
end
|
||||
end
|
||||
# rubocop: enable Metrics/AbcSize
|
||||
|
||||
def revoke!
|
||||
crt_file = Tempfile.new('client_crt')
|
||||
|
|
|
@ -20,7 +20,6 @@ module Depp
|
|||
class << self
|
||||
attr_reader :epp_xml, :user
|
||||
|
||||
# rubocop: disable Metrics/MethodLength
|
||||
def new_from_params(params)
|
||||
new(
|
||||
id: params[:code],
|
||||
|
@ -43,8 +42,8 @@ module Depp
|
|||
country_code: params[:country_code]
|
||||
)
|
||||
end
|
||||
# rubocop: enable Metrics/MethodLength
|
||||
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
def find_by_id(id)
|
||||
data = info_xml(id)
|
||||
|
||||
|
@ -77,6 +76,7 @@ module Depp
|
|||
statuses: data.css('status').map { |s| [s['s'], s.text] }
|
||||
)
|
||||
end
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
|
||||
def user=(user)
|
||||
@user = user
|
||||
|
@ -170,7 +170,8 @@ module Depp
|
|||
handle_errors(data)
|
||||
end
|
||||
|
||||
# rubocop: disable Metrics/MethodLength
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
def update_attributes(params)
|
||||
self.ident_country_code = params[:ident_country_code]
|
||||
self.ident_type = params[:ident_type]
|
||||
|
@ -214,7 +215,8 @@ module Depp
|
|||
data = Depp::Contact.user.request(update_xml)
|
||||
handle_errors(data)
|
||||
end
|
||||
# rubocop: enable Metrics/MethodLength
|
||||
# rubocop:enbale Metrics/AbcSize
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
|
||||
def delete
|
||||
delete_xml = Contact.epp_xml.delete(
|
||||
|
|
|
@ -130,7 +130,9 @@ module Depp
|
|||
ret.with_indifferent_access
|
||||
end
|
||||
|
||||
def construct_params_from_server_data(data) # rubocop:disable Metrics/MethodLength
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
def construct_params_from_server_data(data)
|
||||
ret = default_params
|
||||
ret[:name] = data.css('name').text
|
||||
ret[:registrant] = data.css('registrant').text
|
||||
|
@ -176,6 +178,8 @@ module Depp
|
|||
|
||||
ret
|
||||
end
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
|
||||
def construct_custom_params_hash(domain_params)
|
||||
custom_params = {}
|
||||
|
@ -233,7 +237,7 @@ module Depp
|
|||
host_attr << { hostAddr: { value: v['ipv4'], attrs: { ip: 'v4' } } } if v['ipv4'].present?
|
||||
host_attr << { hostAddr: { value: v['ipv6'], attrs: { ip: 'v6' } } } if v['ipv6'].present?
|
||||
|
||||
ret << { hostAttr: host_attr }
|
||||
ret << { hostAttr: host_attr }
|
||||
end
|
||||
|
||||
ret
|
||||
|
@ -256,11 +260,11 @@ module Depp
|
|||
domain_params[:dnskeys_attributes].each do |_k, v|
|
||||
if v['ds_key_tag'].blank?
|
||||
kd = create_key_data_hash(v)
|
||||
ret << {
|
||||
ret << {
|
||||
keyData: kd
|
||||
} if kd
|
||||
else
|
||||
ret << {
|
||||
ret << {
|
||||
dsData: [
|
||||
keyTag: { value: v['ds_key_tag'] },
|
||||
alg: { value: v['ds_alg'] },
|
||||
|
|
|
@ -8,7 +8,7 @@ module Depp
|
|||
self.epp_xml = EppXml::Keyrelay.new(cl_trid_prefix: current_user.tag)
|
||||
end
|
||||
|
||||
def keyrelay(params) # rubocop:disable Metrics/MethodLength
|
||||
def keyrelay(params)
|
||||
custom_params = {}
|
||||
if params[:legal_document].present?
|
||||
type = params[:legal_document].original_filename.split('.').last.downcase
|
||||
|
|
|
@ -36,6 +36,7 @@ module Depp
|
|||
Nokogiri::XML(e.response_xml.to_s).remove_namespaces!
|
||||
end
|
||||
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
def repp_request(path, params = {})
|
||||
client_cert = File.read(ENV['cert_path'])
|
||||
client_key = File.read(ENV['key_path'])
|
||||
|
@ -51,8 +52,7 @@ module Depp
|
|||
use_ssl: (uri.scheme == 'https'),
|
||||
verify_mode: OpenSSL::SSL::VERIFY_NONE,
|
||||
cert: OpenSSL::X509::Certificate.new(client_cert),
|
||||
key: OpenSSL::PKey::RSA.new(client_key)
|
||||
) do |http|
|
||||
key: OpenSSL::PKey::RSA.new(client_key)) do |http|
|
||||
http.request(req)
|
||||
end
|
||||
|
||||
|
@ -67,6 +67,7 @@ module Depp
|
|||
|
||||
ret
|
||||
end
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
|
||||
private
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ class Dnskey < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def bin_to_hex(s)
|
||||
s.each_byte.map { |b| sprintf('%02X', b) }.join
|
||||
s.each_byte.map { |b| format('%02X', b) }.join
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -207,6 +207,7 @@ class Domain < ActiveRecord::Base
|
|||
STDOUT << "#{Time.zone.now.utc} - Successfully set delete_candidate to #{d.count} domains\n"
|
||||
end
|
||||
|
||||
# rubocop:disable Rails/FindEach
|
||||
def destroy_delete_candidates
|
||||
STDOUT << "#{Time.zone.now.utc} - Destroying domains\n" unless Rails.env.test?
|
||||
|
||||
|
@ -223,6 +224,7 @@ class Domain < ActiveRecord::Base
|
|||
|
||||
STDOUT << "#{Time.zone.now.utc} - Successfully destroyed #{c} domains\n" unless Rails.env.test?
|
||||
end
|
||||
# rubocop:enable Rails/FindEach
|
||||
end
|
||||
|
||||
def name=(value)
|
||||
|
@ -410,8 +412,8 @@ class Domain < ActiveRecord::Base
|
|||
res = ''
|
||||
parts = name.split('.')
|
||||
parts.each do |x|
|
||||
res += sprintf('%02X', x.length) # length of label in hex
|
||||
res += x.each_byte.map { |b| sprintf('%02X', b) }.join # label
|
||||
res += format('%02X', x.length) # length of label in hex
|
||||
res += x.each_byte.map { |b| format('%02X', b) }.join # label
|
||||
end
|
||||
|
||||
res += '00'
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
# rubocop: disable Metrics/ClassLength
|
||||
class Epp::Contact < Contact
|
||||
include EppErrors
|
||||
|
||||
|
@ -15,6 +14,7 @@ class Epp::Contact < Contact
|
|||
# rubocop: disable Metrics/PerceivedComplexity
|
||||
# rubocop: disable Metrics/CyclomaticComplexity
|
||||
# rubocop: disable Metrics/MethodLength
|
||||
# rubocop: disable Metrics/AbcSize
|
||||
def attrs_from(frame, rem = nil)
|
||||
f = frame
|
||||
at = {}.with_indifferent_access
|
||||
|
@ -53,6 +53,7 @@ class Epp::Contact < Contact
|
|||
# rubocop: enable Metrics/MethodLength
|
||||
# rubocop: enable Metrics/PerceivedComplexity
|
||||
# rubocop: enable Metrics/CyclomaticComplexity
|
||||
# rubocop: enable Metrics/AbcSize
|
||||
|
||||
def new(frame, registrar)
|
||||
return super if frame.blank?
|
||||
|
@ -149,4 +150,3 @@ class Epp::Contact < Contact
|
|||
super(at)
|
||||
end
|
||||
end
|
||||
# rubocop: enable Metrics/ClassLength
|
||||
|
|
|
@ -81,13 +81,14 @@ class Epp::Domain < Domain
|
|||
def attach_default_contacts
|
||||
return if registrant.blank?
|
||||
regt = Registrant.find(registrant.id) # temp for bullet
|
||||
tech_contacts << regt if tech_domain_contacts.blank?
|
||||
tech_contacts << regt if tech_domain_contacts.blank?
|
||||
admin_contacts << regt if admin_domain_contacts.blank? && regt.priv?
|
||||
end
|
||||
|
||||
# rubocop: disable Metrics/PerceivedComplexity
|
||||
# rubocop: disable Metrics/CyclomaticComplexity
|
||||
# rubocop: disable Metrics/MethodLength
|
||||
# rubocop: disable Metrics/AbcSize
|
||||
def attrs_from(frame, current_user, action = nil)
|
||||
at = {}.with_indifferent_access
|
||||
|
||||
|
@ -130,6 +131,7 @@ class Epp::Domain < Domain
|
|||
# rubocop: enable Metrics/PerceivedComplexity
|
||||
# rubocop: enable Metrics/CyclomaticComplexity
|
||||
# rubocop: enable Metrics/MethodLength
|
||||
# rubocop: enable Metrics/AbcSize
|
||||
|
||||
def nameservers_attrs(frame, action)
|
||||
ns_list = nameservers_from(frame)
|
||||
|
@ -358,6 +360,7 @@ class Epp::Domain < Domain
|
|||
}]
|
||||
end
|
||||
|
||||
# rubocop: disable Metrics/AbcSize
|
||||
def update(frame, current_user, verify = true)
|
||||
return super if frame.blank?
|
||||
at = {}.with_indifferent_access
|
||||
|
@ -380,6 +383,7 @@ class Epp::Domain < Domain
|
|||
self.deliver_emails = true # turn on email delivery for epp
|
||||
errors.empty? && super(at)
|
||||
end
|
||||
# rubocop: enable Metrics/AbcSize
|
||||
|
||||
def apply_pending_update!
|
||||
preclean_pendings
|
||||
|
@ -524,6 +528,7 @@ class Epp::Domain < Domain
|
|||
# rubocop: enable Metrics/CyclomaticComplexity
|
||||
|
||||
# rubocop: disable Metrics/MethodLength
|
||||
# rubocop: disable Metrics/AbcSize
|
||||
def query_transfer(frame, current_user)
|
||||
return false unless can_be_transferred_to?(current_user.registrar)
|
||||
|
||||
|
@ -533,10 +538,10 @@ class Epp::Domain < Domain
|
|||
transaction do
|
||||
begin
|
||||
dt = domain_transfers.create!(
|
||||
transfer_requested_at: Time.zone.now,
|
||||
transfer_to: current_user.registrar,
|
||||
transfer_from: registrar
|
||||
)
|
||||
transfer_requested_at: Time.zone.now,
|
||||
transfer_to: current_user.registrar,
|
||||
transfer_from: registrar
|
||||
)
|
||||
|
||||
if dt.pending?
|
||||
registrar.messages.create!(
|
||||
|
@ -565,6 +570,7 @@ class Epp::Domain < Domain
|
|||
end
|
||||
end
|
||||
end
|
||||
# rubocop: enable Metrics/AbcSize
|
||||
# rubocop: enable Metrics/MethodLength
|
||||
|
||||
def approve_transfer(frame, current_user)
|
||||
|
@ -621,13 +627,14 @@ class Epp::Domain < Domain
|
|||
end
|
||||
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
def keyrelay(parsed_frame, requester)
|
||||
if registrar == requester
|
||||
errors.add(:base, :domain_already_belongs_to_the_querying_registrar) and return false
|
||||
end
|
||||
|
||||
abs_datetime = parsed_frame.css('absolute').text
|
||||
abs_datetime = DateTime.parse(abs_datetime) if abs_datetime.present?
|
||||
abs_datetime = DateTime.zone.parse(abs_datetime) if abs_datetime.present?
|
||||
|
||||
transaction do
|
||||
kr = keyrelays.build(
|
||||
|
@ -664,6 +671,7 @@ class Epp::Domain < Domain
|
|||
|
||||
true
|
||||
end
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
|
||||
### VALIDATIONS ###
|
||||
|
|
|
@ -47,8 +47,7 @@ class Nameserver < ActiveRecord::Base
|
|||
def replace_hostname_ends(domains, old_end, new_end)
|
||||
domains = domains.where('EXISTS(
|
||||
select 1 from nameservers ns where ns.domain_id = domains.id AND ns.hostname LIKE ?
|
||||
)', "%#{old_end}"
|
||||
)
|
||||
)', "%#{old_end}")
|
||||
|
||||
count, success_count = 0.0, 0.0
|
||||
domains.each do |d|
|
||||
|
|
|
@ -73,7 +73,9 @@ class Registrar < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def issue_prepayment_invoice(amount, description = nil) # rubocop:disable Metrics/MethodLength
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
def issue_prepayment_invoice(amount, description = nil)
|
||||
# Currently only EIS can issue invoices
|
||||
eis = self.class.eis
|
||||
|
||||
|
@ -122,6 +124,8 @@ class Registrar < ActiveRecord::Base
|
|||
]
|
||||
)
|
||||
end
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
|
||||
def cash_account
|
||||
accounts.find_by(account_type: Account::CASH)
|
||||
|
|
|
@ -30,6 +30,7 @@ class WhoisRecord < ActiveRecord::Base
|
|||
end
|
||||
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
def generate_json
|
||||
h = HashWithIndifferentAccess.new
|
||||
return h if domain.blank?
|
||||
|
@ -108,10 +109,11 @@ More information at http://internet.ee
|
|||
EOS
|
||||
end
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
|
||||
def contacts_body(admins, techs)
|
||||
admins ||= []
|
||||
techs ||= []
|
||||
techs ||= []
|
||||
|
||||
out = ''
|
||||
out << (admins.size > 1 ? "\nAdministrative contacts" : "\nAdministrative contact")
|
||||
|
|
|
@ -9,7 +9,7 @@ class DateTimeIso8601Validator < ActiveModel::EachValidator
|
|||
return true if value.empty?
|
||||
|
||||
begin
|
||||
DateTime.parse(value)
|
||||
DateTime.zone.parse(value)
|
||||
rescue => _e
|
||||
return false
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class ObjectCountValidator < ActiveModel::EachValidator
|
||||
def validate_each(record, attribute, value)
|
||||
min, max = options[:min].call, options[:max].call
|
||||
return if value.reject(&:marked_for_destruction?).length.between?(min, max)
|
||||
return if value.count { |i| !i.marked_for_destruction? }.between?(min, max)
|
||||
association = options[:association] || attribute
|
||||
record.errors.add(association, :out_of_range, { min: min, max: max })
|
||||
end
|
||||
|
|
|
@ -151,7 +151,7 @@ describe 'EPP Contact', epp: true do
|
|||
|
||||
id.text.length.should == 15
|
||||
# 5 seconds for what-ever weird lag reasons might happen
|
||||
cr_date.text.to_time.should be_within(5).of(Time.zone.now)
|
||||
cr_date.text.in_time_zone.utc.should be_within(5).of(Time.zone.now)
|
||||
end
|
||||
|
||||
it 'should add registrar prefix for code when missing' do
|
||||
|
|
|
@ -89,8 +89,8 @@ describe 'EPP Domain', epp: true do
|
|||
cre_data = response[:parsed].css('creData')
|
||||
|
||||
cre_data.css('name').text.should == dn
|
||||
cre_data.css('crDate').text.should == d.created_at.to_time.utc.iso8601
|
||||
cre_data.css('exDate').text.should == d.valid_to.to_time.utc.iso8601
|
||||
cre_data.css('crDate').text.should == d.created_at.in_time_zone.utc.utc.iso8601
|
||||
cre_data.css('exDate').text.should == d.valid_to.in_time_zone.utc.utc.iso8601
|
||||
|
||||
response[:clTRID].should == 'ABC-12345'
|
||||
|
||||
|
@ -746,10 +746,10 @@ describe 'EPP Domain', epp: true do
|
|||
trn_data.css('name').text.should == domain.name
|
||||
trn_data.css('trStatus').text.should == 'serverApproved'
|
||||
trn_data.css('reID').text.should == 'REGDOMAIN2'
|
||||
trn_data.css('reDate').text.should == dtl.transfer_requested_at.to_time.utc.iso8601
|
||||
trn_data.css('reDate').text.should == dtl.transfer_requested_at.in_time_zone.utc.utc.iso8601
|
||||
trn_data.css('acID').text.should == 'REGDOMAIN1'
|
||||
trn_data.css('acDate').text.should == dtl.transferred_at.to_time.utc.iso8601
|
||||
trn_data.css('exDate').text.should == domain.valid_to.to_time.utc.iso8601
|
||||
trn_data.css('acDate').text.should == dtl.transferred_at.in_time_zone.utc.utc.iso8601
|
||||
trn_data.css('exDate').text.should == domain.valid_to.in_time_zone.utc.utc.iso8601
|
||||
|
||||
domain.registrar.should == @registrar2
|
||||
|
||||
|
@ -791,10 +791,10 @@ describe 'EPP Domain', epp: true do
|
|||
trn_data.css('name').text.should == domain.name
|
||||
trn_data.css('trStatus').text.should == 'pending'
|
||||
trn_data.css('reID').text.should == 'REGDOMAIN1'
|
||||
trn_data.css('reDate').text.should == dtl.transfer_requested_at.to_time.utc.iso8601
|
||||
trn_data.css('acDate').text.should == dtl.wait_until.to_time.utc.iso8601
|
||||
trn_data.css('reDate').text.should == dtl.transfer_requested_at.in_time_zone.utc.utc.iso8601
|
||||
trn_data.css('acDate').text.should == dtl.wait_until.in_time_zone.utc.utc.iso8601
|
||||
trn_data.css('acID').text.should == 'REGDOMAIN2'
|
||||
trn_data.css('exDate').text.should == domain.valid_to.to_time.utc.iso8601
|
||||
trn_data.css('exDate').text.should == domain.valid_to.in_time_zone.utc.utc.iso8601
|
||||
|
||||
domain.registrar.should == @registrar2
|
||||
|
||||
|
@ -806,10 +806,10 @@ describe 'EPP Domain', epp: true do
|
|||
trn_data.css('name').text.should == domain.name
|
||||
trn_data.css('trStatus').text.should == 'pending'
|
||||
trn_data.css('reID').text.should == 'REGDOMAIN1'
|
||||
trn_data.css('reDate').text.should == dtl.transfer_requested_at.to_time.utc.iso8601
|
||||
trn_data.css('acDate').text.should == dtl.wait_until.to_time.utc.iso8601
|
||||
trn_data.css('reDate').text.should == dtl.transfer_requested_at.in_time_zone.utc.utc.iso8601
|
||||
trn_data.css('acDate').text.should == dtl.wait_until.in_time_zone.utc.utc.iso8601
|
||||
trn_data.css('acID').text.should == 'REGDOMAIN2'
|
||||
trn_data.css('exDate').text.should == domain.valid_to.to_time.utc.iso8601
|
||||
trn_data.css('exDate').text.should == domain.valid_to.in_time_zone.utc.utc.iso8601
|
||||
|
||||
domain.registrar.should == @registrar2
|
||||
|
||||
|
@ -1213,9 +1213,9 @@ describe 'EPP Domain', epp: true do
|
|||
trn_data.css('name').text.should == domain.name
|
||||
trn_data.css('trStatus').text.should == 'clientApproved'
|
||||
trn_data.css('reID').text.should == 'REGDOMAIN2'
|
||||
trn_data.css('reDate').text.should == dtl.transfer_requested_at.to_time.utc.iso8601
|
||||
trn_data.css('reDate').text.should == dtl.transfer_requested_at.in_time_zone.utc.utc.iso8601
|
||||
trn_data.css('acID').text.should == 'REGDOMAIN1'
|
||||
trn_data.css('exDate').text.should == domain.valid_to.to_time.utc.iso8601
|
||||
trn_data.css('exDate').text.should == domain.valid_to.in_time_zone.utc.utc.iso8601
|
||||
end
|
||||
|
||||
it 'rejects a domain transfer' do
|
||||
|
@ -2187,8 +2187,8 @@ describe 'EPP Domain', epp: true do
|
|||
ns1.css('hostName').last.text.should == 'ns1.example.com'
|
||||
ns1.css('hostAddr').first.text.should == '192.168.1.1'
|
||||
ns1.css('hostAddr').last.text.should == '1080:0:0:0:8:800:200C:417A'
|
||||
inf_data.css('crDate').text.should == domain.created_at.to_time.utc.iso8601
|
||||
inf_data.css('exDate').text.should == domain.valid_to.to_time.utc.iso8601
|
||||
inf_data.css('crDate').text.should == domain.created_at.in_time_zone.utc.utc.iso8601
|
||||
inf_data.css('exDate').text.should == domain.valid_to.in_time_zone.utc.utc.iso8601
|
||||
inf_data.css('pw').text.should == domain.auth_info
|
||||
|
||||
ds_data_1 = response[:parsed].css('dsData')[0]
|
||||
|
@ -2217,7 +2217,7 @@ describe 'EPP Domain', epp: true do
|
|||
response = epp_plain_request(domain_info_xml(name: { value: domain.name }))
|
||||
inf_data = response[:parsed].css('resData infData')
|
||||
|
||||
inf_data.css('upDate').text.should == domain.updated_at.to_time.utc.iso8601
|
||||
inf_data.css('upDate').text.should == domain.updated_at.in_time_zone.utc.utc.iso8601
|
||||
end
|
||||
|
||||
it 'returns domain info with different nameservers' do
|
||||
|
|
|
@ -49,7 +49,7 @@ describe Dnskey do
|
|||
dk = d.dnskeys.last
|
||||
|
||||
dk.generate_digest
|
||||
dk.ds_digest.should == '0B62D1BC64EFD1EE652FB102BDF1011BF514CCD9A1A0CFB7472AEA3B01F38C92'
|
||||
dk.ds_digest.should == '0B62D1BC64EFD1EE652FB102BDF1011BF514CCD9A1A0CFB7472AEA3B01F38C92'
|
||||
dk.ds_key_tag.should == '30607'
|
||||
end
|
||||
|
||||
|
|
|
@ -33,7 +33,6 @@ end
|
|||
|
||||
module Autodoc
|
||||
class Document
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
def route_info_doc
|
||||
return unless example.metadata[:route_info_doc]
|
||||
route = request.env["rack.routing_args"][:route_info]
|
||||
|
@ -57,7 +56,6 @@ module Autodoc
|
|||
|
||||
pretty_table(rows).join("\n")
|
||||
end
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
|
||||
def pretty_table(rows)
|
||||
# longest_in_col = 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue