"crypto/x509"
"encoding/pem"
"fmt"
+ "net"
+ "os"
+ "testing"
+ "time"
+
"github.com/go-kit/log"
"github.com/prometheus/blackbox_exporter/config"
"github.com/prometheus/client_golang/prometheus"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/health"
"google.golang.org/grpc/health/grpc_health_v1"
- "io/ioutil"
- "net"
- "os"
- "testing"
- "time"
)
func TestGRPCConnection(t *testing.T) {
_, testcertPem, testKey := generateSelfSignedCertificate(testCertTmpl)
// CAFile must be passed via filesystem, use a tempfile.
- tmpCaFile, err := ioutil.TempFile("", "cafile.pem")
+ tmpCaFile, err := os.CreateTemp("", "cafile.pem")
if err != nil {
t.Fatalf("Error creating CA tempfile: %s", err)
}
"errors"
"fmt"
"io"
- "io/ioutil"
"net"
"net/http"
"net/http/cookiejar"
)
func matchRegularExpressions(reader io.Reader, httpConfig config.HTTPProbe, logger log.Logger) bool {
- body, err := ioutil.ReadAll(reader)
+ body, err := io.ReadAll(reader)
if err != nil {
level.Error(logger).Log("msg", "Error reading HTTP body", "err", err)
return false
}
if !requestErrored {
- _, err = io.Copy(ioutil.Discard, byteCounter)
+ _, err = io.Copy(io.Discard, byteCounter)
if err != nil {
level.Info(logger).Log("msg", "Failed to read HTTP response body", "err", err)
success = false
func getDecompressionReader(algorithm string, origBody io.ReadCloser) (io.ReadCloser, error) {
switch strings.ToLower(algorithm) {
case "br":
- return ioutil.NopCloser(brotli.NewReader(origBody)), nil
+ return io.NopCloser(brotli.NewReader(origBody)), nil
case "deflate":
return flate.NewReader(origBody), nil
"crypto/x509"
"encoding/pem"
"fmt"
- "io/ioutil"
"net/http"
"net/http/httptest"
"net/url"
_, testcertPem, testKey := generateSelfSignedCertificate(testCertTmpl)
// CAFile must be passed via filesystem, use a tempfile.
- tmpCaFile, err := ioutil.TempFile("", "cafile.pem")
+ tmpCaFile, err := os.CreateTemp("", "cafile.pem")
if err != nil {
t.Fatalf("Error creating CA tempfile: %s", err)
}
"crypto/x509"
"encoding/pem"
"fmt"
- "io/ioutil"
"net"
"os"
"runtime"
_, rootCertPem, rootKey := generateSelfSignedCertificate(rootCertTmpl)
// CAFile must be passed via filesystem, use a tempfile.
- tmpCaFile, err := ioutil.TempFile("", "cafile.pem")
+ tmpCaFile, err := os.CreateTemp("", "cafile.pem")
if err != nil {
t.Fatalf(fmt.Sprintf("Error creating CA tempfile: %s", err))
}
_, serverCertPem, serverKey := generateSignedCertificate(serverCertTmpl, olderRootCert, rootPrivatekey)
// CAFile must be passed via filesystem, use a tempfile.
- tmpCaFile, err := ioutil.TempFile("", "cafile.pem")
+ tmpCaFile, err := os.CreateTemp("", "cafile.pem")
if err != nil {
t.Fatalf(fmt.Sprintf("Error creating CA tempfile: %s", err))
}
_, testCertPem, testKey := generateSelfSignedCertificate(testCertTmpl)
// CAFile must be passed via filesystem, use a tempfile.
- tmpCaFile, err := ioutil.TempFile("", "cafile.pem")
+ tmpCaFile, err := os.CreateTemp("", "cafile.pem")
if err != nil {
t.Fatalf(fmt.Sprintf("Error creating CA tempfile: %s", err))
}