class Gitlab::QA::Component::LDAP

Constants

BOOTSTRAP_LDIF
DOCKER_IMAGE
DOCKER_IMAGE_TAG
FIXTURE_PATH
LDAP_PASSWORD
LDAP_USER

Public Class Methods

new() click to toggle source
Calls superclass method Gitlab::QA::Component::Base::new
# File lib/gitlab/qa/component/ldap.rb, line 26
def initialize
  super

  @volumes[FIXTURE_PATH] = BOOTSTRAP_LDIF
end

Public Instance Methods

instance() click to toggle source
Calls superclass method Gitlab::QA::Component::Base#instance
# File lib/gitlab/qa/component/ldap.rb, line 56
def instance
  raise 'Please provide a block!' unless block_given?

  super
end
name() click to toggle source
# File lib/gitlab/qa/component/ldap.rb, line 52
def name
  @name ||= "openldap-#{SecureRandom.hex(4)}"
end
password() click to toggle source
# File lib/gitlab/qa/component/ldap.rb, line 48
def password
  LDAP_PASSWORD
end
set_gitlab_credentials() click to toggle source

rubocop:enable Metrics/AbcSize

# File lib/gitlab/qa/component/ldap.rb, line 87
def set_gitlab_credentials
  ::Gitlab::QA::Runtime::Env.ldap_username = username
  ::Gitlab::QA::Runtime::Env.ldap_password = password
end
start() click to toggle source

rubocop:disable Metrics/AbcSize

# File lib/gitlab/qa/component/ldap.rb, line 63
def start
  # copy-service needed for bootstraping LDAP user:
  # https://github.com/osixia/docker-openldap#seed-ldap-database-with-ldif
  docker.run(image: image, tag: tag, args: ['--copy-service']) do |command|
    command << '-d '
    command << "--name #{name}"
    command << "--net #{network}"
    command << "--hostname #{hostname}"

    @volumes.to_h.each do |to, from|
      command.volume(to, from, 'Z')
    end

    @environment.to_h.each do |key, value|
      command.env(key, value)
    end

    @network_aliases.to_a.each do |network_alias|
      command << "--network-alias #{network_alias}"
    end
  end
end
tls=(status) click to toggle source

LDAP_TLS is true by default

# File lib/gitlab/qa/component/ldap.rb, line 33
def tls=(status)
  if status
    @environment['LDAP_TLS_CRT_FILENAME'] = "#{hostname}.crt"
    @environment['LDAP_TLS_KEY_FILENAME'] = "#{hostname}.key"
    @environment['LDAP_TLS_ENFORCE'] = 'true'
    @environment['LDAP_TLS_VERIFY_CLIENT'] = 'never'
  else
    @environment['LDAP_TLS'] = 'false'
  end
end
username() click to toggle source
# File lib/gitlab/qa/component/ldap.rb, line 44
def username
  LDAP_USER
end