Files
VictoriaMetrics/lib/httputil/url_test.go
Aliaksandr Valialkin 2f86ef95a1 lib/{httputil,promauth}: move functions, which create TLS config and TLS-based HTTP transport, from lib/httputil to lib/promauth
- Move lib/httputil.Transport to lib/promauth.NewTLSTransport. Remove the first arg to this function (URL),
  since it has zero relation to the created transport.

- Move lib/httputil.TLSConfig to lib/promauth.NewTLSConfig. Re-use the existing functionality
  from lib/promauth.Config for creating TLS config. This enables the following features:
  - Ability to load key, cert and CA files from http urls.
  - Ability to change the key, cert and CA files without the need to restart the service.
    It automatically re-loads the new files after they change.
2025-03-26 20:14:17 +01:00

35 lines
520 B
Go

package httputil
import (
"testing"
)
func TestCheckURL_Success(t *testing.T) {
f := func(urlStr string) {
t.Helper()
if err := CheckURL(urlStr); err != nil {
t.Fatalf("unexpected error: %s", err)
}
}
f("http://victoriametrics.com")
f("https://victoriametrics.com")
}
func TestCheckURL_Failure(t *testing.T) {
f := func(urlStr string) {
t.Helper()
if err := CheckURL(urlStr); err == nil {
t.Fatalf("expecting non-nil error")
}
}
// empty url
f("")
// no schema
f("127.0.0.1:8880")
}