Skip to content

Commit

Permalink
e2e: Fix syntax for commands to check cluster certs
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Riobo Lorenzo <[email protected]>
  • Loading branch information
adrianriobo authored and anjannath committed Sep 27, 2023
1 parent cc384f3 commit f8878c1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/e2e/features/story_openshift.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ Feature: 4 Openshift stories
Background:
Given ensuring CRC cluster is running
And ensuring oc command is available
And executing "oc config view --raw -o jsonpath="{.clusters[?(@.name=='api-crc-testing:6443')].cluster.certificate-authority-data}"| base64 -d - > ca.crt" succeeds
And executing "echo | openssl s_client -connect api.crc.testing:6443 | openssl x509 -out server.crt" succeeds
And executing "oc config view --raw -o jsonpath="{.clusters[?(@.name=='api-crc-testing:6443')].cluster.certificate-authority-data}" > ca.base64" succeeds
And decode base64 file "ca.base64" to "ca.crt"
And executing "echo QUIT | openssl s_client -connect api.crc.testing:6443 | openssl x509 -out server.crt" succeeds
And executing "openssl verify -CAfile ca.crt server.crt" succeeds
And ensuring user is logged in succeeds
Expand Down
13 changes: 13 additions & 0 deletions test/e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,8 @@ func InitializeScenario(s *godog.ScenarioContext) {
ConfigFileInCRCHomeContainsKey)
s.Step(`removing file "(.*)" from CRC home folder succeeds$`,
DeleteFileFromCRCHome)
s.Step(`^decode base64 file "(.*)" to "(.*)"$`,
DecodeBase64File)

s.After(func(ctx context.Context, sc *godog.Scenario, err error) (context.Context, error) {

Expand Down Expand Up @@ -978,3 +980,14 @@ func PullLoginTagPushImageSucceeds(image string) error {

return nil
}

// Decode a file encoded with base64
func DecodeBase64File(inputFile, outputFile string) error {
var cmd string
if runtime.GOOS == "windows" {
cmd = fmt.Sprintf("certutil.exe -decode %s %s", inputFile, outputFile)
} else {
cmd = fmt.Sprintf("base64 -d -i %s > %s", inputFile, outputFile)
}
return util.ExecuteCommandSucceedsOrFails(cmd, "succeeds")
}

0 comments on commit f8878c1

Please sign in to comment.