mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2026-06-29 05:25:26 +03:00
- 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.
35 lines
520 B
Go
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")
|
|
}
|