bf9395e022
CI / results (push) Blocked by required conditions
CI / license-header (push) Has been skipped
CI / e2e-dry-run (push) Has been skipped
CI / e2e-live (push) Waiting to run
CI / fast-gate (push) Failing after 0s
Test PR Label Logic / test-pr-labels (push) Failing after 1s
Skill Format Check / check-format (push) Failing after 2s
CI / security (push) Failing after 5s
CI / unit-test (push) Has been skipped
CI / lint (push) Has been skipped
CI / script-test (push) Has been skipped
CI / deterministic-gate (push) Has been skipped
CI / coverage (push) Has been skipped
CI / deadcode (push) Waiting to run
53 lines
1.3 KiB
Go
53 lines
1.3 KiB
Go
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
//go:build !authsidecar
|
|
|
|
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/larksuite/cli/internal/envvars"
|
|
)
|
|
|
|
func TestCheckNoAuthsidecarBuild_Unset(t *testing.T) {
|
|
var stderr bytes.Buffer
|
|
code := checkNoAuthsidecarBuild(func(string) string { return "" }, &stderr)
|
|
if code != 0 {
|
|
t.Errorf("exit code = %d, want 0 when AUTH_PROXY is unset", code)
|
|
}
|
|
if stderr.Len() != 0 {
|
|
t.Errorf("stderr should be empty, got %q", stderr.String())
|
|
}
|
|
}
|
|
|
|
// TestCheckNoAuthsidecarBuild_Set verifies that deploying a plain build into
|
|
// a sandbox that expects sidecar isolation fails loudly at startup instead
|
|
// of silently leaking credentials through the env provider path.
|
|
func TestCheckNoAuthsidecarBuild_Set(t *testing.T) {
|
|
var stderr bytes.Buffer
|
|
env := func(k string) string {
|
|
if k == envvars.CliAuthProxy {
|
|
return "http://127.0.0.1:16384"
|
|
}
|
|
return ""
|
|
}
|
|
code := checkNoAuthsidecarBuild(env, &stderr)
|
|
if code == 0 {
|
|
t.Fatal("expected non-zero exit code when AUTH_PROXY is set")
|
|
}
|
|
msg := stderr.String()
|
|
for _, want := range []string{
|
|
envvars.CliAuthProxy,
|
|
"authsidecar", // build-tag name must appear so operators can act on it
|
|
"rebuild",
|
|
} {
|
|
if !strings.Contains(msg, want) {
|
|
t.Errorf("stderr message missing %q; got:\n%s", want, msg)
|
|
}
|
|
}
|
|
}
|