Skip to content

Commit

Permalink
changes var name from keystore id to cloud id and refactors cucumber …
Browse files Browse the repository at this point in the history
…tests accordingly

es for cloud id
  • Loading branch information
luispresuelVenafi committed Jun 3, 2024
1 parent a6c362e commit 23ba91f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Feature: provision to cloud keystore
And I remember the output
And I use previous Pickup ID to provision from VCP a certificate to cloudkeystore "<cloudkeystore>" setting keystore and provider names
And I remember the output
And it should output keystore ID
And it should output cloud ID
Then I clean up previous installed certificate from cloudkeystore
Examples:
| cloudkeystore |
Expand All @@ -23,7 +23,7 @@ Feature: provision to cloud keystore
And I remember the output
And I use previous Pickup ID to provision from VCP a certificate to cloudkeystore "<cloudkeystore>" setting keystore and provider names with -format json
And I remember the output
And it should output keystore ID in JSON
And it should output cloud ID in JSON
Then I clean up previous installed certificate from cloudkeystore
Examples:
| cloudkeystore |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,29 +51,29 @@ def build_provision_cmd(platform, cloudkeystore_type, keystore_provider_names, f
return cmd
end

Then(/^it should output keystore ID( in JSON)?$/) do |json|
Then(/^it should output cloud ID( in JSON)?$/) do |json|

if @previous_command_output.nil?
fail(ArgumentError.new('@previous_command_output is nil'))
end

Kernel.puts("Checking output:\n"+@previous_command_output)
keystore_id = ""
cloud_id = ""
case @cloudkeystore_type
when $keystore_type_aws
when $keystore_type_azure
when $keystore_type_gcp
keystore_id = "gcpId"
cloud_id = "gcpId"
else
fail(ArgumentError.new("Unexpected : #{@cloudkeystore_type}"))
end
if json
json_string = extract_json_from_output(@previous_command_output)
JSON.parse(json_string)
@keystore_id = unescape_text(normalize_json(json_string, "#{keystore_id}")).tr('"', '')
@cloud_id = unescape_text(normalize_json(json_string, "#{cloud_id}")).tr('"', '')
else
m = @previous_command_output.match /#{keystore_id} (.+)$/
@keystore_id = m[1]
m = @previous_command_output.match /#{cloud_id} (.+)$/
@cloud_id = m[1]
end
end

Expand All @@ -90,6 +90,6 @@ def build_provision_cmd(platform, cloudkeystore_type, keystore_provider_names, f

def cleanup_google
client = create_certificate_manager_client
certificate_name = "projects/#{ENV['GCP_PROJECT']}/locations/#{ENV['GCP_REGION']}/certificates/#{@keystore_id}"
certificate_name = "projects/#{ENV['GCP_PROJECT']}/locations/#{ENV['GCP_REGION']}/certificates/#{@cloud_id}"
delete_certificate(client, certificate_name)
end

0 comments on commit 23ba91f

Please sign in to comment.