Skip to content

Commit b36ffba

Browse files
committed
docs: add parameter descriptions and enhanced test coverage
Signed-off-by: weidongkl <[email protected]>
1 parent e93852b commit b36ffba

File tree

2 files changed

+41
-7
lines changed

2 files changed

+41
-7
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ scrape_configs:
213213
| max-distinct-key-groups | REDIS_EXPORTER_MAX_DISTINCT_KEY_GROUPS | Maximum number of distinct key groups that can be tracked independently *per Redis database*. If exceeded, only key groups with the highest memory consumption within the limit will be tracked separately, all remaining key groups will be tracked under a single `overflow` key group. |
214214
| config-command | REDIS_EXPORTER_CONFIG_COMMAND | What to use for the CONFIG command, defaults to `CONFIG`, , set to "-" to skip config metrics extraction. |
215215
| basic-auth-username | REDIS_EXPORTER_BASIC_AUTH_USERNAME | Username for Basic Authentication with the redis exporter needs to be set together with basic-auth-password to be effective
216-
| basic-auth-password | REDIS_EXPORTER_BASIC_AUTH_PASSWORD | Password for Basic Authentication with the redis exporter needs to be set together with basic-auth-username to be effective
216+
| basic-auth-password | REDIS_EXPORTER_BASIC_AUTH_PASSWORD | Password for Basic Authentication with the redis exporter needs to be set together with basic-auth-username to be effective, conflicts with `basic-auth-hash-password`.
217+
| basic-auth-hash-password | REDIS_EXPORTER_BASIC_AUTH_HASH_PASSWORD | Bcrypt-hashed password for Basic Authentication with the redis exporter needs to be set together with basic-auth-username to be effective, conflicts with `basic-auth-password`.
217218
| include-metrics-for-empty-databases | REDIS_EXPORTER_INCL_METRICS_FOR_EMPTY_DATABASES | Whether to emit db metrics (like db_keys) for empty databases
218219

219220
Redis instance addresses can be tcp addresses: `redis://localhost:6379`, `redis.example.com:6379` or e.g. unix sockets: `unix:///tmp/redis.sock`.\

exporter/http_test.go

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -597,12 +597,13 @@ func TestBasicAuth(t *testing.T) {
597597
}
598598

599599
tests := []struct {
600-
name string
601-
username string
602-
password string
603-
configUsername string
604-
configPassword string
605-
wantStatusCode int
600+
name string
601+
username string
602+
password string
603+
configUsername string
604+
configPassword string
605+
configHashPassword string
606+
wantStatusCode int
606607
}{
607608
{
608609
name: "No auth configured - no credentials provided",
@@ -644,6 +645,38 @@ func TestBasicAuth(t *testing.T) {
644645
configPassword: "testpass",
645646
wantStatusCode: http.StatusUnauthorized,
646647
},
648+
{
649+
name: "Auth configured with hash password - correct credentials",
650+
username: "testuser",
651+
password: "testpass",
652+
configUsername: "testuser",
653+
configHashPassword: "$2a$12$ODSJd0tmxY7H/adgD7R5SO43d8nmhUsa8OM6Weo7VFs3MbrsEY7tu",
654+
wantStatusCode: http.StatusOK,
655+
},
656+
{
657+
name: "Auth configured with hash password - wrong password",
658+
username: "testuser",
659+
password: "wrongpass",
660+
configUsername: "testuser",
661+
configHashPassword: "$2a$12$ODSJd0tmxY7H/adgD7R5SO43d8nmhUsa8OM6Weo7VFs3MbrsEY7tu",
662+
wantStatusCode: http.StatusUnauthorized,
663+
},
664+
{
665+
name: "Auth configured with hash password - wrong username",
666+
username: "wronguser",
667+
password: "testpass",
668+
configUsername: "testuser",
669+
configHashPassword: "$2a$12$ODSJd0tmxY7H/adgD7R5SO43d8nmhUsa8OM6Weo7VFs3MbrsEY7tu",
670+
wantStatusCode: http.StatusUnauthorized,
671+
},
672+
{
673+
name: "Auth configured with hash password - no credentials provided",
674+
username: "",
675+
password: "",
676+
configUsername: "testuser",
677+
configHashPassword: "$2a$12$ODSJd0tmxY7H/adgD7R5SO43d8nmhUsa8OM6Weo7VFs3MbrsEY7tu",
678+
wantStatusCode: http.StatusUnauthorized,
679+
},
647680
}
648681

649682
for _, tt := range tests {

0 commit comments

Comments
 (0)