File: enable_ssl_verification.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (33 lines) | stat: -rw-r--r-- 1,034 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# frozen_string_literal: true

module Integrations
  module EnableSslVerification
    extend ActiveSupport::Concern

    prepended do
      field :enable_ssl_verification,
        type: :checkbox,
        title: -> { s_('Integrations|SSL verification') },
        checkbox_label: -> { s_('Integrations|Enable SSL verification') },
        help: -> { s_('Integrations|Clear if using a self-signed certificate.') },
        description: -> { s_('Enable SSL verification. Defaults to `true` (enabled).') }
    end

    def initialize_properties
      super

      self.enable_ssl_verification = true if new_record? && enable_ssl_verification.nil?
    end

    def fields
      super.tap do |fields|
        url_index = fields.index { |field| field[:name].ends_with?('_url') }
        insert_index = url_index || -1

        enable_ssl_verification_index = fields.index { |field| field[:name] == 'enable_ssl_verification' }

        fields.insert(insert_index, fields.delete_at(enable_ssl_verification_index))
      end
    end
  end
end