package model import ( customermodel "git.sendico.io/tech/sxchnge/product/customers/model" sessionmodel "git.sendico.io/tech/sxchnge/product/sessions/model" "go.mongodb.org/mongo-driver/v2/bson" "testing" ) func TestAccountTokenPreservesSessionIdentity(t *testing.T) { account := &customermodel.Account{} account.SetID(bson.NewObjectID()) account.Login = "security@example.com" account.Name = "Security" account.Locale = "en" session := sessionmodel.SessionIdentifier{ ClientID: "web", DeviceID: "device-a", SessionVersion: "session-version-a", } token, err := Claims2Token(Account2ClaimsForSession(account, 1, session)) if err != nil { t.Fatalf("decode account claims: %v", err) } if token.SessionIdentifier != session { t.Fatalf("session identity = %#v, want %#v", token.SessionIdentifier, session) } if token.Expiration.IsZero() { t.Fatal("access token expiration is missing") } }