[configtls] Removed deprecated structs (#9786)
**Description:** <Describe what has changed.> Removed deprecated structs **Link to tracking Issue:** <Issue number if applicable> Related to https://github.com/open-telemetry/opentelemetry-collector/issues/9428 Related to https://github.com/open-telemetry/opentelemetry-collector/issues/9474 Closes https://github.com/open-telemetry/opentelemetry-collector/issues/9548
This commit is contained in:
parent
407ea439e3
commit
1038b67c85
|
|
@ -0,0 +1,25 @@
|
|||
# Use this changelog template to create an entry for release notes.
|
||||
|
||||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
|
||||
change_type: breaking
|
||||
|
||||
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
|
||||
component: configtls
|
||||
|
||||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
|
||||
note: Remove Deprecated `TLSSetting`, `TLSClientSetting`, and `TLSServerSetting`.
|
||||
|
||||
# One or more tracking issues or pull requests related to the change
|
||||
issues: [9786]
|
||||
|
||||
# (Optional) One or more lines of additional information to render under the primary note.
|
||||
# These lines will be padded with 2 spaces and then inserted directly into the document.
|
||||
# Use pipe (|) for multiline entries.
|
||||
subtext:
|
||||
|
||||
# Optional: The change log or logs in which this entry should be included.
|
||||
# e.g. '[user]' or '[user, api]'
|
||||
# Include 'user' if the change is relevant to end users.
|
||||
# Include 'api' if there is a change to a library API.
|
||||
# Default: '[user]'
|
||||
change_logs: [api]
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
# Use this changelog template to create an entry for release notes.
|
||||
|
||||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
|
||||
change_type: breaking
|
||||
|
||||
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
|
||||
component: configtls
|
||||
|
||||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
|
||||
note: Rename `TLSSetting` to `Config` on `ClientConfig` and `ServerConfig`.
|
||||
|
||||
# One or more tracking issues or pull requests related to the change
|
||||
issues: [9786]
|
||||
|
||||
# (Optional) One or more lines of additional information to render under the primary note.
|
||||
# These lines will be padded with 2 spaces and then inserted directly into the document.
|
||||
# Use pipe (|) for multiline entries.
|
||||
subtext:
|
||||
|
||||
# Optional: The change log or logs in which this entry should be included.
|
||||
# e.g. '[user]' or '[user, api]'
|
||||
# Include 'user' if the change is relevant to end users.
|
||||
# Include 'api' if there is a change to a library API.
|
||||
# Default: '[user]'
|
||||
change_logs: [api]
|
||||
|
|
@ -197,7 +197,7 @@ func TestAllGrpcServerSettingsExceptAuth(t *testing.T) {
|
|||
Transport: confignet.TransportTypeTCP,
|
||||
},
|
||||
TLSSetting: &configtls.ServerConfig{
|
||||
TLSSetting: configtls.Config{},
|
||||
Config: configtls.Config{},
|
||||
ClientCAFile: "",
|
||||
},
|
||||
MaxRecvMsgSizeMiB: 1,
|
||||
|
|
@ -278,7 +278,7 @@ func TestGRPCClientSettingsError(t *testing.T) {
|
|||
Endpoint: "",
|
||||
Compression: "",
|
||||
TLSSetting: configtls.ClientConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: "/doesnt/exist",
|
||||
},
|
||||
Insecure: false,
|
||||
|
|
@ -294,7 +294,7 @@ func TestGRPCClientSettingsError(t *testing.T) {
|
|||
Endpoint: "",
|
||||
Compression: "",
|
||||
TLSSetting: configtls.ClientConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CertFile: "/doesnt/exist",
|
||||
},
|
||||
Insecure: false,
|
||||
|
|
@ -465,7 +465,7 @@ func TestGRPCServerSettingsError(t *testing.T) {
|
|||
Transport: confignet.TransportTypeTCP,
|
||||
},
|
||||
TLSSetting: &configtls.ServerConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: "/doesnt/exist",
|
||||
},
|
||||
},
|
||||
|
|
@ -479,7 +479,7 @@ func TestGRPCServerSettingsError(t *testing.T) {
|
|||
Transport: confignet.TransportTypeTCP,
|
||||
},
|
||||
TLSSetting: &configtls.ServerConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CertFile: "/doesnt/exist",
|
||||
},
|
||||
},
|
||||
|
|
@ -538,14 +538,14 @@ func TestHttpReception(t *testing.T) {
|
|||
{
|
||||
name: "TLS",
|
||||
tlsServerCreds: &configtls.ServerConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: filepath.Join("testdata", "ca.crt"),
|
||||
CertFile: filepath.Join("testdata", "server.crt"),
|
||||
KeyFile: filepath.Join("testdata", "server.key"),
|
||||
},
|
||||
},
|
||||
tlsClientCreds: &configtls.ClientConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: filepath.Join("testdata", "ca.crt"),
|
||||
},
|
||||
ServerName: "localhost",
|
||||
|
|
@ -554,12 +554,12 @@ func TestHttpReception(t *testing.T) {
|
|||
{
|
||||
name: "NoServerCertificates",
|
||||
tlsServerCreds: &configtls.ServerConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: filepath.Join("testdata", "ca.crt"),
|
||||
},
|
||||
},
|
||||
tlsClientCreds: &configtls.ClientConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: filepath.Join("testdata", "ca.crt"),
|
||||
},
|
||||
ServerName: "localhost",
|
||||
|
|
@ -569,7 +569,7 @@ func TestHttpReception(t *testing.T) {
|
|||
{
|
||||
name: "mTLS",
|
||||
tlsServerCreds: &configtls.ServerConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: filepath.Join("testdata", "ca.crt"),
|
||||
CertFile: filepath.Join("testdata", "server.crt"),
|
||||
KeyFile: filepath.Join("testdata", "server.key"),
|
||||
|
|
@ -577,7 +577,7 @@ func TestHttpReception(t *testing.T) {
|
|||
ClientCAFile: filepath.Join("testdata", "ca.crt"),
|
||||
},
|
||||
tlsClientCreds: &configtls.ClientConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: filepath.Join("testdata", "ca.crt"),
|
||||
CertFile: filepath.Join("testdata", "client.crt"),
|
||||
KeyFile: filepath.Join("testdata", "client.key"),
|
||||
|
|
@ -588,7 +588,7 @@ func TestHttpReception(t *testing.T) {
|
|||
{
|
||||
name: "NoClientCertificate",
|
||||
tlsServerCreds: &configtls.ServerConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: filepath.Join("testdata", "ca.crt"),
|
||||
CertFile: filepath.Join("testdata", "server.crt"),
|
||||
KeyFile: filepath.Join("testdata", "server.key"),
|
||||
|
|
@ -596,7 +596,7 @@ func TestHttpReception(t *testing.T) {
|
|||
ClientCAFile: filepath.Join("testdata", "ca.crt"),
|
||||
},
|
||||
tlsClientCreds: &configtls.ClientConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: filepath.Join("testdata", "ca.crt"),
|
||||
},
|
||||
ServerName: "localhost",
|
||||
|
|
@ -606,7 +606,7 @@ func TestHttpReception(t *testing.T) {
|
|||
{
|
||||
name: "WrongClientCA",
|
||||
tlsServerCreds: &configtls.ServerConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: filepath.Join("testdata", "ca.crt"),
|
||||
CertFile: filepath.Join("testdata", "server.crt"),
|
||||
KeyFile: filepath.Join("testdata", "server.key"),
|
||||
|
|
@ -614,7 +614,7 @@ func TestHttpReception(t *testing.T) {
|
|||
ClientCAFile: filepath.Join("testdata", "server.crt"),
|
||||
},
|
||||
tlsClientCreds: &configtls.ClientConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: filepath.Join("testdata", "ca.crt"),
|
||||
CertFile: filepath.Join("testdata", "client.crt"),
|
||||
KeyFile: filepath.Join("testdata", "client.key"),
|
||||
|
|
|
|||
|
|
@ -311,7 +311,7 @@ func TestHTTPClientSettingsError(t *testing.T) {
|
|||
settings: ClientConfig{
|
||||
Endpoint: "",
|
||||
TLSSetting: configtls.ClientConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: "/doesnt/exist",
|
||||
},
|
||||
Insecure: false,
|
||||
|
|
@ -324,7 +324,7 @@ func TestHTTPClientSettingsError(t *testing.T) {
|
|||
settings: ClientConfig{
|
||||
Endpoint: "",
|
||||
TLSSetting: configtls.ClientConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CertFile: "/doesnt/exist",
|
||||
},
|
||||
Insecure: false,
|
||||
|
|
@ -494,7 +494,7 @@ func TestHTTPServerSettingsError(t *testing.T) {
|
|||
settings: ServerConfig{
|
||||
Endpoint: "localhost:0",
|
||||
TLSSetting: &configtls.ServerConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: "/doesnt/exist",
|
||||
},
|
||||
},
|
||||
|
|
@ -505,7 +505,7 @@ func TestHTTPServerSettingsError(t *testing.T) {
|
|||
settings: ServerConfig{
|
||||
Endpoint: "localhost:0",
|
||||
TLSSetting: &configtls.ServerConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CertFile: "/doesnt/exist",
|
||||
},
|
||||
},
|
||||
|
|
@ -586,14 +586,14 @@ func TestHttpReception(t *testing.T) {
|
|||
{
|
||||
name: "TLS",
|
||||
tlsServerCreds: &configtls.ServerConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: filepath.Join("testdata", "ca.crt"),
|
||||
CertFile: filepath.Join("testdata", "server.crt"),
|
||||
KeyFile: filepath.Join("testdata", "server.key"),
|
||||
},
|
||||
},
|
||||
tlsClientCreds: &configtls.ClientConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: filepath.Join("testdata", "ca.crt"),
|
||||
},
|
||||
ServerName: "localhost",
|
||||
|
|
@ -602,14 +602,14 @@ func TestHttpReception(t *testing.T) {
|
|||
{
|
||||
name: "TLS (HTTP/1.1)",
|
||||
tlsServerCreds: &configtls.ServerConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: filepath.Join("testdata", "ca.crt"),
|
||||
CertFile: filepath.Join("testdata", "server.crt"),
|
||||
KeyFile: filepath.Join("testdata", "server.key"),
|
||||
},
|
||||
},
|
||||
tlsClientCreds: &configtls.ClientConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: filepath.Join("testdata", "ca.crt"),
|
||||
},
|
||||
ServerName: "localhost",
|
||||
|
|
@ -619,12 +619,12 @@ func TestHttpReception(t *testing.T) {
|
|||
{
|
||||
name: "NoServerCertificates",
|
||||
tlsServerCreds: &configtls.ServerConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: filepath.Join("testdata", "ca.crt"),
|
||||
},
|
||||
},
|
||||
tlsClientCreds: &configtls.ClientConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: filepath.Join("testdata", "ca.crt"),
|
||||
},
|
||||
ServerName: "localhost",
|
||||
|
|
@ -634,7 +634,7 @@ func TestHttpReception(t *testing.T) {
|
|||
{
|
||||
name: "mTLS",
|
||||
tlsServerCreds: &configtls.ServerConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: filepath.Join("testdata", "ca.crt"),
|
||||
CertFile: filepath.Join("testdata", "server.crt"),
|
||||
KeyFile: filepath.Join("testdata", "server.key"),
|
||||
|
|
@ -642,7 +642,7 @@ func TestHttpReception(t *testing.T) {
|
|||
ClientCAFile: filepath.Join("testdata", "ca.crt"),
|
||||
},
|
||||
tlsClientCreds: &configtls.ClientConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: filepath.Join("testdata", "ca.crt"),
|
||||
CertFile: filepath.Join("testdata", "client.crt"),
|
||||
KeyFile: filepath.Join("testdata", "client.key"),
|
||||
|
|
@ -653,7 +653,7 @@ func TestHttpReception(t *testing.T) {
|
|||
{
|
||||
name: "NoClientCertificate",
|
||||
tlsServerCreds: &configtls.ServerConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: filepath.Join("testdata", "ca.crt"),
|
||||
CertFile: filepath.Join("testdata", "server.crt"),
|
||||
KeyFile: filepath.Join("testdata", "server.key"),
|
||||
|
|
@ -661,7 +661,7 @@ func TestHttpReception(t *testing.T) {
|
|||
ClientCAFile: filepath.Join("testdata", "ca.crt"),
|
||||
},
|
||||
tlsClientCreds: &configtls.ClientConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: filepath.Join("testdata", "ca.crt"),
|
||||
},
|
||||
ServerName: "localhost",
|
||||
|
|
@ -671,7 +671,7 @@ func TestHttpReception(t *testing.T) {
|
|||
{
|
||||
name: "WrongClientCA",
|
||||
tlsServerCreds: &configtls.ServerConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: filepath.Join("testdata", "ca.crt"),
|
||||
CertFile: filepath.Join("testdata", "server.crt"),
|
||||
KeyFile: filepath.Join("testdata", "server.key"),
|
||||
|
|
@ -679,7 +679,7 @@ func TestHttpReception(t *testing.T) {
|
|||
ClientCAFile: filepath.Join("testdata", "server.crt"),
|
||||
},
|
||||
tlsClientCreds: &configtls.ClientConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: filepath.Join("testdata", "ca.crt"),
|
||||
CertFile: filepath.Join("testdata", "client.crt"),
|
||||
KeyFile: filepath.Join("testdata", "client.key"),
|
||||
|
|
@ -1089,7 +1089,7 @@ func TestHttpClientHostHeader(t *testing.T) {
|
|||
serverURL, _ := url.Parse(server.URL)
|
||||
setting := ClientConfig{
|
||||
Endpoint: serverURL.String(),
|
||||
TLSSetting: configtls.TLSClientSetting{},
|
||||
TLSSetting: configtls.ClientConfig{},
|
||||
ReadBufferSize: 0,
|
||||
WriteBufferSize: 0,
|
||||
Timeout: 0,
|
||||
|
|
@ -1340,14 +1340,14 @@ func BenchmarkHttpRequest(b *testing.B) {
|
|||
}
|
||||
|
||||
tlsServerCreds := &configtls.ServerConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: filepath.Join("testdata", "ca.crt"),
|
||||
CertFile: filepath.Join("testdata", "server.crt"),
|
||||
KeyFile: filepath.Join("testdata", "server.key"),
|
||||
},
|
||||
}
|
||||
tlsClientCreds := &configtls.ClientConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: filepath.Join("testdata", "ca.crt"),
|
||||
},
|
||||
ServerName: "localhost",
|
||||
|
|
|
|||
|
|
@ -26,10 +26,6 @@ const defaultMaxTLSVersion = 0
|
|||
|
||||
var systemCertPool = x509.SystemCertPool
|
||||
|
||||
// TLSSetting exposes the common client and server TLS configurations.
|
||||
// Deprecated: [v0.96.0] Use Config instead.
|
||||
type TLSSetting = Config
|
||||
|
||||
// Config exposes the common client and server TLS configurations.
|
||||
// Note: Since there isn't anything specific to a server connection. Components
|
||||
// with server connections should use Config.
|
||||
|
|
@ -76,17 +72,12 @@ type Config struct {
|
|||
ReloadInterval time.Duration `mapstructure:"reload_interval"`
|
||||
}
|
||||
|
||||
// TSLClientSetting contains TLS configurations that are specific to client
|
||||
// connections in addition to the common configurations.
|
||||
// Deprecated: [v0.96.0] Use ClientConfig instead.
|
||||
type TLSClientSetting = ClientConfig
|
||||
|
||||
// ClientConfig contains TLS configurations that are specific to client
|
||||
// connections in addition to the common configurations. This should be used by
|
||||
// components configuring TLS client connections.
|
||||
type ClientConfig struct {
|
||||
// squash ensures fields are correctly decoded in embedded struct.
|
||||
TLSSetting `mapstructure:",squash"`
|
||||
Config `mapstructure:",squash"`
|
||||
|
||||
// These are config options specific to client connections.
|
||||
|
||||
|
|
@ -105,17 +96,12 @@ type ClientConfig struct {
|
|||
ServerName string `mapstructure:"server_name_override"`
|
||||
}
|
||||
|
||||
// TLSServerSetting contains TLS configurations that are specific to server
|
||||
// connections in addition to the common configurations.
|
||||
// Deprecated: [v0.96.0] Use ServerConfig instead.
|
||||
type TLSServerSetting = ServerConfig
|
||||
|
||||
// ServerConfig contains TLS configurations that are specific to server
|
||||
// connections in addition to the common configurations. This should be used by
|
||||
// components configuring TLS server connections.
|
||||
type ServerConfig struct {
|
||||
// squash ensures fields are correctly decoded in embedded struct.
|
||||
TLSSetting `mapstructure:",squash"`
|
||||
Config `mapstructure:",squash"`
|
||||
|
||||
// These are config options specific to server connections.
|
||||
|
||||
|
|
@ -174,7 +160,7 @@ func (r *certReloader) GetCertificate() (*tls.Certificate, error) {
|
|||
return r.cert, nil
|
||||
}
|
||||
|
||||
func (c TLSSetting) Validate() error {
|
||||
func (c Config) Validate() error {
|
||||
if c.hasCAFile() && c.hasCAPem() {
|
||||
return fmt.Errorf("provide either a CA file or the PEM-encoded string, but not both")
|
||||
}
|
||||
|
|
@ -377,7 +363,7 @@ func (c ClientConfig) LoadTLSConfigContext(_ context.Context) (*tls.Config, erro
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
tlsCfg, err := c.TLSSetting.loadTLSConfig()
|
||||
tlsCfg, err := c.loadTLSConfig()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to load TLS config: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ func TestOptionsToConfig(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "should load system CA and custom CA",
|
||||
options: TLSSetting{IncludeSystemCACertsPool: true, CAFile: filepath.Join("testdata", "ca-1.crt")},
|
||||
options: Config{IncludeSystemCACertsPool: true, CAFile: filepath.Join("testdata", "ca-1.crt")},
|
||||
},
|
||||
{
|
||||
name: "should fail with invalid CA file path",
|
||||
|
|
@ -250,7 +250,7 @@ func readFilePanics(filePath string) configopaque.String {
|
|||
|
||||
func TestLoadTLSClientConfigError(t *testing.T) {
|
||||
tlsSetting := ClientConfig{
|
||||
TLSSetting: Config{
|
||||
Config: Config{
|
||||
CertFile: "doesnt/exist",
|
||||
KeyFile: "doesnt/exist",
|
||||
},
|
||||
|
|
@ -283,7 +283,7 @@ func TestLoadTLSClientConfig(t *testing.T) {
|
|||
|
||||
func TestLoadTLSServerConfigError(t *testing.T) {
|
||||
tlsSetting := ServerConfig{
|
||||
TLSSetting: Config{
|
||||
Config: Config{
|
||||
CertFile: "doesnt/exist",
|
||||
KeyFile: "doesnt/exist",
|
||||
},
|
||||
|
|
@ -634,10 +634,10 @@ func TestMinMaxTLSVersions(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestTLSSettingValidate(t *testing.T) {
|
||||
func TestConfigValidate(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
tlsConfig TLSSetting
|
||||
tlsConfig Config
|
||||
errorTxt string
|
||||
}{
|
||||
{name: `TLS Config ["", ""] to be valid`, tlsConfig: Config{MinVersion: "", MaxVersion: ""}},
|
||||
|
|
@ -718,13 +718,13 @@ func TestSystemCertPool(t *testing.T) {
|
|||
anError := errors.New("my error")
|
||||
tests := []struct {
|
||||
name string
|
||||
tlsSetting TLSSetting
|
||||
tlsConfig Config
|
||||
wantErr error
|
||||
systemCertFn func() (*x509.CertPool, error)
|
||||
}{
|
||||
{
|
||||
name: "not using system cert pool",
|
||||
tlsSetting: TLSSetting{
|
||||
tlsConfig: Config{
|
||||
IncludeSystemCACertsPool: false,
|
||||
CAFile: filepath.Join("testdata", "ca-1.crt"),
|
||||
},
|
||||
|
|
@ -733,7 +733,7 @@ func TestSystemCertPool(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "using system cert pool",
|
||||
tlsSetting: TLSSetting{
|
||||
tlsConfig: Config{
|
||||
IncludeSystemCACertsPool: true,
|
||||
CAFile: filepath.Join("testdata", "ca-1.crt"),
|
||||
},
|
||||
|
|
@ -742,7 +742,7 @@ func TestSystemCertPool(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "error loading system cert pool",
|
||||
tlsSetting: TLSSetting{
|
||||
tlsConfig: Config{
|
||||
IncludeSystemCACertsPool: true,
|
||||
CAFile: filepath.Join("testdata", "ca-1.crt"),
|
||||
},
|
||||
|
|
@ -753,7 +753,7 @@ func TestSystemCertPool(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "nil system cert pool",
|
||||
tlsSetting: TLSSetting{
|
||||
tlsConfig: Config{
|
||||
IncludeSystemCACertsPool: true,
|
||||
CAFile: filepath.Join("testdata", "ca-1.crt"),
|
||||
},
|
||||
|
|
@ -772,7 +772,7 @@ func TestSystemCertPool(t *testing.T) {
|
|||
}()
|
||||
|
||||
serverConfig := ServerConfig{
|
||||
TLSSetting: test.tlsSetting,
|
||||
Config: test.tlsConfig,
|
||||
}
|
||||
c, err := serverConfig.LoadTLSConfig()
|
||||
if test.wantErr != nil {
|
||||
|
|
@ -782,7 +782,7 @@ func TestSystemCertPool(t *testing.T) {
|
|||
}
|
||||
|
||||
clientConfig := ClientConfig{
|
||||
TLSSetting: test.tlsSetting,
|
||||
Config: test.tlsConfig,
|
||||
}
|
||||
c, err = clientConfig.LoadTLSConfig()
|
||||
if test.wantErr != nil {
|
||||
|
|
@ -798,13 +798,13 @@ func TestSystemCertPool_loadCert(t *testing.T) {
|
|||
anError := errors.New("my error")
|
||||
tests := []struct {
|
||||
name string
|
||||
tlsSetting TLSSetting
|
||||
tlsConfig Config
|
||||
wantErr error
|
||||
systemCertFn func() (*x509.CertPool, error)
|
||||
}{
|
||||
{
|
||||
name: "not using system cert pool",
|
||||
tlsSetting: TLSSetting{
|
||||
tlsConfig: Config{
|
||||
IncludeSystemCACertsPool: false,
|
||||
},
|
||||
wantErr: nil,
|
||||
|
|
@ -812,7 +812,7 @@ func TestSystemCertPool_loadCert(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "using system cert pool",
|
||||
tlsSetting: TLSSetting{
|
||||
tlsConfig: Config{
|
||||
IncludeSystemCACertsPool: true,
|
||||
},
|
||||
wantErr: nil,
|
||||
|
|
@ -820,7 +820,7 @@ func TestSystemCertPool_loadCert(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "error loading system cert pool",
|
||||
tlsSetting: TLSSetting{
|
||||
tlsConfig: Config{
|
||||
IncludeSystemCACertsPool: true,
|
||||
},
|
||||
wantErr: anError,
|
||||
|
|
@ -830,7 +830,7 @@ func TestSystemCertPool_loadCert(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "nil system cert pool",
|
||||
tlsSetting: TLSSetting{
|
||||
tlsConfig: Config{
|
||||
IncludeSystemCACertsPool: true,
|
||||
},
|
||||
wantErr: nil,
|
||||
|
|
@ -846,7 +846,7 @@ func TestSystemCertPool_loadCert(t *testing.T) {
|
|||
defer func() {
|
||||
systemCertPool = oldSystemCertPool
|
||||
}()
|
||||
certPool, err := test.tlsSetting.loadCert(filepath.Join("testdata", "ca-1.crt"))
|
||||
certPool, err := test.tlsConfig.loadCert(filepath.Join("testdata", "ca-1.crt"))
|
||||
if test.wantErr != nil {
|
||||
assert.Equal(t, test.wantErr, err)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ func TestUnmarshalConfig(t *testing.T) {
|
|||
Endpoint: "1.2.3.4:1234",
|
||||
Compression: "gzip",
|
||||
TLSSetting: configtls.ClientConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: "/var/lib/mycert.pem",
|
||||
},
|
||||
Insecure: false,
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ func TestCreateTracesExporter(t *testing.T) {
|
|||
ClientConfig: configgrpc.ClientConfig{
|
||||
Endpoint: endpoint,
|
||||
TLSSetting: configtls.ClientConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: filepath.Join("testdata", "test_cert.pem"),
|
||||
},
|
||||
},
|
||||
|
|
@ -153,7 +153,7 @@ func TestCreateTracesExporter(t *testing.T) {
|
|||
ClientConfig: configgrpc.ClientConfig{
|
||||
Endpoint: endpoint,
|
||||
TLSSetting: configtls.ClientConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: "nosuchfile",
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ func TestUnmarshalConfig(t *testing.T) {
|
|||
},
|
||||
Endpoint: "https://1.2.3.4:1234",
|
||||
TLSSetting: configtls.ClientConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: "/var/lib/mycert.pem",
|
||||
CertFile: "certfile",
|
||||
KeyFile: "keyfile",
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ func TestCreateTracesExporter(t *testing.T) {
|
|||
ClientConfig: confighttp.ClientConfig{
|
||||
Endpoint: endpoint,
|
||||
TLSSetting: configtls.ClientConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: filepath.Join("testdata", "test_cert.pem"),
|
||||
},
|
||||
},
|
||||
|
|
@ -110,7 +110,7 @@ func TestCreateTracesExporter(t *testing.T) {
|
|||
ClientConfig: confighttp.ClientConfig{
|
||||
Endpoint: endpoint,
|
||||
TLSSetting: configtls.ClientConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CAFile: "nosuchfile",
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ func TestUnmarshalConfig(t *testing.T) {
|
|||
Transport: confignet.TransportTypeTCP,
|
||||
},
|
||||
TLSSetting: &configtls.ServerConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CertFile: "test.crt",
|
||||
KeyFile: "test.key",
|
||||
},
|
||||
|
|
@ -119,7 +119,7 @@ func TestUnmarshalConfig(t *testing.T) {
|
|||
ServerConfig: &confighttp.ServerConfig{
|
||||
Endpoint: "0.0.0.0:4318",
|
||||
TLSSetting: &configtls.ServerConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CertFile: "test.crt",
|
||||
KeyFile: "test.key",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -691,7 +691,7 @@ func TestGRPCInvalidTLSCredentials(t *testing.T) {
|
|||
Transport: confignet.TransportTypeTCP,
|
||||
},
|
||||
TLSSetting: &configtls.ServerConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CertFile: "willfail",
|
||||
},
|
||||
},
|
||||
|
|
@ -754,7 +754,7 @@ func TestHTTPInvalidTLSCredentials(t *testing.T) {
|
|||
ServerConfig: &confighttp.ServerConfig{
|
||||
Endpoint: testutil.GetAvailableLocalAddress(t),
|
||||
TLSSetting: &configtls.ServerConfig{
|
||||
TLSSetting: configtls.Config{
|
||||
Config: configtls.Config{
|
||||
CertFile: "willfail",
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue