-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parse Dsn URL to handle user/password masking (#452)
* Parse Dsn URL to handle user/password masking * Format log
- Loading branch information
Showing
4 changed files
with
42 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package collector | ||
|
||
import ( | ||
"bytes" | ||
|
||
"sync" | ||
"testing" | ||
|
||
"github.com/go-kit/log" | ||
"github.com/prometheus/common/promlog" | ||
_ "github.com/sijms/go-ora/v2" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestMalformedDSNMasksUserPassword(t *testing.T) { | ||
buf := bytes.Buffer{} | ||
w := log.NewSyncWriter(&buf) | ||
testLogger := log.NewLogfmtLogger(w) | ||
e := &Exporter{ | ||
mu: &sync.Mutex{}, | ||
dsn: "\tuser:pass@sdfoijwef/sdfle", | ||
logger: promlog.NewWithLogger(testLogger, &promlog.Config{}), | ||
} | ||
err := e.connect() | ||
assert.NotNil(t, err) | ||
assert.Contains(t, buf.String(), "malformedDSN:=***@") | ||
} |
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