From 41e4dc90c3d83e9664b78e469c6daeb458673d8b Mon Sep 17 00:00:00 2001 From: Markus Rudy Date: Fri, 8 Mar 2024 17:30:30 +0100 Subject: [PATCH] e2e: call contrast set from Go --- .github/workflows/e2e_openssl.yml | 3 ++- e2e/openssl/openssl_test.go | 33 +++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e_openssl.yml b/.github/workflows/e2e_openssl.yml index 1cd2bc1583..24e50c4aa8 100644 --- a/.github/workflows/e2e_openssl.yml +++ b/.github/workflows/e2e_openssl.yml @@ -54,7 +54,8 @@ jobs: just get-credentials - name: Build, deploy, contrast generate, contrast set, contrast verify run: | - just default openssl contrast.cli + just coordinator initializer openssl + just deploy openssl contrast.cli - name: Setup Summary run: | cat ./workspace/just.namespace | tee -a "${GITHUB_STEP_SUMMARY}" diff --git a/e2e/openssl/openssl_test.go b/e2e/openssl/openssl_test.go index f79190cbfc..7d2d37229c 100644 --- a/e2e/openssl/openssl_test.go +++ b/e2e/openssl/openssl_test.go @@ -11,6 +11,7 @@ import ( "io" "os" "path" + "path/filepath" "testing" "time" @@ -35,6 +36,38 @@ func TestOpenSSL(t *testing.T) { namespace := os.Getenv(namespaceEnv) require.NotEmpty(t, namespace, "environment variable %q must be set", namespaceEnv) + require.True(t, t.Run("set", func(t *testing.T) { + require := require.New(t) + + ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute) + defer cancel() + + require.NoError(c.WaitForDeployment(ctx, namespace, "coordinator")) + + coordinator, cancelPortForward, err := c.PortForwardPod(ctx, namespace, "port-forwarder-coordinator", "1313") + require.NoError(err) + defer cancelPortForward() + + resources, err := filepath.Glob("../../workspace/deployment/*.yml") + require.NoError(err) + + args := []string{ + "--coordinator-policy-hash=", // TODO(burgerdev): enable policy checking + "--coordinator", coordinator, + "--workspace-dir", "../../workspace", + } + args = append(args, resources...) + + set := cmd.NewSetCmd() + set.Flags().String("workspace-dir", "", "") // Make set aware of root flags + set.SetArgs(args) + set.SetOut(io.Discard) + errBuf := &bytes.Buffer{} + set.SetErr(errBuf) + + require.NoError(set.Execute(), "could not set manifest at coordinator: %s", errBuf) + }), "contrast set needs to succeed for subsequent tests") + certs := make(map[string][]byte) require.True(t, t.Run("contrast verify", func(t *testing.T) {