Merge branch 'master' into registry-790

This commit is contained in:
Artur Beljajev 2018-08-27 21:31:31 +03:00
commit fdc77fdd30
12 changed files with 29 additions and 24 deletions

View file

@ -87,14 +87,14 @@ class Certificate < ActiveRecord::Base
-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/)
if err.match?(/Data Base Updated/)
crt_file.rewind
self.crt = crt_file.read
self.md5 = OpenSSL::Digest::MD5.new(parsed_crt.to_der).to_s
save!
else
logger.error('FAILED TO CREATE CLIENT CERTIFICATE')
if err.match(/TXT_DB error number 2/)
if err.match?(/TXT_DB error number 2/)
errors.add(:base, I18n.t('failed_to_create_crt_csr_already_signed'))
logger.error('CSR ALREADY SIGNED')
else

View file

@ -34,16 +34,12 @@ module Versions
end
def user_from_id_role_username(str)
user = ApiUser.find_by(id: $1) if str =~ /^(\d+)-(ApiUser:|api-)/
unless user.present?
user = AdminUser.find_by(id: $1) if str =~ /^(\d+)-AdminUser:/
unless user.present?
# on import we copied Registrar name, which may eql code
registrar = Registrar.find_by(name: str)
# assume each registrar has only one user
user = registrar.api_users.first if registrar
end
end
registrar = Registrar.find_by(name: str)
user = registrar.api_users.first if registrar
str_match = str.match(/^(\d+)-(ApiUser:|api-|AdminUser:)/)
user ||= User.find_by(id: str_match[1]) if str_match
user
end

View file

@ -100,18 +100,18 @@ class Nameserver < ActiveRecord::Base
def check_puny_symbols
regexp = /(\A|\.)..--/
errors.add(:hostname, :invalid) if hostname =~ regexp
errors.add(:hostname, :invalid) if hostname.match?(regexp)
end
def validate_ipv4_format
ipv4.to_a.each do |ip|
errors.add(:ipv4, :invalid) unless ip =~ IPV4_REGEXP
errors.add(:ipv4, :invalid) unless ip.match?(IPV4_REGEXP)
end
end
def validate_ipv6_format
ipv6.to_a.each do |ip|
errors.add(:ipv6, :invalid) unless ip =~ IPV6_REGEXP
errors.add(:ipv6, :invalid) unless ip.match?(IPV6_REGEXP)
end
end
end