2023-06-08 15:17:00 +02:00
|
|
|
package location_test
|
2020-03-20 23:52:27 +01:00
|
|
|
|
2023-06-08 15:17:00 +02:00
|
|
|
import (
|
|
|
|
"testing"
|
2020-03-20 23:52:27 +01:00
|
|
|
|
2023-06-08 15:17:00 +02:00
|
|
|
"github.com/restic/restic/internal/backend/location"
|
|
|
|
"github.com/restic/restic/internal/restic"
|
|
|
|
"github.com/restic/restic/internal/test"
|
|
|
|
)
|
2020-03-20 23:52:27 +01:00
|
|
|
|
|
|
|
func TestStripPassword(t *testing.T) {
|
2023-06-08 15:17:00 +02:00
|
|
|
registry := location.NewRegistry()
|
2023-06-08 17:32:43 +02:00
|
|
|
registry.Register(
|
|
|
|
location.NewHTTPBackendFactory[any, restic.Backend]("test", nil,
|
2023-06-08 15:17:00 +02:00
|
|
|
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)
|
|
|
|
})
|
2020-03-20 23:52:27 +01:00
|
|
|
}
|