mirror of
https://gh-proxy.org/https://github.com/klinsmaya/CLIProxyAPI.git
synced 2026-11-09 01:46:48 +08:00
- Updated `CredentialFileName` to include trimmed `hashAccountID` for team-scoped plans. - Added `isTeamScopedPlan` helper to handle plan-specific logic. - Ensured filenames are unique across emails for multiple teams. Closes: #4075
65 lines
1.9 KiB
Go
65 lines
1.9 KiB
Go
package codex
|
|
|
|
import "testing"
|
|
|
|
func TestCredentialFileName(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
email string
|
|
planType string
|
|
hashAccountID string
|
|
includeProviderPrefix bool
|
|
want string
|
|
}{
|
|
{
|
|
name: "team includes account hash",
|
|
email: "[email protected]",
|
|
planType: "team",
|
|
hashAccountID: "abc12345",
|
|
includeProviderPrefix: true,
|
|
want: "[email protected]",
|
|
},
|
|
{
|
|
name: "k12 includes account hash",
|
|
email: "[email protected]",
|
|
planType: "k12",
|
|
hashAccountID: "def67890",
|
|
includeProviderPrefix: true,
|
|
want: "[email protected]",
|
|
},
|
|
{
|
|
name: "k12 without account hash falls back to email and plan",
|
|
email: "[email protected]",
|
|
planType: "k12",
|
|
hashAccountID: "",
|
|
includeProviderPrefix: true,
|
|
want: "[email protected]",
|
|
},
|
|
{
|
|
name: "plus ignores account hash",
|
|
email: " [email protected] ",
|
|
planType: "Plus",
|
|
hashAccountID: "abc12345",
|
|
includeProviderPrefix: true,
|
|
want: "[email protected]",
|
|
},
|
|
{
|
|
name: "plan is normalized",
|
|
email: "[email protected]",
|
|
planType: " Team Plan ",
|
|
hashAccountID: "abc12345",
|
|
includeProviderPrefix: true,
|
|
want: "[email protected]",
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got := CredentialFileName(tt.email, tt.planType, tt.hashAccountID, tt.includeProviderPrefix)
|
|
if got != tt.want {
|
|
t.Fatalf("CredentialFileName() = %q, want %q", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|