Class: Gitlab::QA::Scenario::Test::Integration::LDAP

Inherits:
Gitlab::QA::Scenario::Template show all
Defined in:
lib/gitlab/qa/scenario/test/integration/ldap.rb

Direct Known Subclasses

LDAPNoServer, LDAPNoTLS, LDAPTLS

Constant Summary collapse

LDAP_PORT =
389
LDAP_TLS_PORT =
636
BASE_DN =
'dc=example,dc=org'.freeze
BIND_DN =
'cn=admin,dc=example,dc=org'.freeze
GROUP_BASE =
'ou=Global Groups,dc=example,dc=org'.freeze
ADMIN_GROUP =
'AdminGroup'.freeze
ADMIN_USER =
'admin'.freeze
ADMIN_PASSWORD =
'admin'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Gitlab::QA::Scenario::Template

perform

Constructor Details

#initializeLDAP

Returns a new instance of LDAP.



20
21
22
23
# File 'lib/gitlab/qa/scenario/test/integration/ldap.rb', line 20

def initialize
  @ldap_name = 'ldap-server'
  @network = 'test'
end

Instance Attribute Details

#gitlab_nameObject (readonly)

Returns the value of attribute gitlab_name.



18
19
20
# File 'lib/gitlab/qa/scenario/test/integration/ldap.rb', line 18

def gitlab_name
  @gitlab_name
end

#ldap_nameObject (readonly)

Returns the value of attribute ldap_name.



18
19
20
# File 'lib/gitlab/qa/scenario/test/integration/ldap.rb', line 18

def ldap_name
  @ldap_name
end

#networkObject (readonly)

Returns the value of attribute network.



18
19
20
# File 'lib/gitlab/qa/scenario/test/integration/ldap.rb', line 18

def network
  @network
end

#orchestrate_ldap_serverObject (readonly)

Returns the value of attribute orchestrate_ldap_server.



18
19
20
# File 'lib/gitlab/qa/scenario/test/integration/ldap.rb', line 18

def orchestrate_ldap_server
  @orchestrate_ldap_server
end

#spec_suiteObject (readonly)

Returns the value of attribute spec_suite.



18
19
20
# File 'lib/gitlab/qa/scenario/test/integration/ldap.rb', line 18

def spec_suite
  @spec_suite
end

#tlsObject (readonly)

Returns the value of attribute tls.



18
19
20
# File 'lib/gitlab/qa/scenario/test/integration/ldap.rb', line 18

def tls
  @tls
end

Instance Method Details

#configure_omnibus(gitlab) ⇒ Object

Raises:

  • (NotImplementedError)


25
26
27
# File 'lib/gitlab/qa/scenario/test/integration/ldap.rb', line 25

def configure_omnibus(gitlab)
  raise NotImplementedError
end

#ldap_hostnameObject



52
53
54
# File 'lib/gitlab/qa/scenario/test/integration/ldap.rb', line 52

def ldap_hostname
  "#{ldap_name}.#{network}"
end

#ldap_servers_omnibus_configObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/gitlab/qa/scenario/test/integration/ldap.rb', line 29

def ldap_servers_omnibus_config
  config = YAML.safe_load <<~CFG
    main:
      label: LDAP
      host: #{ldap_hostname}
      port: #{tls ? LDAP_TLS_PORT : LDAP_PORT}
      uid: 'uid'
      bind_dn: #{BIND_DN}
      password: #{ADMIN_PASSWORD}
      encryption: #{tls ? 'simple_tls' : 'plain'}
      verify_certificates: false
      base: #{BASE_DN}
      user_filter: ''
      group_base: #{GROUP_BASE}
      admin_group: #{ADMIN_GROUP}
      external_groups: ''
      sync_ssh_keys: false
  CFG

  # Quotes get eaten up when the string is set in the environment
  config.to_s.gsub("\"", "\\\"")
end

#orchestrate_ldapObject



70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/gitlab/qa/scenario/test/integration/ldap.rb', line 70

def orchestrate_ldap
  Component::LDAP.perform do |ldap|
    ldap.name = 'ldap-server'
    ldap.network = 'test'
    ldap.set_gitlab_credentials
    ldap.tls = tls

    ldap.instance do
      yield
    end
  end
end

#perform(release, *rspec_args) ⇒ Object



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/gitlab/qa/scenario/test/integration/ldap.rb', line 83

def perform(release, *rspec_args)
  Component::Gitlab.perform do |gitlab|
    gitlab.release = release
    gitlab.name = gitlab_name
    gitlab.network = 'test'
    gitlab.tls = tls
    configure_omnibus(gitlab)

    if orchestrate_ldap_server
      orchestrate_ldap { run_specs(gitlab, {}, *rspec_args) }
    else
      volumes = { 'admin': File.join(Docker::Volumes::QA_CONTAINER_WORKDIR, 'qa/fixtures/ldap/admin'),
                  'non_admin': File.join(Docker::Volumes::QA_CONTAINER_WORKDIR, 'qa/fixtures/ldap/non_admin') }
      run_specs(gitlab, volumes, *rspec_args)
    end
  end
end

#run_specs(gitlab, volumes = {}, *rspec_args) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/gitlab/qa/scenario/test/integration/ldap.rb', line 56

def run_specs(gitlab, volumes = {}, *rspec_args)
  gitlab.instance do
    puts "Running #{spec_suite} specs!"

    Component::Specs.perform do |specs|
      specs.suite = spec_suite
      specs.release = gitlab.release
      specs.network = gitlab.network
      specs.args = [gitlab.address, *rspec_args]
      specs.volumes = volumes
    end
  end
end