diff --git a/app/controllers/repp/v1/white_ips_controller.rb b/app/controllers/repp/v1/white_ips_controller.rb index 6ece2aea9..6f962c0b5 100644 --- a/app/controllers/repp/v1/white_ips_controller.rb +++ b/app/controllers/repp/v1/white_ips_controller.rb @@ -7,7 +7,7 @@ module Repp include Shunter::Integration::Throttle api :GET, '/repp/v1/white_ips' - desc 'Get all whitelisted ips' + desc 'Get all whitelisted IPs' def index ips = current_user.registrar.white_ips @@ -28,7 +28,7 @@ module Repp end api :PUT, '/repp/v1/white_ips/:id' - desc 'Update whitelisted ip address' + desc 'Update whitelisted IP address' def update unless @white_ip.update(white_ip_params) handle_non_epp_errors(@white_ip) @@ -39,7 +39,7 @@ module Repp end api :DELETE, '/repp/v1/white_ips/:id' - desc 'Delete a specific whitelisted ip address' + desc 'Delete a specific whitelisted IP address' def destroy unless @white_ip.destroy handle_non_epp_errors(@white_ip) diff --git a/app/models/certificate.rb b/app/models/certificate.rb index e51dda2eb..085b4deff 100644 --- a/app/models/certificate.rb +++ b/app/models/certificate.rb @@ -5,15 +5,15 @@ class Certificate < ApplicationRecord belongs_to :api_user - SIGNED = 'signed' - UNSIGNED = 'unsigned' - EXPIRED = 'expired' - REVOKED = 'revoked' - VALID = 'valid' + SIGNED = 'signed'.freeze + UNSIGNED = 'unsigned'.freeze + EXPIRED = 'expired'.freeze + REVOKED = 'revoked'.freeze + VALID = 'valid'.freeze - API = 'api' - REGISTRAR = 'registrar' - INTERFACES = [API, REGISTRAR] + API = 'api'.freeze + REGISTRAR = 'registrar'.freeze + INTERFACES = [API, REGISTRAR].freeze scope 'api', -> { where(interface: API) } scope 'registrar', -> { where(interface: REGISTRAR) } @@ -21,6 +21,7 @@ class Certificate < ApplicationRecord validate :validate_csr_and_crt_presence def validate_csr_and_crt_presence return if csr.try(:scrub).present? || crt.try(:scrub).present? + errors.add(:base, I18n.t(:crt_or_csr_must_be_present)) end @@ -28,8 +29,8 @@ class Certificate < ApplicationRecord def validate_csr_and_crt parsed_crt parsed_csr - rescue OpenSSL::X509::RequestError, OpenSSL::X509::CertificateError - errors.add(:base, I18n.t(:invalid_csr_or_crt)) + rescue OpenSSL::X509::RequestError, OpenSSL::X509::CertificateError + errors.add(:base, I18n.t(:invalid_csr_or_crt)) end validate :assign_metadata, on: :create @@ -67,7 +68,8 @@ class Certificate < ApplicationRecord @cached_status = SIGNED - @cached_status = EXPIRED if parsed_crt.not_before > Time.zone.now.utc && parsed_crt.not_after < Time.zone.now.utc + expired = parsed_crt.not_before > Time.zone.now.utc && parsed_crt.not_after < Time.zone.now.utc + @cached_status = EXPIRED if expired 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) @@ -144,7 +146,8 @@ class Certificate < ApplicationRecord end def parse_md_from_string(crt) - return nil if crt.blank? + return if crt.blank? + crt = crt.split(' ').join("\n") crt.gsub!("-----BEGIN\nCERTIFICATE-----\n", "-----BEGIN CERTIFICATE-----\n") crt.gsub!("\n-----END\nCERTIFICATE-----", "\n-----END CERTIFICATE-----") diff --git a/lib/serializers/repp/api_user.rb b/lib/serializers/repp/api_user.rb index 08f15b106..43218b179 100644 --- a/lib/serializers/repp/api_user.rb +++ b/lib/serializers/repp/api_user.rb @@ -21,6 +21,8 @@ module Serializers accreditation_expire_date: obj.accreditation_expire_date, created_at: obj.created_at, updated_at: obj.updated_at, + creator: obj.creator_str, + updator: obj.updator_str, } json[:certificates] = certificates json