You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2022/08/29 15:15:00 UTC

[camel-k] 01/01: test: Add an E2E test for deploying an integration using secret key filtering

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

nfilotto pushed a commit to branch 3563/e2e-test-key-filtering
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit 304c0ae4ee0d81c0e35389da61749a5ccfe4a6dd
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Mon Aug 29 17:14:37 2022 +0200

    test: Add an E2E test for deploying an integration using secret key filtering
---
 e2e/global/common/config/config_test.go            | 15 +++++++++++++++
 .../config/files/config-secret-key-route.groovy    | 22 ++++++++++++++++++++++
 2 files changed, 37 insertions(+)

diff --git a/e2e/global/common/config/config_test.go b/e2e/global/common/config/config_test.go
index cda0c2990..011b0944d 100644
--- a/e2e/global/common/config/config_test.go
+++ b/e2e/global/common/config/config_test.go
@@ -167,6 +167,21 @@ func TestRunConfigExamples(t *testing.T) {
 			Eventually(AutogeneratedConfigmapsCount(ns), TestTimeoutShort).Should(Equal(0))
 		})
 
+		// Store a secret on the cluster with multi values
+		var secDataMulti = make(map[string]string)
+		secDataMulti["my-secret-key"] = "very top secret"
+		secDataMulti["my-secret-key-2"] = "even more secret"
+		CreatePlainTextSecret(ns, "my-sec-multi", secDataMulti)
+
+		t.Run("Secret with filtered key", func(t *testing.T) {
+			Expect(KamelRunWithID(operatorID, ns, "./files/config-secret-key-route.groovy", "--config", "secret:my-sec-multi/my-secret-key-2").Execute()).To(Succeed())
+			Eventually(IntegrationPodPhase(ns, "config-secret-key-route"), TestTimeoutLong).Should(Equal(corev1.PodRunning))
+			Eventually(IntegrationConditionStatus(ns, "config-secret-key-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+			Eventually(IntegrationLogs(ns, "config-secret-key-route"), TestTimeoutShort).ShouldNot(ContainSubstring(cmDataMulti["my-secret-key"]))
+			Eventually(IntegrationLogs(ns, "config-secret-key-route"), TestTimeoutShort).Should(ContainSubstring(cmDataMulti["my-secret-key-2"]))
+			Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+		})
+
 		// Resource File
 
 		t.Run("Plain text resource file", func(t *testing.T) {
diff --git a/e2e/global/common/config/files/config-secret-key-route.groovy b/e2e/global/common/config/files/config-secret-key-route.groovy
new file mode 100644
index 000000000..7fb448319
--- /dev/null
+++ b/e2e/global/common/config/files/config-secret-key-route.groovy
@@ -0,0 +1,22 @@
+// camel-k: language=groovy
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+ from('timer:secret')
+    .setBody()
+        .simple("resource:classpath:my-secret-key-2")
+    .log('secret content is: ${body}')
\ No newline at end of file