-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} | ||
}) | ||
} | ||
} |