mirror of
https://github.com/octoleo/restic.git
synced 2024-11-11 15:51:02 +00:00
30 lines
708 B
Go
30 lines
708 B
Go
package location_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/restic/restic/internal/backend"
|
|
"github.com/restic/restic/internal/backend/location"
|
|
"github.com/restic/restic/internal/test"
|
|
)
|
|
|
|
func TestStripPassword(t *testing.T) {
|
|
registry := location.NewRegistry()
|
|
registry.Register(
|
|
location.NewHTTPBackendFactory[any, backend.Backend]("test", nil,
|
|
func(s string) string {
|
|
return "cleaned"
|
|
}, nil, nil,
|
|
),
|
|
)
|
|
|
|
t.Run("valid", func(t *testing.T) {
|
|
clean := location.StripPassword(registry, "test:secret")
|
|
test.Equals(t, "cleaned", clean)
|
|
})
|
|
t.Run("unknown", func(t *testing.T) {
|
|
clean := location.StripPassword(registry, "invalid:secret")
|
|
test.Equals(t, "invalid:secret", clean)
|
|
})
|
|
}
|