Allow override of discovery URL via ConfigMap

Signed-off-by: Andrew Keesler <akeesler@vmware.com>

- Seems like the next step is to allow override of the CA bundle; I didn't
  do that here for simplicity of the commit, but seems like it is the right
  thing to do in the future.
This commit is contained in:
Andrew Keesler
2020-08-03 10:17:11 -04:00
parent 548874a641
commit 597408a977
14 changed files with 167 additions and 49 deletions

View File

@@ -7,7 +7,6 @@ package integration
import (
"context"
"os"
"strings"
"testing"
"time"
@@ -52,8 +51,7 @@ O2D8LtWhMbrYy755Fgq4H9s3vCgfvHY1AQ==
)
func TestClient(t *testing.T) {
tmcClusterToken := os.Getenv("PLACEHOLDER_NAME_TMC_CLUSTER_TOKEN")
require.NotEmptyf(t, tmcClusterToken, "must specify PLACEHOLDER_NAME_TMC_CLUSTER_TOKEN env var for integration tests")
tmcClusterToken := library.Getenv(t, "PLACEHOLDER_NAME_TMC_CLUSTER_TOKEN")
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

View File

@@ -7,7 +7,6 @@ package integration
import (
"context"
"os"
"testing"
"time"
@@ -20,11 +19,8 @@ import (
)
func TestGetDeployment(t *testing.T) {
namespaceName := os.Getenv("PLACEHOLDER_NAME_NAMESPACE")
require.NotEmptyf(t, namespaceName, "must specify PLACEHOLDER_NAME_NAMESPACE env var for integration tests")
deploymentName := os.Getenv("PLACEHOLDER_NAME_DEPLOYMENT")
require.NotEmptyf(t, deploymentName, "must specify PLACEHOLDER_NAME_DEPLOYMENT env var for integration tests")
namespaceName := library.Getenv(t, "PLACEHOLDER_NAME_NAMESPACE")
deploymentName := library.Getenv(t, "PLACEHOLDER_NAME_DEPLOYMENT")
client := library.NewClientset(t)

View File

@@ -8,7 +8,6 @@ package integration
import (
"context"
"encoding/base64"
"os"
"testing"
"time"
@@ -21,8 +20,8 @@ import (
)
func TestSuccessfulLoginDiscoveryConfig(t *testing.T) {
namespaceName := os.Getenv("PLACEHOLDER_NAME_NAMESPACE")
require.NotEmptyf(t, namespaceName, "must specify PLACEHOLDER_NAME_NAMESPACE env var for integration tests")
namespaceName := library.Getenv(t, "PLACEHOLDER_NAME_NAMESPACE")
discoveryURL := library.Getenv(t, "PLACEHOLDER_NAME_DISCOVERY_URL")
client := library.NewPlaceholderNameClientset(t)
@@ -30,7 +29,7 @@ func TestSuccessfulLoginDiscoveryConfig(t *testing.T) {
defer cancel()
config := library.NewClientConfig(t)
expectedLDCSpec := expectedLDCSpec(config)
expectedLDCSpec := expectedLDCSpec(config, discoveryURL)
configList, err := client.
CrdsV1alpha1().
LoginDiscoveryConfigs(namespaceName).
@@ -41,8 +40,8 @@ func TestSuccessfulLoginDiscoveryConfig(t *testing.T) {
}
func TestReconcilingLoginDiscoveryConfig(t *testing.T) {
namespaceName := os.Getenv("PLACEHOLDER_NAME_NAMESPACE")
require.NotEmptyf(t, namespaceName, "must specify PLACEHOLDER_NAME_NAMESPACE env var for integration tests")
namespaceName := library.Getenv(t, "PLACEHOLDER_NAME_NAMESPACE")
discoveryURL := library.Getenv(t, "PLACEHOLDER_NAME_DISCOVERY_URL")
client := library.NewPlaceholderNameClientset(t)
@@ -56,7 +55,7 @@ func TestReconcilingLoginDiscoveryConfig(t *testing.T) {
require.NoError(t, err)
config := library.NewClientConfig(t)
expectedLDCSpec := expectedLDCSpec(config)
expectedLDCSpec := expectedLDCSpec(config, discoveryURL)
var actualLDC *crdsplaceholderv1alpha1.LoginDiscoveryConfig
for i := 0; i < 10; i++ {
@@ -73,9 +72,9 @@ func TestReconcilingLoginDiscoveryConfig(t *testing.T) {
require.Equal(t, expectedLDCSpec, &actualLDC.Spec)
}
func expectedLDCSpec(config *rest.Config) *crdsplaceholderv1alpha1.LoginDiscoveryConfigSpec {
func expectedLDCSpec(config *rest.Config, discoveryURL string) *crdsplaceholderv1alpha1.LoginDiscoveryConfigSpec {
return &crdsplaceholderv1alpha1.LoginDiscoveryConfigSpec{
Server: "https://kind-control-plane:6443", //config.Host, // TODO FIX THIS
Server: discoveryURL,
CertificateAuthorityData: base64.StdEncoding.EncodeToString(config.TLSClientConfig.CAData),
}
}

View File

@@ -8,7 +8,6 @@ package integration
import (
"context"
"net/http"
"os"
"testing"
"time"
@@ -37,8 +36,7 @@ func makeRequest(t *testing.T, spec v1alpha1.LoginRequestSpec) (*v1alpha1.LoginR
}
func TestSuccessfulLoginRequest(t *testing.T) {
tmcClusterToken := os.Getenv("PLACEHOLDER_NAME_TMC_CLUSTER_TOKEN")
require.NotEmptyf(t, tmcClusterToken, "must specify PLACEHOLDER_NAME_TMC_CLUSTER_TOKEN env var for integration tests")
tmcClusterToken := library.Getenv(t, "PLACEHOLDER_NAME_TMC_CLUSTER_TOKEN")
response, err := makeRequest(t, v1alpha1.LoginRequestSpec{
Type: v1alpha1.TokenLoginCredentialType,