Fix segfault in x509_cert (#4874)

This commit is contained in:
Fred Cox
2018-10-17 21:46:44 +03:00
committed by Greg
parent f10de93da4
commit 48745c3171
4 changed files with 28 additions and 2 deletions

View File

@@ -4,6 +4,8 @@ import (
"crypto/tls"
"encoding/base64"
"fmt"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"io/ioutil"
"os"
"testing"
@@ -203,3 +205,19 @@ func TestStrings(t *testing.T) {
})
}
}
func TestGatherCert(t *testing.T) {
if testing.Short() {
t.Skip("Skipping integration test in short mode")
}
m := &X509Cert{
Sources: []string{"https://www.influxdata.com:443"},
}
var acc testutil.Accumulator
err := m.Gather(&acc)
require.NoError(t, err)
assert.True(t, acc.HasMeasurement("x509_cert"))
}