@@ -5,6 +5,7 @@ import (
55 "crypto/rand"
66 "crypto/rsa"
77 "encoding/base64"
8+ "errors"
89 "net/http"
910 "net/http/httptest"
1011 "net/url"
@@ -253,6 +254,16 @@ var _ = Describe("ADFS Provider Tests", func() {
253254 Expect(err).ToNot(HaveOccurred())
254255 Expect(session.Email).To(Equal("upn@company.com"))
255256 })
257+
258+ It("falls back to UPN claim on errors", func() {
259+ p.oidcEnrichFunc = func(_ context.Context, s *sessions.SessionState) error {
260+ return errors.New("neither the id_token nor the profileURL set an email")
261+ }
262+
263+ err := p.EnrichSession(context.Background(), session)
264+ Expect(err).ToNot(HaveOccurred())
265+ Expect(session.Email).To(Equal("upn@company.com"))
266+ })
256267 })
257268
258269 Describe("RefreshSession", func() {