cmd/k8s-operator/e2e: support local devcontrol

Change-Id: Ia199605da7f9de940fc526900c65a3e08c5eac2a
Signed-off-by: Tom Proctor <tomhjp@users.noreply.github.com>
tomhjp/k8s-e2e
Tom Proctor 2 months ago
parent aa5b2ce83b
commit f4ffc32e42
No known key found for this signature in database

@ -73,8 +73,7 @@ func TestIngress(t *testing.T) {
Name: "test-ingress",
Namespace: "default",
Annotations: map[string]string{
"tailscale.com/expose": "true",
"tailscale.com/proxy-class": "prod",
"tailscale.com/expose": "true",
},
},
Spec: corev1.ServiceSpec{

@ -6,6 +6,7 @@ package e2e
import (
"context"
"errors"
"fmt"
"log"
"os"
"strings"
@ -43,6 +44,10 @@ func TestMain(m *testing.M) {
func runTests(m *testing.M) (int, error) {
secret := os.Getenv("TS_API_CLIENT_SECRET")
loginServer := os.Getenv("TS_LOGIN_SERVER")
if loginServer == "" {
loginServer = "https://login.tailscale.com"
}
if secret != "" {
secretParts := strings.Split(secret, "-")
if len(secretParts) != 4 {
@ -52,11 +57,12 @@ func runTests(m *testing.M) (int, error) {
credentials := clientcredentials.Config{
ClientID: secretParts[2],
ClientSecret: secret,
TokenURL: "https://login.tailscale.com/api/v2/oauth/token",
TokenURL: fmt.Sprintf("%s/api/v2/oauth/token", loginServer),
Scopes: []string{"auth_keys"},
}
apiClient = tailscale.NewClient("-", nil)
apiClient.HTTPClient = credentials.Client(ctx)
apiClient.BaseURL = loginServer
caps := tailscale.KeyCapabilities{
Devices: tailscale.KeyDeviceCapabilities{
@ -76,10 +82,11 @@ func runTests(m *testing.M) (int, error) {
defer apiClient.DeleteKey(context.Background(), authKeyMeta.ID)
tailnetClient = &tsnet.Server{
Hostname: "test-proxy",
Ephemeral: true,
Store: &mem.Store{},
AuthKey: authKey,
ControlURL: loginServer,
Hostname: "test-proxy",
Ephemeral: true,
Store: &mem.Store{},
AuthKey: authKey,
}
_, err = tailnetClient.Up(ctx)
if err != nil {

Loading…
Cancel
Save