Files
yuez 680a40ebc8 fix: remove auth_provider capability to clean up OAuth page, bump v0.2.1
- Remove AuthProvider capability declaration; keep only management_api
- Drop auth.login.start/poll and auth.identifier handlers
- Remove unused auth.parse and file-parsing structs
- Update QuotaCard version tag to v0.2.1
- Sync User-Agent to use PluginVersion
2026-09-08 08:30:50 +08:00

62 lines
1.5 KiB
Go

package plugin
import (
"testing"
)
func TestExtractSessionToken(t *testing.T) {
tests := []struct {
name string
input string
expected string
}{
{
name: "raw token",
input: "abc123token",
expected: "abc123token",
},
{
name: "single cookie",
input: "__Secure-commandcode_prod_.session_token=secret_tok_123",
expected: "secret_tok_123",
},
{
name: "cookie with semicolons and trailing params",
input: "__Secure-commandcode_prod_.session_token=secret_tok_123; Path=/; Secure; HttpOnly",
expected: "secret_tok_123",
},
{
name: "multi-cookie string",
input: "some_other_cookie=xyz; __Secure-commandcode_prod_.session_token=secret_tok_123; foo=bar",
expected: "secret_tok_123",
},
{
name: "empty string",
input: " ",
expected: "",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := ExtractSessionToken(tt.input)
if got != tt.expected {
t.Errorf("ExtractSessionToken(%q) = %q, want %q", tt.input, got, tt.expected)
}
})
}
}
func TestFormatSessionCookie(t *testing.T) {
got := FormatSessionCookie("my-token")
want := "__Secure-commandcode_prod_.session_token=my-token"
if got != want {
t.Errorf("FormatSessionCookie() = %q, want %q", got, want)
}
gotCookie := FormatSessionCookie("__Secure-commandcode_prod_.session_token=my-token; Path=/")
if gotCookie != want {
t.Errorf("FormatSessionCookie() from cookie = %q, want %q", gotCookie, want)
}
}