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