Class: Gitlab::QA::Component::LDAP
- Defined in:
- lib/gitlab/qa/component/ldap.rb
Constant Summary collapse
- DOCKER_IMAGE =
'osixia/openldap'.freeze
- DOCKER_IMAGE_TAG =
'latest'.freeze
- LDAP_USER =
'tanuki'.freeze
- LDAP_PASSWORD =
'password'.freeze
- BOOTSTRAP_LDIF =
'/container/service/slapd/assets/config/bootstrap/ldif/custom'.freeze
- FIXTURE_PATH =
File.('../../../../fixtures/ldap'.freeze, __dir__)
Instance Attribute Summary
Attributes inherited from Base
#docker, #environment, #network, #runner_network, #volumes
Instance Method Summary collapse
-
#initialize ⇒ LDAP
constructor
A new instance of LDAP.
- #instance ⇒ Object
- #name ⇒ Object
- #password ⇒ Object
-
#set_gitlab_credentials ⇒ Object
rubocop:enable Metrics/AbcSize.
-
#start ⇒ Object
rubocop:disable Metrics/AbcSize.
-
#tls=(status) ⇒ Object
LDAP_TLS is true by default.
- #username ⇒ Object
Methods inherited from Base
#add_network_alias, #hostname, #image, #prepare, #prepare_docker_image, #prepare_network, #process_exec_commands, #pull, #restart, #tag, #teardown, #teardown!
Methods included from Scenario::Actable
Constructor Details
#initialize ⇒ LDAP
Returns a new instance of LDAP.
26 27 28 29 30 |
# File 'lib/gitlab/qa/component/ldap.rb', line 26 def initialize super @volumes[FIXTURE_PATH] = BOOTSTRAP_LDIF end |
Instance Method Details
#instance ⇒ Object
56 57 58 59 60 |
# File 'lib/gitlab/qa/component/ldap.rb', line 56 def instance raise 'Please provide a block!' unless block_given? super end |
#name ⇒ Object
52 53 54 |
# File 'lib/gitlab/qa/component/ldap.rb', line 52 def name @name ||= "openldap-#{SecureRandom.hex(4)}" end |
#password ⇒ Object
48 49 50 |
# File 'lib/gitlab/qa/component/ldap.rb', line 48 def password LDAP_PASSWORD end |
#set_gitlab_credentials ⇒ Object
rubocop:enable Metrics/AbcSize
87 88 89 90 |
# 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 ⇒ Object
rubocop:disable Metrics/AbcSize
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# 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, tag, '--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) ⇒ Object
LDAP_TLS is true by default
33 34 35 36 37 38 39 40 41 42 |
# 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 ⇒ Object
44 45 46 |
# File 'lib/gitlab/qa/component/ldap.rb', line 44 def username LDAP_USER end |