forked from prometheus/nagios_plugins
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/3 check prom needs the opts (#4)
* fix: check prom needs the opts Signed-off-by: Yoan Blanc <[email protected]> * Added tests to verify #3 * Ensure test-failure in CI, update changelog Co-authored-by: Yoan Blanc <[email protected]>
- Loading branch information
1 parent
b35eace
commit 83347b2
Showing
7 changed files
with
130 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env bats | ||
|
||
PROMETHEUS_SERVER=http://localhost:${NGINX_PORT}/ | ||
|
||
UNABLE_TO_QUERY="UNKNOWN - unable to query prometheus endpoint!" | ||
BASIC_AUTH_PARAMS="-C --user -C admin:admin" | ||
|
||
|
||
load test_utils | ||
|
||
@test "--- ${BATS_TEST_FILENAME} ---" { | ||
true | ||
} | ||
# Failing due to basic auth | ||
@test "Test without basic auth -q 1 -w 2 -c 3" { | ||
OUTPUT="$(test_parameters '-q 1 -w 2 -c 3')" | ||
echo $OUTPUT | ||
[ "${OUTPUT}" == "${UNABLE_TO_QUERY}" ] | ||
} | ||
@test "Test without basic auth -q 2 -w 2 -c 3" { | ||
OUTPUT="$(test_parameters '-q 2 -w 2 -c 3')" | ||
[ "${OUTPUT}" == "${UNABLE_TO_QUERY}" ] | ||
} | ||
@test "Test without basic auth -q 3 -w 2 -c 3" { | ||
OUTPUT="$(test_parameters '-q 3 -w 2 -c 3')" | ||
[ "${OUTPUT}" == "${UNABLE_TO_QUERY}" ] | ||
} | ||
@test "Test without basic auth -q 4 -w 2 -c 3" { | ||
OUTPUT="$(test_parameters '-q 4 -w 2 -c 3')" | ||
[ "${OUTPUT}" == "${UNABLE_TO_QUERY}" ] | ||
} | ||
|
||
# Passing with basic auth | ||
@test "Test with basic auth -q 1 -w 2 -c 3" { | ||
OUTPUT="$(test_parameters "${BASIC_AUTH_PARAMS} -q 1 -w 2 -c 3")" | ||
[ "${OUTPUT}" == "OK - tc is 1" ] | ||
} | ||
@test "Test with basic auth -q 2 -w 2 -c 3" { | ||
OUTPUT="$(test_parameters "${BASIC_AUTH_PARAMS} -q 2 -w 2 -c 3")" | ||
[ "${OUTPUT}" == "WARNING - tc is 2" ] | ||
} | ||
@test "Test with basic auth -q 3 -w 2 -c 3" { | ||
OUTPUT="$(test_parameters "${BASIC_AUTH_PARAMS} -q 3 -w 2 -c 3")" | ||
[ "${OUTPUT}" == "CRITICAL - tc is 3" ] | ||
} | ||
@test "Test with basic auth -q 4 -w 2 -c 3" { | ||
OUTPUT="$(test_parameters "${BASIC_AUTH_PARAMS} -q 4 -w 2 -c 3")" | ||
[ "${OUTPUT}" == "CRITICAL - tc is 4" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
admin:$apr1$enb5u7Pi$yMZD6bvOaAUIRL0ki850L/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
http { | ||
server { | ||
listen 80; | ||
|
||
location / { | ||
auth_basic "Prometheus"; | ||
auth_basic_user_file /etc/nginx/.htpasswd; | ||
proxy_pass http://${PROMETHEUS_NAME}:9090/; | ||
} | ||
|
||
location /health { | ||
return 200; | ||
} | ||
} | ||
} | ||
events {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters