Skip to content

Commit

Permalink
Use bootstrap token from vault to validate exec'ing into consul server (
Browse files Browse the repository at this point in the history
#1116)

Follow up on #1103
  • Loading branch information
ishustava authored and jmurret committed Mar 29, 2022
1 parent 61bae2b commit e38036e
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions acceptance/tests/vault/vault_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package vault

import (
"context"
"fmt"
"testing"

Expand All @@ -12,7 +11,6 @@ import (
"github.com/hashicorp/consul-k8s/acceptance/framework/logger"
"github.com/hashicorp/consul-k8s/acceptance/framework/vault"
"github.com/stretchr/testify/require"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const staticClientName = "static-client"
Expand Down Expand Up @@ -129,12 +127,8 @@ func TestVault(t *testing.T) {
require.Equal(t, caConfig.Provider, "vault")

// Validate that consul sever is running correctly and the consul members command works
tokenSecret, err := ctx.KubernetesClient(t).CoreV1().Secrets(ns).Get(context.Background(), fmt.Sprintf("%s-consul-bootstrap-acl-token", consulReleaseName), metav1.GetOptions{})
require.NoError(t, err)
token := string(tokenSecret.Data["token"])

logger.Log(t, "Confirming that we can run Consul commands when exec'ing into server container")
membersOutput, err := k8s.RunKubectlAndGetOutputWithLoggerE(t, ctx.KubectlOptions(t), terratestLogger.Discard, "exec", fmt.Sprintf("%s-consul-server-0", consulReleaseName), "-c", "consul", "--", "sh", "-c", fmt.Sprintf("CONSUL_HTTP_TOKEN=%s consul members", token))
membersOutput, err := k8s.RunKubectlAndGetOutputWithLoggerE(t, ctx.KubectlOptions(t), terratestLogger.Discard, "exec", fmt.Sprintf("%s-consul-server-0", consulReleaseName), "-c", "consul", "--", "sh", "-c", fmt.Sprintf("CONSUL_HTTP_TOKEN=%s consul members", bootstrapToken))
logger.Logf(t, "Members: \n%s", membersOutput)
require.NoError(t, err)
require.Contains(t, membersOutput, fmt.Sprintf("%s-consul-server-0", consulReleaseName))
Expand Down

0 comments on commit e38036e

Please sign in to comment.