From 37ce0a72f41d074d65fda288f849c8489a5d0325 Mon Sep 17 00:00:00 2001 From: Ice3man543 Date: Tue, 23 Feb 2021 18:17:24 +0530 Subject: [PATCH] Added TLS protocol test --- v2/pkg/protocols/network/network_test.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/v2/pkg/protocols/network/network_test.go b/v2/pkg/protocols/network/network_test.go index e2c910fa..aa00a8fb 100644 --- a/v2/pkg/protocols/network/network_test.go +++ b/v2/pkg/protocols/network/network_test.go @@ -14,7 +14,7 @@ func TestNetworkCompileMake(t *testing.T) { templateID := "testing-network" request := &Request{ ID: templateID, - Address: []string{"{{Hostname}}", "{{Hostname}}:8082"}, + Address: []string{"{{Hostname}}", "{{Hostname}}:8082", "tls://{{Hostname}}:443"}, ReadSize: 1024, Inputs: []*Input{{Data: "test-data"}}, } @@ -25,12 +25,17 @@ func TestNetworkCompileMake(t *testing.T) { err := request.Compile(executerOpts) require.Nil(t, err, "could not compile network request") - require.Equal(t, 2, len(request.addresses), "could not get correct number of input address") + require.Equal(t, 3, len(request.addresses), "could not get correct number of input address") t.Run("check-host", func(t *testing.T) { - require.Equal(t, "{{Hostname}}", request.addresses[0].key, "could not get correct host") + require.Equal(t, "{{Hostname}}", request.addresses[0].ip, "could not get correct host") }) t.Run("check-host-with-port", func(t *testing.T) { - require.Equal(t, "{{Hostname}}", request.addresses[1].key, "could not get correct host with port") - require.Equal(t, "8082", request.addresses[1].value, "could not get correct port for host") + require.Equal(t, "{{Hostname}}", request.addresses[1].ip, "could not get correct host with port") + require.Equal(t, "8082", request.addresses[1].port, "could not get correct port for host") + }) + t.Run("check-tls-with-port", func(t *testing.T) { + require.Equal(t, "{{Hostname}}", request.addresses[2].ip, "could not get correct host with port") + require.Equal(t, "443", request.addresses[2].port, "could not get correct port for host") + require.True(t, request.addresses[2].tls, "could not get correct port for host") }) }