Skip to content

Commit

Permalink
feat(tests): added tests for tlsConfig override & bearerTokenfile set…
Browse files Browse the repository at this point in the history
…ting

Signed-off-by: Toni Tauro <[email protected]>
  • Loading branch information
eyenx committed Jul 28, 2023
1 parent 2f8bf04 commit e0b3589
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/unit/prometheus-servicemonitor.bats
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,45 @@ load _helpers
[ "$(echo "$output" | yq -r '.spec.endpoints | length')" = "1" ]
[ "$(echo "$output" | yq -r '.spec.endpoints[0].port')" = "https" ]
}

@test "prometheus/ServiceMonitor-server: tlsConfig default" {
cd `chart_dir`
local output=$( (helm template \
--show-only templates/prometheus-servicemonitor.yaml \
--set 'serverTelemetry.serviceMonitor.enabled=true' \
. ) | tee /dev/stderr)

[ "$(echo "$output" | yq -r '.spec.endpoints[0].tlsConfig.insecureSkipVerify')" = "true" ]
}

@test "prometheus/ServiceMonitor-server: tlsConfig override" {
cd `chart_dir`
local output=$( (helm template \
--show-only templates/prometheus-servicemonitor.yaml \
--set 'serverTelemetry.serviceMonitor.tlsConfig.ca=ca.crt' \
--set 'serverTelemetry.serviceMonitor.enabled=true' \
. ) | tee /dev/stderr)

[ "$(echo "$output" | yq -r '.spec.endpoints[0].tlsConfig.ca')" = "ca.crt" ]
}

@test "prometheus/ServiceMonitor-server: bearerTokenFile default" {
cd `chart_dir`
local output=$( (helm template \
--show-only templates/prometheus-servicemonitor.yaml \
--set 'serverTelemetry.serviceMonitor.enabled=true' \
. ) | tee /dev/stderr)

[ "$(echo "$output" | yq -r '.spec.endpoints[0] | has("bearerToken")')" = "false" ]
}

@test "prometheus/ServiceMonitor-server: bearerTokenFile set" {
cd `chart_dir`
local output=$( (helm template \
--show-only templates/prometheus-servicemonitor.yaml \
--set 'serverTelemetry.serviceMonitor.enabled=true' \
--set 'serverTelemetry.serviceMonitor.bearerTokenFile=tokenfile' \
. ) | tee /dev/stderr)

[ "$(echo "$output" | yq -r '.spec.endpoints[0].bearerTokenFile')" = "tokenfile" ]
}

0 comments on commit e0b3589

Please sign in to comment.