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

Function TestRegistrySQL_HTTPClient

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

Source from the content-addressed store, hash-verified

111}
112
113func TestRegistrySQL_HTTPClient(t *testing.T) {
114 t.Parallel()
115
116 ts := httptest.NewServer(http.HandlerFunc(func(writer http.ResponseWriter, _ *http.Request) {
117 writer.WriteHeader(http.StatusOK)
118 }))
119 defer ts.Close()
120
121 r, err := New(t.Context(), SkipNetworkInit(), DisableValidation(), WithConfigOptions(configx.WithValues(map[string]interface{}{
122 config.KeyDSN: dbal.NewSQLiteTestDatabase(t),
123 config.KeyClientHTTPNoPrivateIPRanges: true,
124 config.KeyClientHTTPPrivateIPExceptionURLs: []string{ts.URL + "/exception/*"},
125 })))
126 require.NoError(t, err)
127
128 t.Run("case=matches exception glob", func(t *testing.T) {
129 res, err := r.HTTPClient(t.Context()).Get(ts.URL + "/exception/foo")
130 require.NoError(t, err)
131 assert.Equal(t, 200, res.StatusCode)
132 })
133
134 t.Run("case=does not match exception glob", func(t *testing.T) {
135 _, err := r.HTTPClient(t.Context()).Get(ts.URL + "/foo")
136 assert.ErrorContains(t, err, "prohibited IP address")
137 })
138}
139
140func TestDefaultKeyManager_HsmDisabled(t *testing.T) {
141 t.Parallel()

Callers

nothing calls this directly

Calls 8

SkipNetworkInitFunction · 0.85
DisableValidationFunction · 0.85
WithConfigOptionsFunction · 0.85
NewFunction · 0.70
CloseMethod · 0.65
GetMethod · 0.65
HTTPClientMethod · 0.65
WriteHeaderMethod · 0.45

Tested by

no test coverage detected