Files
larksuite__cli/internal/runtimebootstrap/bootstrap_architecture_test.go
zhaoyukun.yk 4dfe1b7dc0 feat(auth): support managed external credentials
Add Extended-only direct, credential-proxy, and platform-proxy modes while keeping Standard behavior and external-credential product details isolated behind source-neutral runtime capabilities.

Fail closed across helper execution, proxy routing, streams, managed file transfers, and unsupported event flows. Harden system configuration, edition updates, and release publication.

Cover Standard compatibility and Extended integration with contract tests, repository-local three-mode E2E, native trust checks, and CI and release gates.
2026-08-12 14:55:41 +08:00

60 lines
1.5 KiB
Go

// Copyright (c) 2026 Lark Technologies Pte. Ltd.
// SPDX-License-Identifier: MIT
package runtimebootstrap
import (
"go/parser"
"go/token"
"path/filepath"
"strconv"
"strings"
"testing"
"github.com/larksuite/cli/internal/vfs"
)
const externalCredentialImplementation = "github.com/larksuite/cli/internal/externalcredential"
func TestOnlyExtendedSelectorImportsExternalCredentialImplementation(t *testing.T) {
entries, err := vfs.ReadDir(".")
if err != nil {
t.Fatal(err)
}
var extendedSelectorImportsAdapter bool
for _, entry := range entries {
if entry.IsDir() ||
!strings.HasSuffix(entry.Name(), ".go") ||
strings.HasSuffix(entry.Name(), "_test.go") {
continue
}
path := filepath.Join(".", entry.Name())
src, err := vfs.ReadFile(path)
if err != nil {
t.Fatal(err)
}
file, err := parser.ParseFile(token.NewFileSet(), path, src, parser.ImportsOnly)
if err != nil {
t.Fatalf("parse %s: %v", path, err)
}
for _, spec := range file.Imports {
importPath, err := strconv.Unquote(spec.Path.Value)
if err != nil {
t.Fatalf("parse import in %s: %v", path, err)
}
if importPath != externalCredentialImplementation {
continue
}
if entry.Name() != "selector_extended.go" {
t.Errorf("%s imports the external credential implementation; Standard bootstrap must stay product-neutral", path)
continue
}
extendedSelectorImportsAdapter = true
}
}
if !extendedSelectorImportsAdapter {
t.Fatal("selector_extended.go must remain the explicit external credential composition edge")
}
}