Skip to content

Commit

Permalink
fix: do not leak testify package in tlscommon
Browse files Browse the repository at this point in the history
move testify methods to a separate test package to avoid polluting
the module graph for downstream clients and leaking the dependency
  • Loading branch information
kruskall committed Jan 31, 2025
1 parent e8b8e7b commit 05aeeb9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions transport/tlscommon/tls_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ import (
"net/url"
"testing"

"github.com/elastic/elastic-agent-libs/transport/tlscommontest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestMakeVerifyServerConnection(t *testing.T) {
testCerts := GenTestCerts(t)
testCerts := tlscommontest.GenTestCerts(t)

certPool := x509.NewCertPool()
certPool.AddCert(testCerts["ca"])
Expand Down Expand Up @@ -183,13 +184,13 @@ func TestMakeVerifyServerConnection(t *testing.T) {
}

func TestTrustRootCA(t *testing.T) {
certs := GenTestCerts(t)
certs := tlscommontest.GenTestCerts(t)

nonEmptyCertPool := x509.NewCertPool()
nonEmptyCertPool.AddCert(certs["wildcard"])
nonEmptyCertPool.AddCert(certs["unknown_authority"])

fingerprint := GetCertFingerprint(certs["ca"])
fingerprint := tlscommontest.GetCertFingerprint(certs["ca"])

testCases := []struct {
name string
Expand Down Expand Up @@ -258,8 +259,8 @@ func TestTrustRootCA(t *testing.T) {
}

func TestMakeVerifyConnectionUsesCATrustedFingerprint(t *testing.T) {
testCerts := GenTestCerts(t)
fingerprint := GetCertFingerprint(testCerts["ca"])
testCerts := tlscommontest.GenTestCerts(t)
fingerprint := tlscommontest.GetCertFingerprint(testCerts["ca"])

testcases := map[string]struct {
verificationMode TLSVerificationMode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

package tlscommon
package tlscommontest

import (
"bytes"
Expand Down

0 comments on commit 05aeeb9

Please sign in to comment.