MCPcopy
hub / github.com/ory/hydra / TestRegistrySQL_newKeyStrategy_handlesNetworkError

Function TestRegistrySQL_newKeyStrategy_handlesNetworkError

driver/registry_sql_test.go:56–91  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

54}
55
56func 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
93func TestRegistrySQL_CookieStore_MaxAgeZero(t *testing.T) {
94 t.Parallel()

Callers

nothing calls this directly

Calls 6

MustNewFunction · 0.92
newRegistryWithoutInitFunction · 0.85
failedPingFunction · 0.85
LogrusMethod · 0.80
ErrorfMethod · 0.45
InitMethod · 0.45

Tested by

no test coverage detected