Class: Gitlab::QA::Component::SAML
- Inherits:
-
Object
- Object
- Gitlab::QA::Component::SAML
- Includes:
- Scenario::Actable
- Defined in:
- lib/gitlab/qa/component/saml.rb
Constant Summary collapse
- SAML_IMAGE =
'jamedjo/test-saml-idp'.freeze
- SAML_IMAGE_TAG =
'latest'.freeze
Instance Attribute Summary collapse
-
#docker ⇒ Object
readonly
Returns the value of attribute docker.
-
#environment ⇒ Object
Returns the value of attribute environment.
- #name ⇒ Object
-
#network ⇒ Object
Returns the value of attribute network.
-
#volumes ⇒ Object
Returns the value of attribute volumes.
Instance Method Summary collapse
- #add_network_alias(name) ⇒ Object
- #group_name ⇒ Object
- #hostname ⇒ Object
-
#initialize ⇒ SAML
constructor
A new instance of SAML.
- #instance ⇒ Object
- #prepare ⇒ Object
- #pull ⇒ Object
-
#restart ⇒ Object
rubocop:enable Metrics/AbcSize.
- #set_assertion_consumer_service(assertion_con_service) ⇒ Object
- #set_entity_id(entity_id) ⇒ Object
- #set_sandbox_name(sandbox_name) ⇒ Object
- #set_simple_saml_hostname ⇒ Object
-
#start ⇒ Object
rubocop:disable Metrics/AbcSize.
- #teardown ⇒ Object
Methods included from Scenario::Actable
Constructor Details
Instance Attribute Details
#docker ⇒ Object (readonly)
Returns the value of attribute docker.
15 16 17 |
# File 'lib/gitlab/qa/component/saml.rb', line 15 def docker @docker end |
#environment ⇒ Object
Returns the value of attribute environment.
16 17 18 |
# File 'lib/gitlab/qa/component/saml.rb', line 16 def environment @environment end |
#name ⇒ Object
38 39 40 |
# File 'lib/gitlab/qa/component/saml.rb', line 38 def name @name ||= "saml-qa-idp" end |
#network ⇒ Object
Returns the value of attribute network.
16 17 18 |
# File 'lib/gitlab/qa/component/saml.rb', line 16 def network @network end |
#volumes ⇒ Object
Returns the value of attribute volumes.
16 17 18 |
# File 'lib/gitlab/qa/component/saml.rb', line 16 def volumes @volumes end |
Instance Method Details
#add_network_alias(name) ⇒ Object
34 35 36 |
# File 'lib/gitlab/qa/component/saml.rb', line 34 def add_network_alias(name) @network_aliases.push(name) end |
#group_name ⇒ Object
46 47 48 |
# File 'lib/gitlab/qa/component/saml.rb', line 46 def group_name @group_name ||= "saml_sso_group-#{SecureRandom.hex(4)}" end |
#hostname ⇒ Object
42 43 44 |
# File 'lib/gitlab/qa/component/saml.rb', line 42 def hostname "#{name}.#{network}" end |
#instance ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/gitlab/qa/component/saml.rb', line 50 def instance raise 'Please provide a block!' unless block_given? prepare start yield self ensure teardown end |
#prepare ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/gitlab/qa/component/saml.rb', line 61 def prepare pull return if @docker.network_exists?(network) @docker.network_create(network) end |
#pull ⇒ Object
105 106 107 |
# File 'lib/gitlab/qa/component/saml.rb', line 105 def pull @docker.pull(SAML_IMAGE, SAML_IMAGE_TAG) end |
#restart ⇒ Object
rubocop:enable Metrics/AbcSize
94 95 96 |
# File 'lib/gitlab/qa/component/saml.rb', line 94 def restart @docker.restart(name) end |
#set_assertion_consumer_service(assertion_con_service) ⇒ Object
30 31 32 |
# File 'lib/gitlab/qa/component/saml.rb', line 30 def set_assertion_consumer_service(assertion_con_service) @environment['SIMPLESAMLPHP_SP_ASSERTION_CONSUMER_SERVICE'] = assertion_con_service end |
#set_entity_id(entity_id) ⇒ Object
26 27 28 |
# File 'lib/gitlab/qa/component/saml.rb', line 26 def set_entity_id(entity_id) @environment['SIMPLESAMLPHP_SP_ENTITY_ID'] = entity_id end |
#set_sandbox_name(sandbox_name) ⇒ Object
109 110 111 |
# File 'lib/gitlab/qa/component/saml.rb', line 109 def set_sandbox_name(sandbox_name) ::Gitlab::QA::Runtime::Env.gitlab_sandbox_name = sandbox_name end |
#set_simple_saml_hostname ⇒ Object
113 114 115 |
# File 'lib/gitlab/qa/component/saml.rb', line 113 def set_simple_saml_hostname ::Gitlab::QA::Runtime::Env.simple_saml_hostname = hostname end |
#start ⇒ Object
rubocop:disable Metrics/AbcSize
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/gitlab/qa/component/saml.rb', line 70 def start docker.run(SAML_IMAGE, SAML_IMAGE_TAG) do |command| command << '-d ' command << "--name #{name}" command << "--net #{network}" command << "--hostname #{hostname}" command << "--publish 8080:8080" command << "--publish 8443:8443" @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
98 99 100 101 102 103 |
# File 'lib/gitlab/qa/component/saml.rb', line 98 def teardown raise 'Invalid instance name!' unless name @docker.stop(name) @docker.remove(name) end |