Skip to content

Commit 8391d1b

Browse files
zepatrikory-bot
authored andcommitted
test(hydra): convert custom JWT claim tests to table
GitOrigin-RevId: c0114d299bdec370104e8ad0b3042d3a3c045bb1
1 parent 442c5d0 commit 8391d1b

File tree

4 files changed

+124
-251
lines changed

4 files changed

+124
-251
lines changed

oauth2/e2e_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ func TestAuthCodeFlowE2E(t *testing.T) {
3838
config.KeyRefreshTokenHook: "",
3939
config.KeyLoginURL: testhelpers.LoginURL,
4040
config.KeyConsentURL: testhelpers.ConsentURL,
41-
config.KeyAccessTokenLifespan: 10 * time.Second,
42-
config.KeyRefreshTokenLifespan: 20 * time.Second,
41+
config.KeyAccessTokenLifespan: 10 * time.Minute, // allow to debug
42+
config.KeyRefreshTokenLifespan: 20 * time.Minute, // allow to debug
4343
config.KeyScopeStrategy: "exact",
4444
config.KeyIssuerURL: "https://hydra.ory",
4545
})))

oauth2/handler.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1463,7 +1463,6 @@ func (h *Handler) updateSessionWithRequest(
14631463
session.ExcludeNotBeforeClaim = h.c.ExcludeNotBeforeClaim(ctx)
14641464
session.AllowedTopLevelClaims = h.c.AllowedTopLevelClaims(ctx)
14651465
session.MirrorTopLevelClaims = h.c.MirrorTopLevelClaims(ctx)
1466-
session.Flow = flow
14671466

14681467
return session, nil
14691468
}

oauth2/session.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"github.com/ory/fosite/handler/openid"
2121
"github.com/ory/fosite/token/jwt"
2222
"github.com/ory/hydra/v2/driver/config"
23-
"github.com/ory/hydra/v2/flow"
2423
"github.com/ory/x/logrusx"
2524
)
2625

@@ -34,8 +33,6 @@ type Session struct {
3433
ExcludeNotBeforeClaim bool `json:"exclude_not_before_claim"`
3534
AllowedTopLevelClaims []string `json:"allowed_top_level_claims"`
3635
MirrorTopLevelClaims bool `json:"mirror_top_level_claims"`
37-
38-
Flow *flow.Flow `json:"-"`
3936
}
4037

4138
func NewTestSession(t testing.TB, subject string) *Session {
@@ -44,8 +41,6 @@ func NewTestSession(t testing.TB, subject string) *Session {
4441
}
4542

4643
func NewSessionWithCustomClaims(ctx context.Context, p *config.DefaultProvider, subject string) *Session {
47-
allowedTopLevelClaims := p.AllowedTopLevelClaims(ctx)
48-
mirrorTopLevelClaims := p.MirrorTopLevelClaims(ctx)
4944
return &Session{
5045
DefaultSession: &openid.DefaultSession{
5146
Claims: new(jwt.IDTokenClaims),
@@ -54,8 +49,9 @@ func NewSessionWithCustomClaims(ctx context.Context, p *config.DefaultProvider,
5449
ExpiresAt: make(map[fosite.TokenType]time.Time),
5550
},
5651
Extra: map[string]interface{}{},
57-
AllowedTopLevelClaims: allowedTopLevelClaims,
58-
MirrorTopLevelClaims: mirrorTopLevelClaims,
52+
AllowedTopLevelClaims: p.AllowedTopLevelClaims(ctx),
53+
MirrorTopLevelClaims: p.MirrorTopLevelClaims(ctx),
54+
ExcludeNotBeforeClaim: p.ExcludeNotBeforeClaim(ctx),
5955
}
6056
}
6157

0 commit comments

Comments
 (0)