Download test/kiro_config_test.go from shimen/API: direct link, hf CLI and curl.
- Browser
- Download file 2.17 kB
-
https://huggingface.co/spaces/shimen/API/resolve/main/test/kiro_config_test.go
- Command line
-
hf download hf://spaces/shimen/API/test/kiro_config_test.go
-
curl -L -o kiro_config_test.go https://huggingface.co/spaces/shimen/API/resolve/main/test/kiro_config_test.go
2.17 kB
| package test | |
| import ( | |
| "os" | |
| "testing" | |
| "time" | |
| "github.com/router-for-me/CLIProxyAPI/v6/internal/config" | |
| "github.com/router-for-me/CLIProxyAPI/v6/internal/watcher/synthesizer" | |
| "github.com/stretchr/testify/assert" | |
| ) | |
| func TestKiroConfigLoading(t *testing.T) { | |
| configContent := ` | |
| host: "0.0.0.0" | |
| port: 7860 | |
| auth-dir: "/tmp/auth" | |
| debug: false | |
| kiro-api-key: | |
| - refresh-token: "aorAAAAAGnwiEAK6Czi4DuKwiaLfGiKxrp4usf6puI-cHxFt4ysq-g_DuZ31NuBDMm-2hWgOrAVmd9Po4JurqgvwwBkc0:MGUCMG3+h7e7DoPosRyv35ph6d+R7XCgKf8cfMR4S65arNVN4minOq7EvLchzIF2Kk8ZCAIxANmoJr9GihJuFqEwg+G+NgTxHRYMitngFT4NGnz5+7gto5oxE1oK2cL83+M4iHRj4Q" | |
| region: "us-east-1" | |
| oauth-model-alias: | |
| antigravity: | |
| - name: rev19-uic3-1p | |
| alias: gemini-2.5-computer-use-preview-10-2025 | |
| ` | |
| tmpFile, err := os.CreateTemp("", "config-*.yaml") | |
| assert.NoError(t, err) | |
| defer os.Remove(tmpFile.Name()) | |
| _, err = tmpFile.WriteString(configContent) | |
| assert.NoError(t, err) | |
| tmpFile.Close() | |
| // Load config | |
| cfg, err := config.LoadConfig(tmpFile.Name()) | |
| assert.NoError(t, err) | |
| assert.NotNil(t, cfg) | |
| // Check KiroKey | |
| assert.Len(t, cfg.KiroKey, 1) | |
| assert.Equal(t, "us-east-1", cfg.KiroKey[0].Region) | |
| assert.Contains(t, cfg.KiroKey[0].RefreshToken, "aorAAAAA") | |
| // Check OAuthModelAlias | |
| assert.Contains(t, cfg.OAuthModelAlias, "antigravity") | |
| assert.Len(t, cfg.OAuthModelAlias["antigravity"], 1) // Only one alias actually? User provided 7. | |
| // Wait, LoadConfig might have issues if YAML structure is complex. | |
| // Let's check why I asserted 1. | |
| // The provided yaml has 7 aliases. | |
| // Synthesize Auth | |
| synth := synthesizer.NewConfigSynthesizer() | |
| ctx := &synthesizer.SynthesisContext{ | |
| Config: cfg, | |
| Now: time.Now(), | |
| IDGenerator: synthesizer.NewStableIDGenerator(), | |
| } | |
| auths, err := synth.Synthesize(ctx) | |
| assert.NoError(t, err) | |
| // Find Kiro auth | |
| var kiroAuthFound bool | |
| for _, a := range auths { | |
| if a.Provider == "kiro" { | |
| kiroAuthFound = true | |
| assert.Equal(t, "kiro-apikey", a.Label) | |
| assert.Contains(t, a.Metadata["refresh_token"], "aorAAAAA") | |
| assert.Equal(t, "us-east-1", a.Metadata["region"]) | |
| } | |
| } | |
| assert.True(t, kiroAuthFound, "Kiro auth should be synthesized") | |
| } | |