| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package e2e |
| 5 |
|
| 6 |
import ( |
| 7 |
"testing" |
| 8 |
"time" |
| 9 |
|
| 10 |
"github.com/stretchr/testify/assert" |
| 11 |
"github.com/stretchr/testify/require" |
| 12 |
|
| 13 |
"go.opentelemetry.io/collector/config/confighttp" |
| 14 |
"go.opentelemetry.io/collector/confmap" |
| 15 |
) |
| 16 |
|
| 17 |
func TestConfmapMarshalConfigHTTP(t *testing.T) { |
| 18 |
conf := confmap.New() |
| 19 |
require.NoError(t, conf.Marshal(confighttp.NewDefaultClientConfig())) |
| 20 |
assert.Equal(t, map[string]any{ |
| 21 |
"idle_conn_timeout": 90 * time.Second, |
| 22 |
"max_idle_conns": 100, |
| 23 |
"force_attempt_http2": true, |
| 24 |
}, conf.ToStringMap()) |
| 25 |
|
| 26 |
conf = confmap.New() |
| 27 |
require.NoError(t, conf.Marshal(confighttp.NewDefaultCORSConfig())) |
| 28 |
assert.Equal(t, map[string]any{}, conf.ToStringMap()) |
| 29 |
|
| 30 |
conf = confmap.New() |
| 31 |
require.NoError(t, conf.Marshal(confighttp.NewDefaultServerConfig())) |
| 32 |
assert.Equal(t, map[string]any{ |
| 33 |
"cors": nil, |
| 34 |
"idle_timeout": 60 * time.Second, |
| 35 |
"keep_alives_enabled": true, |
| 36 |
"read_header_timeout": 60 * time.Second, |
| 37 |
"tls": nil, |
| 38 |
"write_timeout": 30 * time.Second, |
| 39 |
}, conf.ToStringMap()) |
| 40 |
|
| 41 |
conf = confmap.New() |
| 42 |
require.NoError(t, conf.Marshal(confighttp.AuthConfig{})) |
| 43 |
assert.Equal(t, map[string]any{}, conf.ToStringMap()) |
| 44 |
} |