diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..7bdf8e7b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,124 @@ +# Release pipeline — triggered by pushing a v* tag. +# +# Produces, from the tagged commit and nothing else: +# 1. linux/amd64 + linux/arm64 binaries (CGO_ENABLED=0 — the Ceph RBD backend +# sits behind the `ceph` build tag, so cross-compilation needs no cgo) +# 2. a multi-arch container image pushed to ghcr.io +# 3. a GitHub Release with the binaries and their checksums +# 4. the Helm chart published as an OCI artifact (appVersion = the tag) +# +# Version stamping contract (review R1): the tag is injected with +# `-ldflags "-X main.Version="` and round-tripped through +# `lightstack --version` before anything is published. +name: Release + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + packages: write + +env: + GO_VERSION: '1.27.2' + +jobs: + test: + name: Test gate + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + - name: Run unit tests + run: make test + + release: + name: Build and publish + runs-on: ubuntu-latest + needs: test + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + + - name: Build binaries + run: | + VERSION="${GITHUB_REF_NAME}" + mkdir -p dist + for GOOS_GOARCH in linux/amd64 linux/arm64; do + GOOS="${GOOS_GOARCH%/*}" + GOARCH="${GOOS_GOARCH#*/}" + CGO_ENABLED=0 GOOS="$GOOS" GOARCH="$GOARCH" \ + go build -trimpath \ + -ldflags "-s -w -X main.Version=${VERSION}" \ + -o "dist/lightstack-${VERSION}-${GOOS}-${GOARCH}" ./cmd/lightstack + CGO_ENABLED=0 GOOS="$GOOS" GOARCH="$GOARCH" \ + go build -trimpath -s -w \ + -o "dist/lightstack-migrate-${VERSION}-${GOOS}-${GOARCH}" ./cmd/lightstack-migrate + done + + - name: Verify version stamping + # R1 regression guard: the Makefile used to inject -X main.Version + # into a variable that did not exist, which Go silently ignored. + run: | + VERSION="${GITHUB_REF_NAME}" + GOT="$(./dist/lightstack-${VERSION}-linux-amd64 --version)" + if [ "$GOT" != "$VERSION" ]; then + echo "::error::--version reported '${GOT}', expected '${VERSION}'" + exit 1 + fi + + - name: Checksums + run: cd dist && sha256sum * > "checksums-${GITHUB_REF_NAME}.txt" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push multi-arch image + uses: docker/build-push-action@v6 + with: + context: . + file: build/package/Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ghcr.io/${{ github.repository }}:${GITHUB_REF_NAME} + build-args: | + VERSION=${{ github.ref_name }} + VCS_REF=${{ github.sha }} + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + draft: true + generate_release_notes: true + files: | + dist/lightstack-* + dist/checksums-* + + - name: Publish Helm chart + env: + GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # The chart's own version (Chart.yaml `version`) is bumped per chart + # change in the repo; the app version is pinned to this release tag + # (and the image tag matches it, including the leading "v"). + CHART_VERSION="$(awk '/^version:/ {print $2}' charts/lightstack/Chart.yaml)" + helm package charts/lightstack --app-version "${GITHUB_REF_NAME}" -d dist/ + echo "${GHCR_TOKEN}" | helm registry login ghcr.io \ + -u "${{ github.actor }}" --password-stdin + helm push "dist/lightstack-${CHART_VERSION}.tgz" \ + "oci://ghcr.io/${{ github.repository_owner }}/charts" diff --git a/CHANGELOG.md b/CHANGELOG.md index b26f2fbf..d62c0ce9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 --- +## [Unreleased] + +### 🚀 Release Engineering +- **Version stamping** (review R1, `docs/review/comprehensive-review-report-2026-10-12.md`): + `main.Version` now exists and is injected via `-ldflags "-X main.Version=..."` by + the Makefile, the Dockerfile (`VERSION` build-arg) and the release workflow; + `lightstack --version` prints it and it is logged at startup. Previously the + ldflags injection targeted a nonexistent variable and was silently ignored — + every shipped binary was unidentifiable. +- **Release pipeline** (`.github/workflows/release.yml`, review R3): pushing a `v*` + tag runs the test gate, builds linux/amd64 + linux/arm64 binaries (CGO-free) with + checksums and a `--version` round-trip check, pushes the multi-arch image to + `ghcr.io`, creates a draft GitHub Release and publishes the Helm chart as an OCI + artifact with `appVersion` pinned to the tag. +- **Chart version** 0.3.0 → 0.4.0 (appVersion 0.7.0, matching the target release). + +### 🔒 Security +- **Refuse well-known/empty JWT secrets at startup** (review S2): the defaults + shipped in `config/lightstack.yaml` and `.env.example` are public, and with + stateless tokens knowing one is enough to mint an admin token. `LoadConfig` now + refuses them; `LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET=1` is the documented + escape hatch for isolated dev/test stacks (the plain docker-compose dev stack + and `make run` opt in explicitly; the Horizon stack and the Helm chart already + require a real secret). +- **Horizon default role** corrected: `OPENSTACK_KEYSTONE_DEFAULT_ROLE` is `member` + (matches the seeded admin/member/reader roles) — was `_member_`, which matches + nothing in the seed. + +--- + ## [0.6.1] - 2026-04-22 ### 📋 v0.7.0 Planning & Specifications diff --git a/CLAUDE.md b/CLAUDE.md index 95724641..578d53fb 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -80,9 +80,12 @@ openstack token issue ### Building and Running ```bash -# Build the main binary +# Build the main binary (version-stamped from git describe) make build # Outputs to bin/lightstack +# Check the build version +./bin/lightstack --version + # Run with configuration make run # Builds and starts with config/lightstack.yaml diff --git a/Makefile b/Makefile index 8c5915d5..3c49710e 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,12 @@ build-with-ebpf: build-ebpf build # Run the application run: build @echo "Starting lightstack..." - ./$(BUILD_DIR)/$(BINARY_NAME) --config config/lightstack.yaml --migrations migrations + # The dev escape hatch: the shipped config carries the well-known default + # JWT secret, which the binary refuses without this (review S2). `make run` + # is a local-development target only — production deployments set a real + # keystone.jwt_secret (or LIGHTSTACK_JWT_SECRET) and never set this. + LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET=1 \ + ./$(BUILD_DIR)/$(BINARY_NAME) --config config/lightstack.yaml --migrations migrations # Install dependencies install-deps: diff --git a/build/package/Dockerfile b/build/package/Dockerfile index 969e9c9a..83ec59ff 100644 --- a/build/package/Dockerfile +++ b/build/package/Dockerfile @@ -20,7 +20,7 @@ COPY . . # Build the binary for target architecture RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \ - go build -ldflags="-w -s" -o lightstack ./cmd/lightstack + go build -ldflags="-w -s -X main.Version=${VERSION}" -o lightstack ./cmd/lightstack # Build the migration tool for target architecture RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \ diff --git a/charts/lightstack/Chart.yaml b/charts/lightstack/Chart.yaml index b79fbce6..f092424a 100644 --- a/charts/lightstack/Chart.yaml +++ b/charts/lightstack/Chart.yaml @@ -4,7 +4,8 @@ description: Deploy lightstack (lightweight OpenStack-compatible cloud) on Kuber type: application # Chart version (SemVer). Bumped independently of the product. # 0.3.0: adds the noVNC console proxy + console-token settings (SPEC-021). -version: 0.3.0 +# 0.4.0: release-engineering alignment — appVersion 0.7.0 target, OCI publish via the tag-triggered release workflow. +version: 0.4.0 # Default product image tag when image.tag is unset (image.repository is REQUIRED, no default — FR-018). appVersion: "0.7.0" kubeVersion: ">=1.25.0-0" diff --git a/cmd/lightstack/config_test.go b/cmd/lightstack/config_test.go index fc351e16..fbd0580c 100644 --- a/cmd/lightstack/config_test.go +++ b/cmd/lightstack/config_test.go @@ -14,7 +14,8 @@ import ( // wrong directory, console-tokens would list and purge nothing. func TestLoadConfigAppliesStatePath(t *testing.T) { path := filepath.Join(t.TempDir(), "lightstack.yaml") - if err := os.WriteFile(path, []byte("state_path: /data/lightstack\n"), 0o600); err != nil { + if err := os.WriteFile(path, []byte( + "state_path: /data/lightstack\nkeystone:\n jwt_secret: test-secret-not-a-default\n"), 0o600); err != nil { t.Fatal(err) } t.Cleanup(func() { paths.SetBase(paths.DefaultBase) }) diff --git a/cmd/lightstack/main.go b/cmd/lightstack/main.go index ae52860e..bf051047 100644 --- a/cmd/lightstack/main.go +++ b/cmd/lightstack/main.go @@ -42,8 +42,17 @@ import ( var ( configPath = flag.String("config", "config/lightstack.yaml", "Path to configuration file") migrationsPath = flag.String("migrations", "migrations", "Path to migrations directory") + printVersion = flag.Bool("version", false, "Print the build version and exit") ) +// Version identifies the running build in the field: it is stamped at build +// time by the Makefile, the Dockerfile and the release workflow via +// `-ldflags "-X main.Version="`, and defaults to "dev" otherwise. +// R1 of docs/review/comprehensive-review-report-2026-10-12.md: without this +// variable the ldflags injection silently did nothing, making every shipped +// binary unidentifiable. +var Version = "dev" + func main() { // Subcommand dispatch: `lightstack cleanup` runs the SPEC-010 teardown and exits, // before flag.Parse (which would otherwise treat the subcommand as a positional). @@ -68,6 +77,15 @@ func main() { flag.Parse() + // `lightstack --version` reports the stamped build version and exits, so a + // node in the field can be identified without its deployment metadata. + if *printVersion { + fmt.Println(Version) + return + } + + log.Printf("lightstack %s starting", Version) + // Load configuration cfg, err := loadConfig(*configPath) if err != nil { diff --git a/deployments/docker-compose.yml b/deployments/docker-compose.yml index 58162781..99964137 100644 --- a/deployments/docker-compose.yml +++ b/deployments/docker-compose.yml @@ -65,6 +65,12 @@ services: LIGHTSTACK_REDIS_URL: "redis://redis:6379/0" LIGHTSTACK_CACHE_ENABLED: "true" LIGHTSTACK_JWT_SECRET: "${LIGHTSTACK_JWT_SECRET:-change-me-in-production}" + # The binary refuses the well-known default secret above unless this is + # set (review S2). This is the stub-mode development stack — no real + # guests, tokens never leave the host — so the escape hatch is + # acceptable here. NEVER set it where real guests or foreign clients + # reach the services: pass a real LIGHTSTACK_JWT_SECRET instead. + LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET: "true" LIGHTSTACK_ENDPOINT_HOST: "localhost" # Use localhost for service catalog URLs (accessible from host) # Why this exists: tests run outside any guest, so they name the instance they ask # the metadata service about with the X-Instance-ID header (test/contract/ws4_*, diff --git a/deployments/horizon-config/local_settings b/deployments/horizon-config/local_settings index 07869b25..362bc4e6 100644 --- a/deployments/horizon-config/local_settings +++ b/deployments/horizon-config/local_settings @@ -62,7 +62,7 @@ STATIC_URL = '/static/' # Lightstack Service Discovery OPENSTACK_HOST = "lightstack" # Docker service name OPENSTACK_KEYSTONE_URL = "http://%s:35357/v3" % OPENSTACK_HOST -OPENSTACK_KEYSTONE_DEFAULT_ROLE = "_member_" +OPENSTACK_KEYSTONE_DEFAULT_ROLE = "member" # matches the seeded roles (admin/member/reader) # API Version Configuration (Lightstack Flamingo Compatible) OPENSTACK_API_VERSIONS = { diff --git a/internal/common/config.go b/internal/common/config.go index f9602ec6..03bc1692 100644 --- a/internal/common/config.go +++ b/internal/common/config.go @@ -375,14 +375,49 @@ func LoadConfig(path string) (*Config, error) { cfg.Nova.ShutdownTimeout = MaxShutdownTimeout } - // Warn if using default JWT secret - if cfg.Keystone.JWTSecret == "change-me-in-production" { - fmt.Fprintln(os.Stderr, "WARNING: Using default JWT secret! Set LIGHTSTACK_JWT_SECRET environment variable in production.") + // Refuse well-known (or empty) JWT secrets unless explicitly overridden. + // The defaults below ship in this repository and in .env.example, so anyone + // can read them — and because tokens are stateless, knowing the secret is + // enough to mint an admin token for every service (review finding S2, + // docs/review/comprehensive-review-report-2026-10-12.md). The chart already + // fails fast on an empty secret; this gives the binary the same stance. + if isInsecureDefaultJWTSecret(cfg.Keystone.JWTSecret) && !allowInsecureDefaultJWTSecret() { + return nil, fmt.Errorf( + "keystone.jwt_secret is empty or a well-known default — refusing to start. " + + "Set keystone.jwt_secret in the config file (or the LIGHTSTACK_JWT_SECRET " + + "environment variable) to a random value, e.g. `openssl rand -base64 32`. " + + "For isolated development or test environments only, " + + "LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET=1 opts out of this check") } return &cfg, nil } +// insecureDefaultJWTSecrets are values that appear in this repository's shipped +// configuration and examples. An empty secret is equally forgeable (HMAC with a +// known key), so it is refused too. +var insecureDefaultJWTSecrets = map[string]struct{}{ + "": {}, + "change-me-in-production": {}, + "change-me-in-production-use-openssl-rand-base64-32": {}, +} + +func isInsecureDefaultJWTSecret(secret string) bool { + _, known := insecureDefaultJWTSecrets[secret] + return known +} + +// allowInsecureDefaultJWTSecret is the documented escape hatch for stub-mode +// development and test stacks that never validate a foreign token. +func allowInsecureDefaultJWTSecret() bool { + switch os.Getenv("LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET") { + case "1", "true": + return true + default: + return false + } +} + // maxRealModeStatePath keeps a guest's console socket path within QEMU's 108-byte // sun_path: 108 - len("/console-sockets/") - 36 (uuid) - len(".sock") = 50 (SPEC-021 // FR-017). Stub mode creates no sockets, so it is not limited. diff --git a/internal/common/config_test.go b/internal/common/config_test.go index 28427f78..cea62d58 100644 --- a/internal/common/config_test.go +++ b/internal/common/config_test.go @@ -9,6 +9,14 @@ import ( "time" ) +// allowInsecureDefaultSecret opts this test into the development escape hatch: +// these tests exercise unrelated config keys through minimal config files that +// do not set keystone.jwt_secret, which LoadConfig refuses by default (S2). +func allowInsecureDefaultSecret(t *testing.T) { + t.Helper() + t.Setenv("LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET", "1") +} + func TestLoadConfig(t *testing.T) { // Create a temporary config file tmpfile, err := os.CreateTemp("", "lightstack-test-*.yaml") @@ -134,6 +142,7 @@ logging: // keystone.rgw_compat_tenant_ids parses from YAML and defaults to false. func TestLoadConfigKeystoneRGWCompatTenantIDs(t *testing.T) { + allowInsecureDefaultSecret(t) tmp, err := os.CreateTemp("", "lightstack-rgwcompat-*.yaml") if err != nil { t.Fatal(err) @@ -157,6 +166,7 @@ func TestLoadConfigKeystoneRGWCompatTenantIDs(t *testing.T) { // directions (mirroring the Glance S3 boolean override); unrecognized values // keep the file value. func TestLoadConfigKeystoneRGWCompatTenantIDsEnvOverrides(t *testing.T) { + allowInsecureDefaultSecret(t) writeCfg := func(t *testing.T, on bool) string { t.Helper() tmp, err := os.CreateTemp("", "lightstack-rgwcompatenv-*.yaml") @@ -232,6 +242,7 @@ database: // SPEC-014 T031: the S3/RGW backend config (TLS/CA + timeout) parses from YAML. func TestLoadConfigGlanceS3(t *testing.T) { + allowInsecureDefaultSecret(t) tmp, err := os.CreateTemp("", "lightstack-s3-*.yaml") if err != nil { t.Fatal(err) @@ -265,6 +276,7 @@ glance: // SPEC-014 T031: LIGHTSTACK_GLANCE_S3_* env vars override the file config. func TestLoadConfigGlanceS3EnvOverrides(t *testing.T) { + allowInsecureDefaultSecret(t) tmp, err := os.CreateTemp("", "lightstack-s3env-*.yaml") if err != nil { t.Fatal(err) @@ -297,6 +309,7 @@ func TestLoadConfigGlanceS3EnvOverrides(t *testing.T) { // LIGHTSTACK_GLANCE_S3_INSECURE_SKIP_VERIFY=false — otherwise TLS verification stays off // in production with no way to turn it back on from the environment. func TestLoadConfigGlanceS3InsecureEnvCanDisable(t *testing.T) { + allowInsecureDefaultSecret(t) tmp, err := os.CreateTemp("", "lightstack-s3ins-*.yaml") if err != nil { t.Fatal(err) @@ -325,6 +338,7 @@ func TestLoadConfigGlanceS3InsecureEnvCanDisable(t *testing.T) { // node without patching a read-only mounted config. A malformed value is ignored (the // file value stands) rather than silently zeroing the timeout. func TestLoadConfigGlanceS3ConnectTimeoutEnv(t *testing.T) { + allowInsecureDefaultSecret(t) tmp, err := os.CreateTemp("", "lightstack-s3to-*.yaml") if err != nil { t.Fatal(err) @@ -363,6 +377,7 @@ func TestLoadConfigGlanceS3ConnectTimeoutEnv(t *testing.T) { // That is exactly the value upstream Nova's novncproxy_base_url takes, so it must be // refused at load rather than silently accepted or rewritten. func TestLoadConfigConsoleProxyBaseURL(t *testing.T) { + allowInsecureDefaultSecret(t) cases := []struct { value string wantErr bool @@ -425,6 +440,7 @@ func TestLoadConfigConsoleProxyBaseURL(t *testing.T) { // the same string, and a relative root has no meaning on the host. "/" is refused too — // cleanup purges the per-service subdirectories directly under it. func TestLoadConfigStatePath(t *testing.T) { + allowInsecureDefaultSecret(t) cases := []struct { name, yaml, want string wantErr bool @@ -466,6 +482,7 @@ func TestLoadConfigStatePath(t *testing.T) { // and QEMU refuses a socket path longer than 108 bytes, so a longer root would stop every // guest from starting. Stub mode creates no sockets and is not limited (SPEC-021 FR-017). func TestLoadConfigStatePathLengthInRealMode(t *testing.T) { + allowInsecureDefaultSecret(t) root50 := "/" + strings.Repeat("a", 49) root51 := "/" + strings.Repeat("a", 50) for _, tc := range []struct { @@ -504,6 +521,7 @@ func TestLoadConfigStatePathLengthInRealMode(t *testing.T) { // false turns consoles off, which is what the chart renders wherever it deploys no // proxy (multi-node, or consoleProxy.enabled=false). func TestLoadConfigConsoleEnabled(t *testing.T) { + allowInsecureDefaultSecret(t) for _, tc := range []struct { name, yaml string want bool @@ -533,6 +551,7 @@ func TestLoadConfigConsoleEnabled(t *testing.T) { // the interval goes straight to time.NewTicker in the token reconciler, which panics on // a non-positive duration, and a zero TTL would issue tokens that are already expired. func TestLoadConfigConsoleDurations(t *testing.T) { + allowInsecureDefaultSecret(t) for _, tc := range []struct { name, yaml string ttl, interval time.Duration @@ -568,6 +587,7 @@ func TestLoadConfigConsoleDurations(t *testing.T) { // instance's metadata and user-data. Test stacks turn it on from the environment, and // the override works both ways, like every other boolean one. func TestLoadConfigMetadataTrustInstanceHeader(t *testing.T) { + allowInsecureDefaultSecret(t) for _, tc := range []struct { name, file, env string want bool @@ -600,6 +620,7 @@ func TestLoadConfigMetadataTrustInstanceHeader(t *testing.T) { // the console settings — a deployment that never heard of either still reconciles // drift and still bounds its audit growth. func TestLoadConfigComputeIntervalDefaults(t *testing.T) { + allowInsecureDefaultSecret(t) write := func(t *testing.T, body string) string { t.Helper() p := filepath.Join(t.TempDir(), "lightstack.yaml") @@ -684,6 +705,7 @@ nova: // stop had worked; it just could never say so. Which is the exact failure class the // feature exists to remove, reintroduced one layer down. func TestShutdownTimeoutFitsInsideTheWriteDeadline(t *testing.T) { + allowInsecureDefaultSecret(t) // The invariant, as arithmetic on the constants. This is the assertion that would // have caught the defect before it reached a host: a default that cannot answer is // a default that is wrong, and nothing else in the suite compares these two. @@ -770,3 +792,70 @@ func TestShutdownTimeoutFitsInsideTheWriteDeadline(t *testing.T) { } }) } + +// writeTestConfig persists body to a temp config file and returns its path. +func writeTestConfig(t *testing.T, body string) string { + t.Helper() + tmp, err := os.CreateTemp("", "lightstack-cfg-*.yaml") + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { os.Remove(tmp.Name()) }) + if _, err := tmp.WriteString(body); err != nil { + t.Fatal(err) + } + if err := tmp.Close(); err != nil { + t.Fatal(err) + } + return tmp.Name() +} + +// TestLoadConfigRefusesInsecureDefaultJWTSecret pins the S2 guard: the secrets +// shipped in this repository's config and examples are public, and tokens are +// stateless — knowing one is enough to mint an admin token for every service. +func TestLoadConfigRefusesInsecureDefaultJWTSecret(t *testing.T) { + for _, secret := range []string{ + "", // omitted from the file + "change-me-in-production", // config/lightstack.yaml + "change-me-in-production-use-openssl-rand-base64-32", // .env.example + } { + body := "keystone:\n jwt_secret: \"" + secret + "\"\n" + _, err := LoadConfig(writeTestConfig(t, body)) + if err == nil { + t.Errorf("LoadConfig accepted jwt_secret %q; want refusal", secret) + continue + } + if !strings.Contains(err.Error(), "refusing to start") { + t.Errorf("LoadConfig(%q) error does not explain the refusal: %v", secret, err) + } + } +} + +// TestLoadConfigAllowsInsecureDefaultSecretWithOverride pins the documented +// escape hatch for isolated development and test stacks. +func TestLoadConfigAllowsInsecureDefaultSecretWithOverride(t *testing.T) { + for _, opt := range []string{"1", "true"} { + t.Run("opt="+opt, func(t *testing.T) { + t.Setenv("LIGHTSTACK_ALLOW_INSECURE_DEFAULT_SECRET", opt) + cfg, err := LoadConfig(writeTestConfig(t, "keystone:\n jwt_secret: \"change-me-in-production\"\n")) + if err != nil { + t.Fatalf("LoadConfig with override %q: %v", opt, err) + } + if cfg.Keystone.JWTSecret != "change-me-in-production" { + t.Errorf("JWTSecret = %q; want it passed through unchanged", cfg.Keystone.JWTSecret) + } + }) + } +} + +// TestLoadConfigAcceptsARandomSecret is the positive control for the guard: a +// non-default secret loads without any opt-in. +func TestLoadConfigAcceptsARandomSecret(t *testing.T) { + cfg, err := LoadConfig(writeTestConfig(t, "keystone:\n jwt_secret: \"k4FNxqKmLwW3ZRFvMscJ0d1oO5gYhN\"\n")) + if err != nil { + t.Fatalf("LoadConfig: %v", err) + } + if cfg.Keystone.JWTSecret != "k4FNxqKmLwW3ZRFvMscJ0d1oO5gYhN" { + t.Errorf("JWTSecret = %q; want it preserved", cfg.Keystone.JWTSecret) + } +}