-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds logic for google provider cucumber tests. removes unused gemfile…
…. adds new file to be gitignored
- Loading branch information
1 parent
690f6b4
commit a6c362e
Showing
12 changed files
with
206 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,4 @@ aruba/log.log | |
credentials | ||
*.DS_Store | ||
vendor | ||
google_auth.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
aruba/features/provision/cloudkeystore/provision_cloudkeystore.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
@VAAS | ||
Feature: provision to cloud keystore | ||
|
||
As a user | ||
I want provision certificates to cloud keystore from Venafi Control Plane | ||
|
||
Background: | ||
And the default aruba exit timeout is 180 seconds | ||
|
||
Scenario Outline: Enroll certificate and execute provisioning for cloud keystore | ||
Given I enroll a random certificate with defined platform VCP with -csr service -no-prompt | ||
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 | ||
Then I clean up previous installed certificate from cloudkeystore | ||
Examples: | ||
| cloudkeystore | | ||
| GOOGLE | | ||
|
||
Scenario Outline: Enroll certificate and execute provisioning for cloud keystore and get output in JSON | ||
Given I enroll a random certificate with defined platform VCP with -csr service -no-prompt | ||
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 | ||
Then I clean up previous installed certificate from cloudkeystore | ||
Examples: | ||
| cloudkeystore | | ||
| GOOGLE | |
95 changes: 95 additions & 0 deletions
95
aruba/features/provision/cloudkeystore/steps_definitions/my_steps.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
And(/^I use previous Pickup ID to provision (?:from|using) (\S+) a certificate to cloudkeystore "(.*)"( setting keystore and provider names)?$/) do |platform, cloudkeystore_type, keystore_provider_names| | ||
|
||
cmd = build_provision_cmd(platform, cloudkeystore_type, keystore_provider_names) | ||
|
||
steps %{Then I try to run `#{cmd}`} | ||
end | ||
|
||
And(/^I use previous Pickup ID to provision (?:from|using) (\S+) a certificate to cloudkeystore "(.*)"( setting keystore and provider names)? with (.+)?/) do |platform, cloudkeystore_type, keystore_provider_names, flags| | ||
|
||
cmd = build_provision_cmd(platform, cloudkeystore_type, keystore_provider_names, flags) | ||
|
||
steps %{Then I try to run `#{cmd}`} | ||
end | ||
|
||
def build_provision_cmd(platform, cloudkeystore_type, keystore_provider_names, flags = "") | ||
|
||
platform_flag = " -platform " + platform | ||
|
||
cmd = "vcert provision cloudkeystore #{platform_flag} #{ENDPOINTS[$platform_vcp]} -pickup-id #{@pickup_id}" | ||
|
||
keystore_name = "" | ||
provider_name = "" | ||
keystore_id = "" | ||
case cloudkeystore_type | ||
when $keystore_type_azure | ||
when $keystore_type_gcp | ||
if keystore_provider_names | ||
keystore_name = $gcp_keystore_name | ||
provider_name = $gcp_provider_name | ||
@cloudkeystore_type = $keystore_type_gcp | ||
else | ||
keystore_id = $gcp_keystore_id | ||
end | ||
else | ||
fail(ArgumentError.new("Unexpected : #{cloudkeystore_type}")) | ||
end | ||
if keystore_provider_names | ||
keystore_name_flag = " -keystore-name '#{keystore_name}'" | ||
provider_name_flag = " -provider-name '#{provider_name}'" | ||
|
||
cmd = "#{cmd} #{keystore_name_flag} #{provider_name_flag}" | ||
else | ||
keystore_id_flag = " -keystore-id " + keystore_id | ||
cmd = "#{cmd} #{keystore_id_flag}" | ||
end | ||
|
||
if flags != "" | ||
cmd += " #{flags}" | ||
end | ||
|
||
return cmd | ||
end | ||
|
||
Then(/^it should output keystore 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 = "" | ||
case @cloudkeystore_type | ||
when $keystore_type_aws | ||
when $keystore_type_azure | ||
when $keystore_type_gcp | ||
keystore_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('"', '') | ||
else | ||
m = @previous_command_output.match /#{keystore_id} (.+)$/ | ||
@keystore_id = m[1] | ||
end | ||
end | ||
|
||
And(/^I clean up previous installed certificate from cloudkeystore/) do || | ||
case @cloudkeystore_type | ||
when $keystore_type_aws | ||
when $keystore_type_azure | ||
when $keystore_type_gcp | ||
cleanup_google | ||
else | ||
fail(ArgumentError.new("Unexpected : #{@cloudkeystore_type}")) | ||
end | ||
end | ||
|
||
def cleanup_google | ||
client = create_certificate_manager_client | ||
certificate_name = "projects/#{ENV['GCP_PROJECT']}/locations/#{ENV['GCP_REGION']}/certificates/#{@keystore_id}" | ||
delete_certificate(client, certificate_name) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'google/cloud/certificate_manager/v1' | ||
|
||
# Set the environment variable for Google Cloud credentials | ||
ENV['GOOGLE_APPLICATION_CREDENTIALS'] = ENV['GCP_AUTH_PATH'] | ||
|
||
# Initialize the Certificate Manager Client | ||
def create_certificate_manager_client | ||
Google::Cloud::CertificateManager::V1::CertificateManager::Client.new | ||
end | ||
|
||
# Delete a certificate | ||
def delete_certificate(client, certificate_name) | ||
request = Google::Cloud::CertificateManager::V1::DeleteCertificateRequest.new( | ||
name: certificate_name | ||
) | ||
|
||
operation = client.delete_certificate(request) | ||
operation.wait_until_done! | ||
|
||
if operation.error? | ||
puts "Error deleting certificate: #{operation.error.message}" | ||
else | ||
puts "Certificate deleted successfully." | ||
end | ||
end |