You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2024/03/25 14:19:01 UTC

(camel-k) branch main updated: Add optional install to tests

This is an automated email from the ASF dual-hosted git repository.

pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git


The following commit(s) were added to refs/heads/main by this push:
     new 7e52419aa Add optional install to tests
7e52419aa is described below

commit 7e52419aa80f5544fc7b46d9d0e09fdf596b23de
Author: Lucie Krejcirova <lf...@redhat.com>
AuthorDate: Mon Mar 25 12:19:04 2024 +0100

    Add optional install to tests
---
 e2e/support/test_support.go | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/e2e/support/test_support.go b/e2e/support/test_support.go
index 4f527a3ee..bc2d726cc 100644
--- a/e2e/support/test_support.go
+++ b/e2e/support/test_support.go
@@ -27,6 +27,7 @@ import (
 	"bytes"
 	"context"
 	"encoding/json"
+	"encoding/pem"
 	"errors"
 	"fmt"
 	"io"
@@ -332,6 +333,13 @@ func kamelInstallWithContext(t *testing.T, ctx context.Context, operatorID strin
 		fmt.Printf("Setting operator image pull policy to %s\n", opImagePullPolicy)
 		installArgs = append(installArgs, "--operator-image-pull-policy", opImagePullPolicy)
 	}
+	if len(os.Getenv("CAMEL_K_TEST_MAVEN_CA_PEM_PATH")) > 0 {
+		certName := "myCert"
+		secretName := "maven-ca-certs"
+		CreateSecretDecoded(t, ctx, namespace, os.Getenv("CAMEL_K_TEST_MAVEN_CA_PEM_PATH"), secretName, certName)
+		installArgs = append(installArgs, "--maven-repository", os.Getenv("KAMEL_INSTALL_MAVEN_REPOSITORIES"),
+			"--maven-ca-secret", secretName+"/"+certName)
+	}
 
 	installArgs = append(installArgs, args...)
 	installCommand := KamelWithContext(t, ctx, installArgs...)
@@ -1758,6 +1766,26 @@ func DeleteSecret(t *testing.T, ctx context.Context, ns string, name string) err
 	return TestClient(t).Delete(ctx, &sec)
 }
 
+func CreateSecretDecoded(t *testing.T, ctx context.Context, ns string, pathToFile string, secretName string, certName string) error {
+	bytes, _ := os.ReadFile(pathToFile)
+	block, _ := pem.Decode(bytes)
+
+	secret := corev1.Secret{
+		TypeMeta: metav1.TypeMeta{
+			Kind:       "Secret",
+			APIVersion: corev1.SchemeGroupVersion.String(),
+		},
+		ObjectMeta: metav1.ObjectMeta{
+			Namespace: ns,
+			Name:      secretName,
+		},
+		Data: map[string][]byte{
+			certName: block.Bytes,
+		},
+	}
+	return TestClient(t).Create(ctx, &secret)
+}
+
 func KnativeService(t *testing.T, ctx context.Context, ns string, name string) func() *servingv1.Service {
 	return func() *servingv1.Service {
 		answer := servingv1.Service{