Skip to content

Commit 29ba474

Browse files
zepatrikory-bot
authored andcommitted
chore(hydra): improve test config setup
GitOrigin-RevId: 554890b424d335e9f87234212079894014372e66
1 parent d1aa677 commit 29ba474

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+823
-1121
lines changed

CHANGELOG.md

Lines changed: 2 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
55
**Table of Contents**
66

7-
- [0.0.0 (2025-07-24)](#000-2025-07-24)
7+
- [0.0.0 (2025-07-03)](#000-2025-07-03)
88
- [Breaking Changes](#breaking-changes)
99
- [Related issue(s)](#related-issues)
1010

1111
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
1212

13-
# [0.0.0](https://github.com/ory/hydra/compare/v2.3.0...v0.0.0) (2025-07-24)
13+
# [0.0.0](https://github.com/ory/hydra/compare/v2.3.0...v0.0.0) (2025-07-03)
1414
## Breaking Changes
1515

1616
This patch changes the behavior of configuration item `foo` to do bar. To keep the existing
@@ -41,10 +41,6 @@ If this pull request
4141

4242
### Bug Fixes
4343

44-
* Add repo syncing for polis ([46d17f8](https://github.com/ory/hydra/commit/46d17f8bfdc59e2185e9ce65823eb2652e01f1b8)):
45-
46-
GitOrigin-RevId: e277a25d594b512b800d39dd18f36ea3d99fcf84
47-
4844
* Allow updating when JWKS URI is set ([#3935](https://github.com/ory/hydra/issues/3935)) ([#3946](https://github.com/ory/hydra/issues/3946)) ([fb1655b](https://github.com/ory/hydra/commit/fb1655ba86077b10141132ed332ba8d6f8c70582)):
4945

5046
The client validator no longer rejects PATCH and PUT updates when `JSONWebKeysURI` is non-empty and `JSONWebKeys` is not nil.
@@ -75,10 +71,6 @@ If this pull request
7571
GitOrigin-RevId: 61645585277edd95914705499afd7211a85983eb
7672

7773
* CLI usage help examples ([#3943](https://github.com/ory/hydra/issues/3943)) ([e24f9a7](https://github.com/ory/hydra/commit/e24f9a704c22c72690bc20c498439865181d9239))
78-
* Copybara script ([7b33358](https://github.com/ory/hydra/commit/7b333585bb44a069bf47267c853aa2e91db0efa3)):
79-
80-
GitOrigin-RevId: 14665e01451ac5fcdda148b473b8fc35d4fe21ef
81-
8274
* Correct multiple instances of 'stragegy' typo ([#3906](https://github.com/ory/hydra/issues/3906)) ([50eefbc](https://github.com/ory/hydra/commit/50eefbc21c2c43d221b6079bbd78a33ef8c754c4)):
8375

8476
This commit addresses several occurrences where 'strategy' was
@@ -101,26 +93,14 @@ If this pull request
10193

10294
```
10395

104-
* Identity queries ([a30f021](https://github.com/ory/hydra/commit/a30f021fd98969c2dbc31a4dc3e45365d60c1a25)):
105-
106-
GitOrigin-RevId: b103d25a807c643b521a12d593486d5125f390be
107-
10896
* Ignore flaky keys in Hydra HSM tests ([469b2ad](https://github.com/ory/hydra/commit/469b2ad538865a38738a10f46d270f53d12101ad)):
10997

11098
GitOrigin-RevId: 83312e6544bc33ccc30e1e1e414cc04910429192
11199

112-
* Include go.mod in vendored oryx ([08a3ab4](https://github.com/ory/hydra/commit/08a3ab43ddb1e2a0df430224f969fe3f0ba161bf)):
113-
114-
GitOrigin-RevId: 20365bbe6b2cf95ac7973bcca9056455d2cb3803
115-
116100
* **infrastructure:** Hydra oss CI ([e846541](https://github.com/ory/hydra/commit/e84654185cdfffbf160d5309f744795d15d723f9)):
117101

118102
GitOrigin-RevId: 3df0724e5ea4c81a0f4c481c1a3a34529356d073
119103

120-
* Jsonx.ApplyJSONPatch ([c6fa2a6](https://github.com/ory/hydra/commit/c6fa2a6f17f63e43cfecb576bd2a1c1b58c778ed)):
121-
122-
GitOrigin-RevId: 43c10801f5051e3d5fbea5f4f5e90394f6da0fbb
123-
124104
* JWT documentation link to point to the correct resource ([#3907](https://github.com/ory/hydra/issues/3907)) ([b746e41](https://github.com/ory/hydra/commit/b746e41eda6dc3fe376b147d146a6fcc7dafb455)):
125105

126106
The previous link in the documentation led to a page unrelated to JWT.
@@ -165,14 +145,6 @@ If this pull request
165145

166146
GitOrigin-RevId: 64950988a466bbdb4f25b8d9f5c416ff591c00bf
167147

168-
* Use hard-coded fallback key instead of panic ([e1f6450](https://github.com/ory/hydra/commit/e1f645012f43f62928fdc79710b45d935878367f)):
169-
170-
GitOrigin-RevId: d7a2270bbf5360288199e9632b2eac6cbc29737c
171-
172-
* Use main branch for polis ([6c24e68](https://github.com/ory/hydra/commit/6c24e68995b8eae9ba0b8872867270ef1d35113b)):
173-
174-
GitOrigin-RevId: 04533493184c6abdc3a211daffd98f6b68e1c9cc
175-
176148
* Using uuid_generate_v4 function ([#3958](https://github.com/ory/hydra/issues/3958)) ([c206066](https://github.com/ory/hydra/commit/c20606606654af975e5d82998956bb998acee576)):
177149

178150
Removing the md5 function for the uuid generation with native pgsql
@@ -181,13 +153,6 @@ If this pull request
181153
Closes https://github.com/ory/hydra/issues/3844
182154

183155

184-
### Code Refactoring
185-
186-
* Move database meta functions to root x folder for reusability ([7e49133](https://github.com/ory/hydra/commit/7e49133f435d6a0f74a63e8f8d03c5d314d7d3c6)):
187-
188-
GitOrigin-RevId: 30ee938ea5f1d19bac8967e0ebfe2d595ec27d2b
189-
190-
191156
### Features
192157

193158
* Add error reason to OAuth2TokenExchangeError event ([#3971](https://github.com/ory/hydra/issues/3971)) ([241dd45](https://github.com/ory/hydra/commit/241dd45fa17ed10d1101d890199df47dab4dbce5))
@@ -262,10 +227,6 @@ If this pull request
262227

263228
GitOrigin-RevId: dbb48d171fad1f9b4fd31385f0ef4fb01e39e823
264229

265-
* Move config testhelpers to ory/x ([3a4ba08](https://github.com/ory/hydra/commit/3a4ba084c74cf49a521856f150a8a2c6f3c1aa25)):
266-
267-
GitOrigin-RevId: fd484445e9715760231f7f86ec212d094e826377
268-
269230
* Revoke Kratos session asynchronously ([#3936](https://github.com/ory/hydra/issues/3936)) ([a0e7ee2](https://github.com/ory/hydra/commit/a0e7ee29298d4f882a7d471e0601b01c6848c40d)):
270231

271232
This change makes the session revocation in Kratos async to improve
@@ -345,18 +306,10 @@ If this pull request
345306
POST admin/oauth2/auth/sessions/consent?consent_challenge_id=G_TIM3XABG14UwIgDoT1DRfipjhC1uix
346307
```
347308

348-
* Use stdlib HTTP router in Kratos ([8f81931](https://github.com/ory/hydra/commit/8f8193179a39dc142d502fbc559891ffa0385ed8)):
349-
350-
GitOrigin-RevId: 799513e99acbf43a05fe3113ffda45d2fff2a9e0
351-
352309
* Use vendored jackson ([a0a9062](https://github.com/ory/hydra/commit/a0a906211bce4ced3e1f4324eb9d287ef10892a6)):
353310

354311
GitOrigin-RevId: 591238768218ba2b5af93f91ac7e16f4c170da5b
355312

356-
* Use vendored ory/x ([6581e01](https://github.com/ory/hydra/commit/6581e01679b2e146433061cbaaebb80a0e3905b5)):
357-
358-
GitOrigin-RevId: 994f3b754946ca5b2bd1bab0fe20532f5d5ab62f
359-
360313

361314
### Performance Improvements
362315

@@ -367,19 +320,8 @@ If this pull request
367320

368321
### Tests
369322

370-
* **hydra:** Clean oauth2 session setup ([699e382](https://github.com/ory/hydra/commit/699e38238220f857148b503dfb96d9b057bb4583)):
371-
372-
GitOrigin-RevId: e05097c7439096cf40fdcf059b3396970b2f1219
373-
374323
* Parallelize and improve ([#3989](https://github.com/ory/hydra/issues/3989)) ([a47e395](https://github.com/ory/hydra/commit/a47e39513f1f08076849f77517977abffa195364))
375324

376-
### Unclassified
377-
378-
* Merge 3834fab8c161a7dc98d43f32acf8efd9e6e95352 into 4dae0f4a8785eb36d8dbb27137f6b924c1e0f0b5 ([dc84053](https://github.com/ory/hydra/commit/dc840535c19d58caf130966e00d3d2fe9f3eb577)):
379-
380-
GitOrigin-RevId: 0c2dcaa065b64d2aafbcfd49c79363a214c5b2aa
381-
382-
383325

384326
# [2.3.0](https://github.com/ory/hydra/compare/v2.2.0...v2.3.0) (2025-01-17)
385327

aead/aead_test.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/ory/hydra/v2/aead"
1818
"github.com/ory/hydra/v2/driver/config"
1919
"github.com/ory/hydra/v2/internal/testhelpers"
20+
"github.com/ory/x/configx"
2021
)
2122

2223
func secret(t *testing.T) string {
@@ -43,8 +44,7 @@ func TestAEAD(t *testing.T) {
4344
t.Run("case=without-rotation", func(t *testing.T) {
4445
t.Parallel()
4546
ctx := context.Background()
46-
c := testhelpers.NewConfigurationWithDefaults()
47-
c.MustSet(ctx, config.KeyGetSystemSecret, []string{secret(t)})
47+
c := testhelpers.NewConfigurationWithDefaults(t, configx.WithValue(config.KeyGetSystemSecret, []string{secret(t)}))
4848
a := NewCipher(c)
4949

5050
plain := []byte(uuid.New())
@@ -63,8 +63,7 @@ func TestAEAD(t *testing.T) {
6363
t.Run("case=wrong-secret", func(t *testing.T) {
6464
t.Parallel()
6565
ctx := context.Background()
66-
c := testhelpers.NewConfigurationWithDefaults()
67-
c.MustSet(ctx, config.KeyGetSystemSecret, []string{secret(t)})
66+
c := testhelpers.NewConfigurationWithDefaults(t, configx.WithValue(config.KeyGetSystemSecret, []string{secret(t)}))
6867
a := NewCipher(c)
6968

7069
ct, err := a.Encrypt(ctx, []byte(uuid.New()), nil)
@@ -78,9 +77,8 @@ func TestAEAD(t *testing.T) {
7877
t.Run("case=with-rotation", func(t *testing.T) {
7978
t.Parallel()
8079
ctx := context.Background()
81-
c := testhelpers.NewConfigurationWithDefaults()
8280
old := secret(t)
83-
c.MustSet(ctx, config.KeyGetSystemSecret, []string{old})
81+
c := testhelpers.NewConfigurationWithDefaults(t, configx.WithValue(config.KeyGetSystemSecret, []string{old}))
8482
a := NewCipher(c)
8583

8684
plain := []byte(uuid.New())
@@ -106,8 +104,7 @@ func TestAEAD(t *testing.T) {
106104
t.Run("case=with-rotation-wrong-secret", func(t *testing.T) {
107105
t.Parallel()
108106
ctx := context.Background()
109-
c := testhelpers.NewConfigurationWithDefaults()
110-
c.MustSet(ctx, config.KeyGetSystemSecret, []string{secret(t)})
107+
c := testhelpers.NewConfigurationWithDefaults(t, configx.WithValue(config.KeyGetSystemSecret, []string{secret(t)}))
111108
a := NewCipher(c)
112109

113110
plain := []byte(uuid.New())
@@ -123,8 +120,7 @@ func TestAEAD(t *testing.T) {
123120
t.Run("suite=with additional data", func(t *testing.T) {
124121
t.Parallel()
125122
ctx := context.Background()
126-
c := testhelpers.NewConfigurationWithDefaults()
127-
c.MustSet(ctx, config.KeyGetSystemSecret, []string{secret(t)})
123+
c := testhelpers.NewConfigurationWithDefaults(t, configx.WithValue(config.KeyGetSystemSecret, []string{secret(t)}))
128124
a := NewCipher(c)
129125

130126
plain := []byte(uuid.New())

client/handler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func getClientID(body string) string {
5555

5656
func TestHandler(t *testing.T) {
5757
ctx := context.Background()
58-
reg := testhelpers.NewMockedRegistry(t, &contextx.Default{})
58+
reg := testhelpers.NewRegistryMemory(t)
5959
h := client.NewHandler(reg)
6060
reg.WithContextualizer(&contextx.TestContextualizer{})
6161

client/sdk_test.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"github.com/ory/hydra/v2/oauth2"
2424
"github.com/ory/hydra/v2/x"
2525
"github.com/ory/x/assertx"
26-
"github.com/ory/x/contextx"
26+
"github.com/ory/x/configx"
2727
"github.com/ory/x/ioutilx"
2828
"github.com/ory/x/pointerx"
2929
"github.com/ory/x/uuidx"
@@ -60,35 +60,35 @@ var defaultIgnoreFields = []string{"client_id", "registration_access_token", "re
6060

6161
func TestClientSDK(t *testing.T) {
6262
ctx := context.Background()
63-
conf := testhelpers.NewConfigurationWithDefaults()
64-
conf.MustSet(ctx, config.KeySubjectTypesSupported, []string{"public"})
65-
conf.MustSet(ctx, config.KeyDefaultClientScope, []string{"foo", "bar"})
66-
conf.MustSet(ctx, config.KeyPublicAllowDynamicRegistration, true)
67-
r := testhelpers.NewRegistryMemory(t, conf, &contextx.Static{C: conf.Source(ctx)})
63+
r := testhelpers.NewRegistryMemory(t, configx.WithValues(map[string]any{
64+
config.KeySubjectTypesSupported: []string{"public"},
65+
config.KeyDefaultClientScope: []string{"foo", "bar"},
66+
config.KeyPublicAllowDynamicRegistration: true,
67+
}))
6868

69-
routerAdmin := x.NewRouterAdmin(conf.AdminURL)
69+
routerAdmin := x.NewRouterAdmin(r.Config().AdminURL)
7070
routerPublic := x.NewRouterPublic()
7171
clHandler := client.NewHandler(r)
7272
clHandler.SetPublicRoutes(routerPublic)
7373
clHandler.SetAdminRoutes(routerAdmin)
74-
o2Handler := oauth2.NewHandler(r, conf)
74+
o2Handler := oauth2.NewHandler(r)
7575
o2Handler.SetPublicRoutes(routerPublic, func(h http.Handler) http.Handler { return h })
7676
o2Handler.SetAdminRoutes(routerAdmin)
7777

7878
server := httptest.NewServer(routerAdmin)
7979
t.Cleanup(server.Close)
8080
publicServer := httptest.NewServer(routerPublic)
8181
t.Cleanup(publicServer.Close)
82-
conf.MustSet(ctx, config.KeyAdminURL, server.URL)
83-
conf.MustSet(ctx, config.KeyOAuth2TokenURL, publicServer.URL+"/oauth2/token")
82+
r.Config().MustSet(ctx, config.KeyAdminURL, server.URL)
83+
r.Config().MustSet(ctx, config.KeyOAuth2TokenURL, publicServer.URL+"/oauth2/token")
8484

8585
c := hydra.NewAPIClient(hydra.NewConfiguration())
8686
c.GetConfig().Servers = hydra.ServerConfigurations{{URL: server.URL}}
8787

8888
t.Run("case=client default scopes are set", func(t *testing.T) {
8989
result, _, err := c.OAuth2API.CreateOAuth2Client(ctx).OAuth2Client(hydra.OAuth2Client{}).Execute()
9090
require.NoError(t, err)
91-
assert.EqualValues(t, conf.DefaultClientScope(ctx), strings.Split(*result.Scope, " "))
91+
assert.EqualValues(t, r.Config().DefaultClientScope(ctx), strings.Split(*result.Scope, " "))
9292

9393
_, err = c.OAuth2API.DeleteOAuth2Client(ctx, *result.ClientId).Execute()
9494
require.NoError(t, err)
@@ -212,12 +212,12 @@ func TestClientSDK(t *testing.T) {
212212
path := "/id"
213213
value := "foo"
214214

215-
client := createTestClient("")
216-
created, res, err := c.OAuth2API.CreateOAuth2Client(context.Background()).OAuth2Client(client).Execute()
215+
cl := createTestClient("")
216+
created, res, err := c.OAuth2API.CreateOAuth2Client(context.Background()).OAuth2Client(cl).Execute()
217217
require.NoError(t, err, "%s", ioutilx.MustReadAll(res.Body))
218-
client.ClientId = created.ClientId
218+
cl.ClientId = created.ClientId
219219

220-
_, _, err = c.OAuth2API.PatchOAuth2Client(context.Background(), *client.ClientId).JsonPatch([]hydra.JsonPatch{{Op: op, Path: path, Value: value}}).Execute()
220+
_, _, err = c.OAuth2API.PatchOAuth2Client(context.Background(), *cl.ClientId).JsonPatch([]hydra.JsonPatch{{Op: op, Path: path, Value: value}}).Execute()
221221
require.Error(t, err)
222222
})
223223

@@ -229,7 +229,7 @@ func TestClientSDK(t *testing.T) {
229229
cc := clientcredentials.Config{
230230
ClientID: *created.ClientId,
231231
ClientSecret: "secret",
232-
TokenURL: conf.OAuth2TokenURL(t.Context()).String(),
232+
TokenURL: r.Config().OAuth2TokenURL(t.Context()).String(),
233233
AuthStyle: goauth2.AuthStyleInHeader,
234234
}
235235
token, err := cc.Token(t.Context())
@@ -267,13 +267,13 @@ func TestClientSDK(t *testing.T) {
267267
path := "/client_name"
268268
value := "test"
269269

270-
client := createTestClient("")
271-
client.SetJwksUri("https://example.org/.well-known/jwks.json")
272-
created, _, err := c.OAuth2API.CreateOAuth2Client(context.Background()).OAuth2Client(client).Execute()
270+
cl := createTestClient("")
271+
cl.SetJwksUri("https://example.org/.well-known/jwks.json")
272+
created, _, err := c.OAuth2API.CreateOAuth2Client(context.Background()).OAuth2Client(cl).Execute()
273273
require.NoError(t, err)
274-
client.ClientId = created.ClientId
274+
cl.ClientId = created.ClientId
275275

276-
result, _, err := c.OAuth2API.PatchOAuth2Client(context.Background(), *client.ClientId).JsonPatch([]hydra.JsonPatch{{Op: op, Path: path, Value: value}}).Execute()
276+
result, _, err := c.OAuth2API.PatchOAuth2Client(context.Background(), *cl.ClientId).JsonPatch([]hydra.JsonPatch{{Op: op, Path: path, Value: value}}).Execute()
277277
require.NoError(t, err)
278278
require.Equal(t, value, pointerx.Deref(result.ClientName))
279279
})

0 commit comments

Comments
 (0)