github.com/Venafi/vcert/v5@v5.10.2/aruba/features/firefly/step_definitions/my_steps.rb (about) 1 2 When(/^I( interactively)? get credentials from "(.*)"(?: with)?(.+)?$/) do |interactively, identity_provider, flags| 3 4 idp_token_url = "" 5 idp_user = "" 6 idp_password = "" 7 idp_client_id = "" 8 idp_client_secret = "" 9 idp_scope = "" 10 11 case identity_provider 12 when "Okta" 13 idp_token_url = "#{ENV['OKTA_AUTH_SERVER']}/v1/token" 14 idp_user = ENV['OKTA_CREDS_USR'] 15 idp_password = ENV['OKTA_CREDS_PSW'] 16 if flags === " username and no password" || flags === " username and password" 17 idp_client_id = ENV['OKTA_CLIENT_ID_PASS'] 18 else 19 idp_client_id = ENV['OKTA_CLIENT_ID'] 20 end 21 idp_client_secret = ENV['OKTA_CLIENT_SECRET'] 22 idp_scope = ENV['OKTA_SCOPE'] 23 else 24 fail(ArgumentError.new("Unknown Identity Provider: #{identity_provider}")) 25 end 26 27 if flags === " username and no password" 28 cmd = "vcert getcred -platform oidc -u '#{idp_token_url}' -client-id '#{idp_client_id}'" + 29 " -username '#{idp_user}' -scope '#{idp_scope}'" 30 elsif flags === " username and password" 31 cmd = "vcert getcred -platform oidc -u '#{idp_token_url}' -client-id '#{idp_client_id}'" + 32 " -username '#{idp_user}' -password '#{idp_password}' -scope '#{idp_scope}'" 33 else 34 # client id is our default 35 cmd = "vcert getcred -platform oidc -u '#{idp_token_url}'" + 36 " -client-id '#{idp_client_id}' -client-secret #{idp_client_secret} -scope '#{idp_scope}' #{flags}" 37 end 38 39 if interactively 40 Kernel.puts cmd 41 steps %{ 42 Then I run `#{cmd}` interactively 43 And I type "#{idp_password}" 44 Then the exit status should be 0 45 } 46 else 47 steps %{ 48 Then I try to run `#{cmd}` 49 } 50 end 51 end