Class: Gitlab::QA::Component::LDAP
- Defined in:
- lib/gitlab/qa/component/ldap.rb
Constant Summary collapse
- DOCKER_IMAGE =
'osixia/openldap'
- DOCKER_IMAGE_TAG =
'latest'
- LDAP_USER =
'tanuki'
- LDAP_PASSWORD =
'password'
- BOOTSTRAP_LDIF =
'/container/service/slapd/assets/config/bootstrap/ldif/custom'
- FIXTURE_PATH =
File.('../../../../fixtures/ldap', __dir__)
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
#additional_hosts, #airgapped_network, #docker, #environment, #logger, #network, #network_aliases, #ports, #runner_network, #secrets, #volumes
Instance Method Summary collapse
- #instance ⇒ Object
- #name ⇒ Object
- #password ⇒ Object
- #prepare ⇒ Object
-
#set_gitlab_credentials ⇒ Object
rubocop:enable Metrics/AbcSize.
-
#start ⇒ Object
rubocop:disable Metrics/AbcSize.
- #teardown! ⇒ Object
-
#tls=(status) ⇒ Object
LDAP_TLS is true by default.
- #username ⇒ Object
Methods inherited from Base
#add_network_alias, #hostname, #image, #initialize, #ip_address, #prepare_airgapped_network, #prepare_docker_container, #prepare_docker_image, #prepare_network, #prepare_runner_network, #process_exec_commands, #pull, #restart, #start_instance, #tag, #teardown
Methods included from Scenario::Actable
Constructor Details
This class inherits a constructor from Gitlab::QA::Component::Base
Instance Method Details
#instance ⇒ Object
52 53 54 55 56 |
# File 'lib/gitlab/qa/component/ldap.rb', line 52 def instance raise 'Please provide a block!' unless block_given? super end |
#name ⇒ Object
48 49 50 |
# File 'lib/gitlab/qa/component/ldap.rb', line 48 def name @name ||= "openldap-#{SecureRandom.hex(4)}" end |
#password ⇒ Object
44 45 46 |
# File 'lib/gitlab/qa/component/ldap.rb', line 44 def password LDAP_PASSWORD end |
#prepare ⇒ Object
58 59 60 61 62 63 |
# File 'lib/gitlab/qa/component/ldap.rb', line 58 def prepare copy_fixtures @volumes["#{working_dir_tmp_fixture_path}/ldap"] = BOOTSTRAP_LDIF super end |
#set_gitlab_credentials ⇒ Object
rubocop:enable Metrics/AbcSize
96 97 98 99 |
# File 'lib/gitlab/qa/component/ldap.rb', line 96 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
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/gitlab/qa/component/ldap.rb', line 72 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 |
#teardown! ⇒ Object
65 66 67 68 69 |
# File 'lib/gitlab/qa/component/ldap.rb', line 65 def teardown! FileUtils.rm_rf(working_dir_tmp_fixture_path) super end |
#tls=(status) ⇒ Object
LDAP_TLS is true by default
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/gitlab/qa/component/ldap.rb', line 29 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
40 41 42 |
# File 'lib/gitlab/qa/component/ldap.rb', line 40 def username LDAP_USER end |