Skip to content

Commit

Permalink
Add tests for unix_proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronH88 committed Nov 28, 2024
1 parent aa2756f commit 3d70c9e
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions pkg/services/unix_proxy_test.go
Original file line number Diff line number Diff line change
@@ -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")
}
})
}
}

0 comments on commit 3d70c9e

Please sign in to comment.