Files
dingtalk-workspace-cli/pkg/config/constants_test.go
T
wxianfeng 93d6fdb17e feat: edition layer for Wukong overlay; promote shared code to pkg/
Introduce a build-time edition hook so downstream overlays (e.g. Wukong)
can customize auth UX, config dir, static server list, visible products,
and extra root commands while keeping the default open-source behavior.

- Add pkg/edition (defaults) and pkg/editiontest contract tests; Makefile
  target edition-test; CI job edition-tests.
- Root: optional RegisterExtraCommands with tool caller adapter; inject
  static servers to skip market discovery when configured; deduplicate
  top-level commands so overlay wins; extend hideNonDirectRuntimeCommands
  with edition VisibleProducts and static commands (recovery/schema/mcp).
- Auth/config: gate login subcommand and auth login hints for embedded
  editions; optional token auto-purge; edition ConfigDir override.
- version: human-readable multi-line output plus JSON with edition,
  architecture, build, commit.
- Relocate internal/{config,convert,validate} to pkg/; add pkg/cli and
  pkg/cmdutil (flags/time helpers).
- CI: optional notify-downstream job (GitLab trigger via secrets) on main
  push; open_source_policy_test adjusted for new layout.

Secrets (repo settings): WUKONG_TRIGGER_TOKEN, WUKONG_TRIGGER_URL — optional;
if unset, downstream step is skipped.

Made-with: Cursor
2026-03-31 15:29:21 +08:00

138 lines
3.3 KiB
Go

package config
import (
"testing"
"time"
)
func TestDirPerm(t *testing.T) {
t.Parallel()
if DirPerm != 0o700 {
t.Fatalf("DirPerm = %o, want 700", DirPerm)
}
}
func TestFilePerm(t *testing.T) {
t.Parallel()
if FilePerm != 0o600 {
t.Fatalf("FilePerm = %o, want 600", FilePerm)
}
}
func TestHTTPTimeout(t *testing.T) {
t.Parallel()
if HTTPTimeout <= 0 {
t.Fatalf("HTTPTimeout = %v, want positive", HTTPTimeout)
}
if HTTPTimeout != 30*time.Second {
t.Fatalf("HTTPTimeout = %v, want 30s", HTTPTimeout)
}
}
func TestOAuthTimeout(t *testing.T) {
t.Parallel()
if OAuthTimeout <= 0 {
t.Fatalf("OAuthTimeout = %v, want positive", OAuthTimeout)
}
if OAuthTimeout != 15*time.Second {
t.Fatalf("OAuthTimeout = %v, want 15s", OAuthTimeout)
}
}
func TestDiscoveryTimeout(t *testing.T) {
t.Parallel()
if DiscoveryTimeout <= 0 {
t.Fatalf("DiscoveryTimeout = %v, want positive", DiscoveryTimeout)
}
if DiscoveryTimeout != 10*time.Second {
t.Fatalf("DiscoveryTimeout = %v, want 10s", DiscoveryTimeout)
}
}
func TestLockTimeout(t *testing.T) {
t.Parallel()
if LockTimeout <= 0 {
t.Fatalf("LockTimeout = %v, want positive", LockTimeout)
}
if LockTimeout != 10*time.Second {
t.Fatalf("LockTimeout = %v, want 10s", LockTimeout)
}
}
func TestMaxResponseBodySize(t *testing.T) {
t.Parallel()
want := 10 * 1024 * 1024
if MaxResponseBodySize != want {
t.Fatalf("MaxResponseBodySize = %d, want %d (10MB)", MaxResponseBodySize, want)
}
}
func TestDefaultPartition(t *testing.T) {
t.Parallel()
if DefaultPartition != "default/default" {
t.Fatalf("DefaultPartition = %q, want %q", DefaultPartition, "default/default")
}
}
func TestManualTokenExpiry(t *testing.T) {
t.Parallel()
if ManualTokenExpiry <= 0 {
t.Fatalf("ManualTokenExpiry = %v, want positive", ManualTokenExpiry)
}
if ManualTokenExpiry != 24*time.Hour {
t.Fatalf("ManualTokenExpiry = %v, want 24h", ManualTokenExpiry)
}
}
func TestDeviceFlowTimeout(t *testing.T) {
t.Parallel()
if DeviceFlowTimeout <= 0 {
t.Fatalf("DeviceFlowTimeout = %v, want positive", DeviceFlowTimeout)
}
if DeviceFlowTimeout != 16*time.Minute {
t.Fatalf("DeviceFlowTimeout = %v, want 16m", DeviceFlowTimeout)
}
}
func TestOAuthFlowTimeout(t *testing.T) {
t.Parallel()
if OAuthFlowTimeout <= 0 {
t.Fatalf("OAuthFlowTimeout = %v, want positive", OAuthFlowTimeout)
}
if OAuthFlowTimeout != 6*time.Minute {
t.Fatalf("OAuthFlowTimeout = %v, want 6m", OAuthFlowTimeout)
}
}
func TestDefaultAccessTokenExpiry(t *testing.T) {
t.Parallel()
if DefaultAccessTokenExpiry != 7200 {
t.Fatalf("DefaultAccessTokenExpiry = %d, want 7200", DefaultAccessTokenExpiry)
}
}
func TestDefaultRefreshTokenLifetime(t *testing.T) {
t.Parallel()
if DefaultRefreshTokenLifetime <= 0 {
t.Fatalf("DefaultRefreshTokenLifetime = %v, want positive", DefaultRefreshTokenLifetime)
}
if DefaultRefreshTokenLifetime != 30*24*time.Hour {
t.Fatalf("DefaultRefreshTokenLifetime = %v, want 720h", DefaultRefreshTokenLifetime)
}
}
func TestDefaultFetchServersLimit(t *testing.T) {
t.Parallel()
if DefaultFetchServersLimit != 200 {
t.Fatalf("DefaultFetchServersLimit = %d, want 200", DefaultFetchServersLimit)
}
}
func TestMaxUploadFileSize(t *testing.T) {
t.Parallel()
var want int64 = 100 * 1024 * 1024
if MaxUploadFileSize != want {
t.Fatalf("MaxUploadFileSize = %d, want %d (100MB)", MaxUploadFileSize, want)
}
}