Skip to content

Commit

Permalink
add unit test for apm_config.obfuscation default values
Browse files Browse the repository at this point in the history
  • Loading branch information
keisku committed Dec 21, 2024
1 parent b547803 commit 3e55f29
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions pkg/config/setup/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,35 @@ func TestDisableCoreAgent(t *testing.T) {
assert.False(t, conf.GetBool("enable_payloads.sketches"))
}

func TestAPMObfuscationDefaultValue(t *testing.T) {
pkgconfigmodel.CleanOverride(t)
conf := pkgconfigmodel.NewConfig("datadog", "DD", strings.NewReplacer(".", "_")) // nolint: forbidigo // legit use case

InitConfig(conf)
assert.True(t, conf.GetBool("apm_config.obfuscation.elasticsearch.enabled"))
assert.Len(t, conf.GetStringSlice("apm_config.obfuscation.elasticsearch.keep_values"), 0)
assert.Len(t, conf.GetStringSlice("apm_config.obfuscation.elasticsearch.obfuscate_sql_values"), 0)
assert.True(t, conf.GetBool("apm_config.obfuscation.opensearch.enabled"))
assert.Len(t, conf.GetStringSlice("apm_config.obfuscation.opensearch.keep_values"), 0)
assert.Len(t, conf.GetStringSlice("apm_config.obfuscation.opensearch.obfuscate_sql_values"), 0)
assert.True(t, conf.GetBool("apm_config.obfuscation.mongodb.enabled"))
assert.Len(t, conf.GetStringSlice("apm_config.obfuscation.mongodb.keep_values"), 0)
assert.Len(t, conf.GetStringSlice("apm_config.obfuscation.mongodb.obfuscate_sql_values"), 0)
assert.False(t, conf.GetBool("apm_config.obfuscation.sql_exec_plan.enabled"))
assert.Len(t, conf.GetStringSlice("apm_config.obfuscation.sql_exec_plan.keep_values"), 0)
assert.Len(t, conf.GetStringSlice("apm_config.obfuscation.sql_exec_plan.obfuscate_sql_values"), 0)
assert.False(t, conf.GetBool("apm_config.obfuscation.sql_exec_plan_normalize.enabled"))
assert.Len(t, conf.GetStringSlice("apm_config.obfuscation.sql_exec_plan_normalize.keep_values"), 0)
assert.Len(t, conf.GetStringSlice("apm_config.obfuscation.sql_exec_plan_normalize.obfuscate_sql_values"), 0)
assert.False(t, conf.GetBool("apm_config.obfuscation.http.remove_query_string"))
assert.False(t, conf.GetBool("apm_config.obfuscation.http.remove_paths_with_digits"))
assert.True(t, conf.GetBool("apm_config.obfuscation.redis.enabled"))
assert.False(t, conf.GetBool("apm_config.obfuscation.redis.remove_all_args"))
assert.True(t, conf.GetBool("apm_config.obfuscation.memcached.enabled"))
assert.False(t, conf.GetBool("apm_config.obfuscation.memcached.keep_command"))
assert.True(t, conf.GetBool("apm_config.obfuscation.cache.enabled"))
}

func TestAgentConfigInit(t *testing.T) {
conf := newTestConf()

Expand Down

0 comments on commit 3e55f29

Please sign in to comment.