test(jwt): assert arrays are invalid for SpaceDelimited scope

Scope must be a space-delimited string per RFC 6749 §3.3, not a JSON
array. Adds [] and ["openid","profile"] cases to the existing invalid
sub-test with a comment explaining the likely root cause: an issuer
using []string instead of SpaceDelimited in its claims struct.
This commit is contained in:
AJ ONeal 2026-03-30 17:25:32 -06:00
parent 23ddc5b0ea
commit 77c256a9c2

View File

@ -220,11 +220,20 @@ func TestCov_SpaceDelimited_UnmarshalJSON(t *testing.T) {
t.Fatalf("expected empty, got %v", s) t.Fatalf("expected empty, got %v", s)
} }
}) })
// Scope must be a space-delimited string per RFC 6749 §3.3, not a number or
// JSON array. If a token arrives with "scope":[] the issuer has a bug (e.g.
// using []string instead of SpaceDelimited in its claims struct).
t.Run("invalid", func(t *testing.T) { t.Run("invalid", func(t *testing.T) {
var s SpaceDelimited var s SpaceDelimited
if err := json.Unmarshal([]byte(`123`), &s); err == nil { if err := json.Unmarshal([]byte(`123`), &s); err == nil {
t.Fatal("expected error") t.Fatal("expected error")
} }
if err := json.Unmarshal([]byte(`[]`), &s); err == nil {
t.Fatal("expected error")
}
if err := json.Unmarshal([]byte(`["openid","profile"]`), &s); err == nil {
t.Fatal("expected error")
}
}) })
} }