From 3d70c9ed32a89dffa91c64347084e5b3bf92f962 Mon Sep 17 00:00:00 2001 From: AaronH88 Date: Thu, 28 Nov 2024 15:47:13 -0300 Subject: [PATCH] Add tests for unix_proxy --- pkg/services/unix_proxy_test.go | 79 +++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 pkg/services/unix_proxy_test.go diff --git a/pkg/services/unix_proxy_test.go b/pkg/services/unix_proxy_test.go new file mode 100644 index 000000000..5e5d43f4d --- /dev/null +++ b/pkg/services/unix_proxy_test.go @@ -0,0 +1,79 @@ +package services + +import ( + "context" + "crypto/tls" + "os" + "testing" + + "github.com/ansible/receptor/pkg/netceptor" +) + +func TestUnixProxyServiceInbound(t *testing.T) { + type testCase struct { + name string + filename string + permissions os.FileMode + node string + rservice string + tlscfg *tls.Config + expecterr bool + } + + tests := []testCase{ + { + name: "Fail UnixSocketListen", + expecterr: true, + }, + } + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + ctx := context.Background() + s := netceptor.New(ctx, "Unix Test Node") + err := UnixProxyServiceInbound(s, tc.filename, tc.permissions, tc.node, tc.rservice, tc.tlscfg) + if tc.expecterr { + if err == nil { + t.Errorf("net UnixProxyServiceInbound fail case error") + } + + return + } else if err != nil { + t.Errorf("net UnixProxyServiceInbound error") + } + }) + } +} + +func TestUnixProxyServiceOutbound(t *testing.T) { + type testCase struct { + name string + expecterr bool + service string + tlscfg *tls.Config + filename string + } + + tests := []testCase{ + { + name: "Fail UnixSocketListen", + }, + } + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + ctx := context.Background() + s := netceptor.New(ctx, "Unix Test Node") + err := UnixProxyServiceOutbound(s, tc.service, tc.tlscfg, tc.filename) + if tc.expecterr { + if err == nil { + t.Errorf("net UnixProxyServiceInbound fail case error") + } + + return + } else if err != nil { + t.Errorf("net UnixProxyServiceInbound error") + } + }) + } +}