(t *testing.T)
| 111 | } |
| 112 | |
| 113 | func 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 | |
| 140 | func TestDefaultKeyManager_HsmDisabled(t *testing.T) { |
| 141 | t.Parallel() |
nothing calls this directly
no test coverage detected