Go app for capturing and archiving HSA-eligible receipts: OIDC/PKCE auth against Authelia, SQLite storage with dual-write (filesystem + DB blob), mobile-first upload, and DB export. Adds AI receipt classification: a config.json catalog of people and categories (seeded into the DB on startup), a prompt builder that derives name-order/initial variants from the data (with same-surname ambiguity handling), and an Anthropic tool-use client behind POST /classify. Tests run against a mock endpoint; a live integration test is env-gated to the cheapest model. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
22 lines
429 B
Go
22 lines
429 B
Go
package auth
|
|
|
|
import "testing"
|
|
|
|
func TestGenerateState_Length(t *testing.T) {
|
|
s, err := GenerateState()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
// 32 random bytes → 43 base64url chars (no padding)
|
|
if len(s) < 32 {
|
|
t.Errorf("state too short: %d chars", len(s))
|
|
}
|
|
}
|
|
|
|
func TestGenerateState_Unique(t *testing.T) {
|
|
a, _ := GenerateState()
|
|
b, _ := GenerateState()
|
|
if a == b {
|
|
t.Error("two calls returned the same state")
|
|
}
|
|
}
|