aboutsummaryrefslogtreecommitdiff
path: root/hotline/server_blackbox_test.go
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2022-01-30 20:56:04 -0800
committerJeff Halter <jeff.d.halter@gmail.com>2022-01-30 20:56:04 -0800
commit92a7e455a347e5be7fb69b6846b9f27ca698ae12 (patch)
treecf7d2063123434adfa14f4f781ec4f7966a3adf1 /hotline/server_blackbox_test.go
parent154adcc6b47b3cb278f655a9580311e14de7444d (diff)
Sanitize file path input to prevent directory traversal
Diffstat (limited to 'hotline/server_blackbox_test.go')
-rw-r--r--hotline/server_blackbox_test.go22
1 files changed, 15 insertions, 7 deletions
diff --git a/hotline/server_blackbox_test.go b/hotline/server_blackbox_test.go
index 64d56ab..601d745 100644
--- a/hotline/server_blackbox_test.go
+++ b/hotline/server_blackbox_test.go
@@ -66,6 +66,8 @@ func NewTestLogger() *zap.SugaredLogger {
func StartTestServer() (*Server, context.Context, context.CancelFunc) {
ctx, cancelRoot := context.WithCancel(context.Background())
+ FS = OSFileStore{}
+
srv, err := NewServer("test/config/", "localhost", 0, NewTestLogger())
if err != nil {
panic(err)
@@ -82,6 +84,14 @@ func StartTestServer() (*Server, context.Context, context.CancelFunc) {
}
func TestHandshake(t *testing.T) {
+ mfs := MockFileStore{}
+ fh, _ := os.Open("./test/config/Agreement.txt")
+ mfs.On("Open", "/test/config/Agreement.txt").Return(fh, nil)
+ fh, _ = os.Open("./test/config/config.yaml")
+ mfs.On("Open", "/test/config/config.yaml").Return(fh, nil)
+ FS = mfs
+ spew.Dump(mfs)
+
srv, _, cancelFunc := StartTestServer()
defer cancelFunc()
@@ -313,18 +323,16 @@ func TestNewUser(t *testing.T) {
func tranAssertEqual(t *testing.T, tran1, tran2 []Transaction) bool {
var newT1 []Transaction
var newT2 []Transaction
- for _, trans := range tran1{
- trans.ID = []byte{0,0,0,0}
+ for _, trans := range tran1 {
+ trans.ID = []byte{0, 0, 0, 0}
newT1 = append(newT1, trans)
}
- for _, trans := range tran2{
- trans.ID = []byte{0,0,0,0}
+ for _, trans := range tran2 {
+ trans.ID = []byte{0, 0, 0, 0}
newT2 = append(newT2, trans)
}
- spew.Dump(newT1, newT2)
-
return assert.Equal(t, newT1, newT2)
-} \ No newline at end of file
+}