(t *testing.T)
| 54 | } |
| 55 | |
| 56 | func TestRegistrySQL_newKeyStrategy_handlesNetworkError(t *testing.T) { |
| 57 | t.Parallel() |
| 58 | |
| 59 | // Test ensures any network specific error is logged with a |
| 60 | // specific message when attempting to create a new key strategy: issue #2338 |
| 61 | |
| 62 | hook := test.Hook{} // Test hook for asserting log messages |
| 63 | |
| 64 | l := logrusx.New("", "", logrusx.WithHook(&hook)) |
| 65 | l.Logrus().SetOutput(io.Discard) |
| 66 | |
| 67 | // Create a config and set a valid but unresolvable DSN |
| 68 | c := config.MustNew(t, l, |
| 69 | configx.WithConfigFiles("../internal/.hydra.yaml"), |
| 70 | configx.WithValues(map[string]any{ |
| 71 | config.KeyDSN: "postgres://user:password@127.0.0.1:9999/postgres", |
| 72 | config.HSMEnabled: false, |
| 73 | }), |
| 74 | ) |
| 75 | |
| 76 | r, err := newRegistryWithoutInit(c, l) |
| 77 | if err != nil { |
| 78 | t.Errorf("Failed to create registry: %s", err) |
| 79 | return |
| 80 | } |
| 81 | |
| 82 | r.initialPing = failedPing(errors.New("snizzles")) |
| 83 | |
| 84 | assert.ErrorContains(t, |
| 85 | r.Init(t.Context(), true, false, nil, nil), |
| 86 | "snizzles", |
| 87 | ) |
| 88 | |
| 89 | assert.Equal(t, logrus.InfoLevel, hook.LastEntry().Level) |
| 90 | assert.Contains(t, hook.LastEntry().Message, "snizzles") |
| 91 | } |
| 92 | |
| 93 | func TestRegistrySQL_CookieStore_MaxAgeZero(t *testing.T) { |
| 94 | t.Parallel() |
nothing calls this directly
no test coverage detected