- Added RAM and CPU resource display in the zero-scale dashboard for active applications. - Implemented dynamic updates for resource display based on application state. feat: expand zero-scale control script with new commands and options - Introduced `apply`, `upload-binary`, and `provision-db` commands to the zero-scale control script. - Added options for specifying configuration files, binary uploads, and database provisioning parameters. feat: implement temporal JWKS aggregator service - Created a new service to aggregate JWKS from Gitea and Kubernetes API. - Implemented caching and refresh logic for JWKS keys. feat: deploy shared MySQL and Redis services - Added Kubernetes manifests for shared MySQL and Redis services, including StatefulSet and ConfigMap definitions. - Configured persistent storage and resource limits for MySQL and Redis deployments. feat: add temporal OAuth secret example and values configuration - Created example secret manifest for OAuth credentials required by Temporal. - Added a values file for configuring Temporal server with JWKS integration and resource limits. feat: implement Kubernetes token provider for Temporal client - Developed a K8sTokenHeadersProvider to supply Kubernetes service account tokens to Temporal. - Added tests for token retrieval and environment variable fallback.
55 lines
1.4 KiB
Go
55 lines
1.4 KiB
Go
package temporal
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestK8sTokenHeadersProvider_File(t *testing.T) {
|
|
tempDir := t.TempDir()
|
|
tokenFile := filepath.Join(tempDir, "token")
|
|
expectedToken := "test-k8s-jwt-token-12345"
|
|
|
|
if err := os.WriteFile(tokenFile, []byte(expectedToken+"\n"), 0600); err != nil {
|
|
t.Fatalf("failed to write test token file: %v", err)
|
|
}
|
|
|
|
provider := NewK8sTokenHeadersProvider(tokenFile)
|
|
headers, err := provider.GetHeaders(context.Background())
|
|
if err != nil {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
|
|
authHeader, ok := headers["authorization"]
|
|
if !ok {
|
|
t.Fatalf("missing authorization header")
|
|
}
|
|
|
|
expectedHeader := "Bearer " + expectedToken
|
|
if authHeader != expectedHeader {
|
|
t.Errorf("got %q, want %q", authHeader, expectedHeader)
|
|
}
|
|
}
|
|
|
|
func TestK8sTokenHeadersProvider_EnvFallback(t *testing.T) {
|
|
tempDir := t.TempDir()
|
|
missingFile := filepath.Join(tempDir, "nonexistent")
|
|
|
|
expectedToken := "env-jwt-token-999"
|
|
t.Setenv("TEMPORAL_AUTH_TOKEN", expectedToken)
|
|
|
|
provider := NewK8sTokenHeadersProvider(missingFile)
|
|
headers, err := provider.GetHeaders(context.Background())
|
|
if err != nil {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
|
|
authHeader := headers["authorization"]
|
|
expectedHeader := "Bearer " + expectedToken
|
|
if authHeader != expectedHeader {
|
|
t.Errorf("got %q, want %q", authHeader, expectedHeader)
|
|
}
|
|
}
|