account_codex_cli_only_app_server_test.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package service
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/require"
  5. )
  6. func TestAccount_IsCodexCLIOnlyAppServerAllowed(t *testing.T) {
  7. t.Run("codex_cli_only 开 + allow_app_server=true → true", func(t *testing.T) {
  8. account := &Account{
  9. Platform: PlatformOpenAI,
  10. Type: AccountTypeOAuth,
  11. Extra: map[string]any{"codex_cli_only": true, "codex_cli_only_allow_app_server": true},
  12. }
  13. require.True(t, account.IsCodexCLIOnlyAppServerAllowed())
  14. })
  15. t.Run("codex_cli_only 开 + allow_app_server=false → false", func(t *testing.T) {
  16. account := &Account{
  17. Platform: PlatformOpenAI,
  18. Type: AccountTypeOAuth,
  19. Extra: map[string]any{"codex_cli_only": true, "codex_cli_only_allow_app_server": false},
  20. }
  21. require.False(t, account.IsCodexCLIOnlyAppServerAllowed())
  22. })
  23. t.Run("codex_cli_only 开 + 字段缺失 → false", func(t *testing.T) {
  24. account := &Account{
  25. Platform: PlatformOpenAI,
  26. Type: AccountTypeOAuth,
  27. Extra: map[string]any{"codex_cli_only": true},
  28. }
  29. require.False(t, account.IsCodexCLIOnlyAppServerAllowed())
  30. })
  31. t.Run("codex_cli_only 关 → 即便 allow_app_server=true 也 false", func(t *testing.T) {
  32. account := &Account{
  33. Platform: PlatformOpenAI,
  34. Type: AccountTypeOAuth,
  35. Extra: map[string]any{"codex_cli_only_allow_app_server": true},
  36. }
  37. require.False(t, account.IsCodexCLIOnlyAppServerAllowed())
  38. })
  39. }