]> git.r.bdr.sh - rbdr/mobius/blobdiff - hotline/transaction_handlers_test.go
Refactor TrackerRegistration Read to io.Reader interface
[rbdr/mobius] / hotline / transaction_handlers_test.go
index c174822723ad435073dc9f08e96f273a314be518..b03e3b18b77185dc3b080b660768b74182ede5fa 100644 (file)
@@ -4,11 +4,14 @@ import (
        "errors"
        "fmt"
        "github.com/stretchr/testify/assert"
+       "github.com/stretchr/testify/mock"
        "io/fs"
        "math/rand"
        "os"
+       "path/filepath"
        "strings"
        "testing"
+       "time"
 )
 
 func TestHandleSetChatSubject(t *testing.T) {
@@ -34,13 +37,13 @@ func TestHandleSetChatSubject(t *testing.T) {
                                                                ClientConn: map[uint16]*ClientConn{
                                                                        uint16(1): {
                                                                                Account: &Account{
-                                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                                },
                                                                                ID: &[]byte{0, 1},
                                                                        },
                                                                        uint16(2): {
                                                                                Account: &Account{
-                                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                                },
                                                                                ID: &[]byte{0, 2},
                                                                        },
@@ -50,13 +53,13 @@ func TestHandleSetChatSubject(t *testing.T) {
                                                Clients: map[uint16]*ClientConn{
                                                        uint16(1): {
                                                                Account: &Account{
-                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                },
                                                                ID: &[]byte{0, 1},
                                                        },
                                                        uint16(2): {
                                                                Account: &Account{
-                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                },
                                                                ID: &[]byte{0, 2},
                                                        },
@@ -70,8 +73,8 @@ func TestHandleSetChatSubject(t *testing.T) {
                                        ID:        []byte{0, 0, 0, 1},
                                        ErrorCode: []byte{0, 0, 0, 0},
                                        Fields: []Field{
-                                               NewField(fieldChatID, []byte{0, 0, 0, 1}),
-                                               NewField(fieldChatSubject, []byte("Test Subject")),
+                                               NewField(FieldChatID, []byte{0, 0, 0, 1}),
+                                               NewField(FieldChatSubject, []byte("Test Subject")),
                                        },
                                },
                        },
@@ -84,8 +87,8 @@ func TestHandleSetChatSubject(t *testing.T) {
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
                                        ErrorCode: []byte{0, 0, 0, 0},
                                        Fields: []Field{
-                                               NewField(fieldChatID, []byte{0, 0, 0, 1}),
-                                               NewField(fieldChatSubject, []byte("Test Subject")),
+                                               NewField(FieldChatID, []byte{0, 0, 0, 1}),
+                                               NewField(FieldChatSubject, []byte("Test Subject")),
                                        },
                                },
                                {
@@ -96,8 +99,8 @@ func TestHandleSetChatSubject(t *testing.T) {
                                        ID:        []byte{0xf0, 0xc5, 0x34, 0x1e}, // Random ID from rand.Seed(1)
                                        ErrorCode: []byte{0, 0, 0, 0},
                                        Fields: []Field{
-                                               NewField(fieldChatID, []byte{0, 0, 0, 1}),
-                                               NewField(fieldChatSubject, []byte("Test Subject")),
+                                               NewField(FieldChatID, []byte{0, 0, 0, 1}),
+                                               NewField(FieldChatSubject, []byte("Test Subject")),
                                        },
                                },
                        },
@@ -142,13 +145,13 @@ func TestHandleLeaveChat(t *testing.T) {
                                                                ClientConn: map[uint16]*ClientConn{
                                                                        uint16(1): {
                                                                                Account: &Account{
-                                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                                },
                                                                                ID: &[]byte{0, 1},
                                                                        },
                                                                        uint16(2): {
                                                                                Account: &Account{
-                                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                                },
                                                                                ID: &[]byte{0, 2},
                                                                        },
@@ -158,20 +161,20 @@ func TestHandleLeaveChat(t *testing.T) {
                                                Clients: map[uint16]*ClientConn{
                                                        uint16(1): {
                                                                Account: &Account{
-                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                },
                                                                ID: &[]byte{0, 1},
                                                        },
                                                        uint16(2): {
                                                                Account: &Account{
-                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                },
                                                                ID: &[]byte{0, 2},
                                                        },
                                                },
                                        },
                                },
-                               t: NewTransaction(tranDeleteUser, nil, NewField(fieldChatID, []byte{0, 0, 0, 1})),
+                               t: NewTransaction(TranDeleteUser, nil, NewField(FieldChatID, []byte{0, 0, 0, 1})),
                        },
                        want: []Transaction{
                                {
@@ -182,8 +185,8 @@ func TestHandleLeaveChat(t *testing.T) {
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
                                        ErrorCode: []byte{0, 0, 0, 0},
                                        Fields: []Field{
-                                               NewField(fieldChatID, []byte{0, 0, 0, 1}),
-                                               NewField(fieldUserID, []byte{0, 2}),
+                                               NewField(FieldChatID, []byte{0, 0, 0, 1}),
+                                               NewField(FieldUserID, []byte{0, 2}),
                                        },
                                },
                        },
@@ -226,24 +229,15 @@ func TestHandleGetUserNameList(t *testing.T) {
                                                Clients: map[uint16]*ClientConn{
                                                        uint16(1): {
                                                                ID:       &[]byte{0, 1},
-                                                               Icon:     &[]byte{0, 2},
-                                                               Flags:    &[]byte{0, 3},
+                                                               Icon:     []byte{0, 2},
+                                                               Flags:    []byte{0, 3},
                                                                UserName: []byte{0, 4},
-                                                               Agreed:   true,
                                                        },
                                                        uint16(2): {
                                                                ID:       &[]byte{0, 2},
-                                                               Icon:     &[]byte{0, 2},
-                                                               Flags:    &[]byte{0, 3},
+                                                               Icon:     []byte{0, 2},
+                                                               Flags:    []byte{0, 3},
                                                                UserName: []byte{0, 4},
-                                                               Agreed:   true,
-                                                       },
-                                                       uint16(3): {
-                                                               ID:       &[]byte{0, 3},
-                                                               Icon:     &[]byte{0, 2},
-                                                               Flags:    &[]byte{0, 3},
-                                                               UserName: []byte{0, 4},
-                                                               Agreed:   false,
                                                        },
                                                },
                                        },
@@ -258,16 +252,16 @@ func TestHandleGetUserNameList(t *testing.T) {
                                        clientID:  &[]byte{1, 1},
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 1},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0, 0, 0, 1},
                                        ErrorCode: []byte{0, 0, 0, 0},
                                        Fields: []Field{
                                                NewField(
-                                                       fieldUsernameWithInfo,
+                                                       FieldUsernameWithInfo,
                                                        []byte{00, 01, 00, 02, 00, 03, 00, 02, 00, 04},
                                                ),
                                                NewField(
-                                                       fieldUsernameWithInfo,
+                                                       FieldUsernameWithInfo,
                                                        []byte{00, 02, 00, 02, 00, 03, 00, 02, 00, 04},
                                                ),
                                        },
@@ -304,11 +298,71 @@ func TestHandleChatSend(t *testing.T) {
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       bits.Set(accessSendChat)
+                                                       return bits
+                                               }(),
+                                       },
+                                       UserName: []byte{0x00, 0x01},
+                                       Server: &Server{
+                                               Clients: map[uint16]*ClientConn{
+                                                       uint16(1): {
+                                                               Account: &Account{
+                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                               },
+                                                               ID: &[]byte{0, 1},
+                                                       },
+                                                       uint16(2): {
+                                                               Account: &Account{
+                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                               },
+                                                               ID: &[]byte{0, 2},
+                                                       },
+                                               },
+                                       },
+                               },
+                               t: &Transaction{
+                                       Fields: []Field{
+                                               NewField(FieldData, []byte("hai")),
+                                       },
+                               },
+                       },
+                       want: []Transaction{
+                               {
+                                       clientID:  &[]byte{0, 1},
+                                       Flags:     0x00,
+                                       IsReply:   0x00,
+                                       Type:      []byte{0, 0x6a},
+                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
+                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       Fields: []Field{
+                                               NewField(FieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
+                                       },
+                               },
+                               {
+                                       clientID:  &[]byte{0, 2},
+                                       Flags:     0x00,
+                                       IsReply:   0x00,
+                                       Type:      []byte{0, 0x6a},
+                                       ID:        []byte{0xf0, 0xc5, 0x34, 0x1e}, // Random ID from rand.Seed(1)
+                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       Fields: []Field{
+                                               NewField(FieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
+                                       },
+                               },
+                       },
+                       wantErr: false,
+               },
+               {
+                       name: "treats Chat ID 00 00 00 00 as a public chat message",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessSendChat)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        UserName: []byte{0x00, 0x01},
@@ -316,13 +370,13 @@ func TestHandleChatSend(t *testing.T) {
                                                Clients: map[uint16]*ClientConn{
                                                        uint16(1): {
                                                                Account: &Account{
-                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                },
                                                                ID: &[]byte{0, 1},
                                                        },
                                                        uint16(2): {
                                                                Account: &Account{
-                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                },
                                                                ID: &[]byte{0, 2},
                                                        },
@@ -331,7 +385,8 @@ func TestHandleChatSend(t *testing.T) {
                                },
                                t: &Transaction{
                                        Fields: []Field{
-                                               NewField(fieldData, []byte("hai")),
+                                               NewField(FieldData, []byte("hai")),
+                                               NewField(FieldChatID, []byte{0, 0, 0, 0}),
                                        },
                                },
                        },
@@ -344,7 +399,7 @@ func TestHandleChatSend(t *testing.T) {
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
                                        ErrorCode: []byte{0, 0, 0, 0},
                                        Fields: []Field{
-                                               NewField(fieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
+                                               NewField(FieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
                                        },
                                },
                                {
@@ -355,7 +410,7 @@ func TestHandleChatSend(t *testing.T) {
                                        ID:        []byte{0xf0, 0xc5, 0x34, 0x1e}, // Random ID from rand.Seed(1)
                                        ErrorCode: []byte{0, 0, 0, 0},
                                        Fields: []Field{
-                                               NewField(fieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
+                                               NewField(FieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
                                        },
                                },
                        },
@@ -366,10 +421,9 @@ func TestHandleChatSend(t *testing.T) {
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -377,34 +431,95 @@ func TestHandleChatSend(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranChatSend, &[]byte{0, 1},
-                                       NewField(fieldData, []byte("hai")),
+                                       TranChatSend, &[]byte{0, 1},
+                                       NewField(FieldData, []byte("hai")),
                                ),
                        },
                        want: []Transaction{
                                {
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to participate in chat.")),
+                                               NewField(FieldError, []byte("You are not allowed to participate in chat.")),
+                                       },
+                               },
+                       },
+                       wantErr: false,
+               },
+               {
+                       name: "sends chat msg as emote if FieldChatOptions is set to 1",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       bits.Set(accessSendChat)
+                                                       return bits
+                                               }(),
+                                       },
+                                       UserName: []byte("Testy McTest"),
+                                       Server: &Server{
+                                               Clients: map[uint16]*ClientConn{
+                                                       uint16(1): {
+                                                               Account: &Account{
+                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                               },
+                                                               ID: &[]byte{0, 1},
+                                                       },
+                                                       uint16(2): {
+                                                               Account: &Account{
+                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                               },
+                                                               ID: &[]byte{0, 2},
+                                                       },
+                                               },
+                                       },
+                               },
+                               t: &Transaction{
+                                       Fields: []Field{
+                                               NewField(FieldData, []byte("performed action")),
+                                               NewField(FieldChatOptions, []byte{0x00, 0x01}),
+                                       },
+                               },
+                       },
+                       want: []Transaction{
+                               {
+                                       clientID:  &[]byte{0, 1},
+                                       Flags:     0x00,
+                                       IsReply:   0x00,
+                                       Type:      []byte{0, 0x6a},
+                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
+                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       Fields: []Field{
+                                               NewField(FieldData, []byte("\r*** Testy McTest performed action")),
+                                       },
+                               },
+                               {
+                                       clientID:  &[]byte{0, 2},
+                                       Flags:     0x00,
+                                       IsReply:   0x00,
+                                       Type:      []byte{0, 0x6a},
+                                       ID:        []byte{0xf0, 0xc5, 0x34, 0x1e},
+                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       Fields: []Field{
+                                               NewField(FieldData, []byte("\r*** Testy McTest performed action")),
                                        },
                                },
                        },
                        wantErr: false,
                },
                {
-                       name: "sends chat msg as emote if fieldChatOptions is set",
+                       name: "does not send chat msg as emote if FieldChatOptions is set to 0",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessSendChat)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        UserName: []byte("Testy McTest"),
@@ -412,13 +527,13 @@ func TestHandleChatSend(t *testing.T) {
                                                Clients: map[uint16]*ClientConn{
                                                        uint16(1): {
                                                                Account: &Account{
-                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                },
                                                                ID: &[]byte{0, 1},
                                                        },
                                                        uint16(2): {
                                                                Account: &Account{
-                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                },
                                                                ID: &[]byte{0, 2},
                                                        },
@@ -427,8 +542,8 @@ func TestHandleChatSend(t *testing.T) {
                                },
                                t: &Transaction{
                                        Fields: []Field{
-                                               NewField(fieldData, []byte("performed action")),
-                                               NewField(fieldChatOptions, []byte{0x00, 0x01}),
+                                               NewField(FieldData, []byte("hello")),
+                                               NewField(FieldChatOptions, []byte{0x00, 0x00}),
                                        },
                                },
                        },
@@ -441,7 +556,7 @@ func TestHandleChatSend(t *testing.T) {
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 0},
                                        Fields: []Field{
-                                               NewField(fieldData, []byte("\r*** Testy McTest performed action")),
+                                               NewField(FieldData, []byte("\r Testy McTest:  hello")),
                                        },
                                },
                                {
@@ -452,7 +567,7 @@ func TestHandleChatSend(t *testing.T) {
                                        ID:        []byte{0xf0, 0xc5, 0x34, 0x1e},
                                        ErrorCode: []byte{0, 0, 0, 0},
                                        Fields: []Field{
-                                               NewField(fieldData, []byte("\r*** Testy McTest performed action")),
+                                               NewField(FieldData, []byte("\r Testy McTest:  hello")),
                                        },
                                },
                        },
@@ -463,11 +578,10 @@ func TestHandleChatSend(t *testing.T) {
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessSendChat)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        UserName: []byte{0x00, 0x01},
@@ -475,13 +589,16 @@ func TestHandleChatSend(t *testing.T) {
                                                Clients: map[uint16]*ClientConn{
                                                        uint16(1): {
                                                                Account: &Account{
-                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
-                                                               },
+                                                                       Access: func() accessBitmap {
+                                                                               var bits accessBitmap
+                                                                               bits.Set(accessReadChat)
+                                                                               return bits
+                                                                       }()},
                                                                ID: &[]byte{0, 1},
                                                        },
                                                        uint16(2): {
                                                                Account: &Account{
-                                                                       Access: &[]byte{0, 0, 0, 0, 0, 0, 0, 0},
+                                                                       Access: accessBitmap{0, 0, 0, 0, 0, 0, 0, 0},
                                                                },
                                                                ID: &[]byte{0, 2},
                                                        },
@@ -490,7 +607,7 @@ func TestHandleChatSend(t *testing.T) {
                                },
                                t: &Transaction{
                                        Fields: []Field{
-                                               NewField(fieldData, []byte("hai")),
+                                               NewField(FieldData, []byte("hai")),
                                        },
                                },
                        },
@@ -503,7 +620,7 @@ func TestHandleChatSend(t *testing.T) {
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
                                        ErrorCode: []byte{0, 0, 0, 0},
                                        Fields: []Field{
-                                               NewField(fieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
+                                               NewField(FieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
                                        },
                                },
                        },
@@ -514,11 +631,10 @@ func TestHandleChatSend(t *testing.T) {
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessSendChat)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        UserName: []byte{0x00, 0x01},
@@ -538,19 +654,19 @@ func TestHandleChatSend(t *testing.T) {
                                                Clients: map[uint16]*ClientConn{
                                                        uint16(1): {
                                                                Account: &Account{
-                                                                       Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+                                                                       Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
                                                                },
                                                                ID: &[]byte{0, 1},
                                                        },
                                                        uint16(2): {
                                                                Account: &Account{
-                                                                       Access: &[]byte{0, 0, 0, 0, 0, 0, 0, 0},
+                                                                       Access: accessBitmap{0, 0, 0, 0, 0, 0, 0, 0},
                                                                },
                                                                ID: &[]byte{0, 2},
                                                        },
                                                        uint16(3): {
                                                                Account: &Account{
-                                                                       Access: &[]byte{0, 0, 0, 0, 0, 0, 0, 0},
+                                                                       Access: accessBitmap{0, 0, 0, 0, 0, 0, 0, 0},
                                                                },
                                                                ID: &[]byte{0, 3},
                                                        },
@@ -559,8 +675,8 @@ func TestHandleChatSend(t *testing.T) {
                                },
                                t: &Transaction{
                                        Fields: []Field{
-                                               NewField(fieldData, []byte("hai")),
-                                               NewField(fieldChatID, []byte{0, 0, 0, 1}),
+                                               NewField(FieldData, []byte("hai")),
+                                               NewField(FieldChatID, []byte{0, 0, 0, 1}),
                                        },
                                },
                        },
@@ -573,8 +689,8 @@ func TestHandleChatSend(t *testing.T) {
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 0},
                                        Fields: []Field{
-                                               NewField(fieldChatID, []byte{0, 0, 0, 1}),
-                                               NewField(fieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
+                                               NewField(FieldChatID, []byte{0, 0, 0, 1}),
+                                               NewField(FieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
                                        },
                                },
                                {
@@ -585,8 +701,8 @@ func TestHandleChatSend(t *testing.T) {
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 0},
                                        Fields: []Field{
-                                               NewField(fieldChatID, []byte{0, 0, 0, 1}),
-                                               NewField(fieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
+                                               NewField(FieldChatID, []byte{0, 0, 0, 1}),
+                                               NewField(FieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
                                        },
                                },
                        },
@@ -625,18 +741,19 @@ func TestHandleGetFileInfo(t *testing.T) {
                                cc: &ClientConn{
                                        ID: &[]byte{0x00, 0x01},
                                        Server: &Server{
+                                               FS: &OSFileStore{},
                                                Config: &Config{
                                                        FileRoot: func() string {
                                                                path, _ := os.Getwd()
-                                                               return path + "/test/config/Files"
+                                                               return filepath.Join(path, "/test/config/Files")
                                                        }(),
                                                },
                                        },
                                },
                                t: NewTransaction(
-                                       tranGetFileInfo, nil,
-                                       NewField(fieldFileName, []byte("testfile.txt")),
-                                       NewField(fieldFilePath, []byte{0x00, 0x00}),
+                                       TranGetFileInfo, nil,
+                                       NewField(FieldFileName, []byte("testfile.txt")),
+                                       NewField(FieldFilePath, []byte{0x00, 0x00}),
                                ),
                        },
                        wantRes: []Transaction{
@@ -644,18 +761,17 @@ func TestHandleGetFileInfo(t *testing.T) {
                                        clientID:  &[]byte{0, 1},
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0xce},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
                                        ErrorCode: []byte{0, 0, 0, 0},
                                        Fields: []Field{
-                                               NewField(fieldFileName, []byte("testfile.txt")),
-                                               NewField(fieldFileTypeString, []byte("Text File")),
-                                               NewField(fieldFileCreatorString, []byte("ttxt")),
-                                               NewField(fieldFileComment, []byte{}),
-                                               NewField(fieldFileType, []byte("TEXT")),
-                                               NewField(fieldFileCreateDate, make([]byte, 8)),
-                                               NewField(fieldFileModifyDate, make([]byte, 8)),
-                                               NewField(fieldFileSize, []byte{0x0, 0x0, 0x0, 0x17}),
+                                               NewField(FieldFileName, []byte("testfile.txt")),
+                                               NewField(FieldFileTypeString, []byte("Text File")),
+                                               NewField(FieldFileCreatorString, []byte("ttxt")),
+                                               NewField(FieldFileType, []byte("TEXT")),
+                                               NewField(FieldFileCreateDate, make([]byte, 8)),
+                                               NewField(FieldFileModifyDate, make([]byte, 8)),
+                                               NewField(FieldFileSize, []byte{0x0, 0x0, 0x0, 0x17}),
                                        },
                                },
                        },
@@ -672,10 +788,10 @@ func TestHandleGetFileInfo(t *testing.T) {
                                return
                        }
 
-                       // Clear the file timestamp fields to work around problems running the tests in multiple timezones
+                       // Clear the fileWrapper timestamp fields to work around problems running the tests in multiple timezones
                        // TODO: revisit how to test this by mocking the stat calls
+                       gotRes[0].Fields[4].Data = make([]byte, 8)
                        gotRes[0].Fields[5].Data = make([]byte, 8)
-                       gotRes[0].Fields[6].Data = make([]byte, 8)
                        if !assert.Equal(t, tt.wantRes, gotRes) {
                                t.Errorf("HandleGetFileInfo() gotRes = %v, want %v", gotRes, tt.wantRes)
                        }
@@ -689,22 +805,19 @@ func TestHandleNewFolder(t *testing.T) {
                t  *Transaction
        }
        tests := []struct {
-               setup   func()
                name    string
                args    args
                wantRes []Transaction
                wantErr bool
        }{
                {
-                       name:  "without required permission",
-                       setup: func() {},
+                       name: "without required permission",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                },
@@ -717,11 +830,11 @@ func TestHandleNewFolder(t *testing.T) {
                                {
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to create folders.")),
+                                               NewField(FieldError, []byte("You are not allowed to create folders.")),
                                        },
                                },
                        },
@@ -732,11 +845,10 @@ func TestHandleNewFolder(t *testing.T) {
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessCreateFolder)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        ID: &[]byte{0, 1},
@@ -744,12 +856,18 @@ func TestHandleNewFolder(t *testing.T) {
                                                Config: &Config{
                                                        FileRoot: "/Files/",
                                                },
+                                               FS: func() *MockFileStore {
+                                                       mfs := &MockFileStore{}
+                                                       mfs.On("Mkdir", "/Files/aaa/testFolder", fs.FileMode(0777)).Return(nil)
+                                                       mfs.On("Stat", "/Files/aaa/testFolder").Return(nil, os.ErrNotExist)
+                                                       return mfs
+                                               }(),
                                        },
                                },
                                t: NewTransaction(
-                                       tranNewFolder, &[]byte{0, 1},
-                                       NewField(fieldFileName, []byte("testFolder")),
-                                       NewField(fieldFilePath, []byte{
+                                       TranNewFolder, &[]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testFolder")),
+                                       NewField(FieldFilePath, []byte{
                                                0x00, 0x01,
                                                0x00, 0x00,
                                                0x03,
@@ -757,18 +875,12 @@ func TestHandleNewFolder(t *testing.T) {
                                        }),
                                ),
                        },
-                       setup: func() {
-                               mfs := &MockFileStore{}
-                               mfs.On("Mkdir", "/Files/aaa/testFolder", fs.FileMode(0777)).Return(nil)
-                               mfs.On("Stat", "/Files/aaa/testFolder").Return(nil, os.ErrNotExist)
-                               FS = mfs
-                       },
                        wantRes: []Transaction{
                                {
                                        clientID:  &[]byte{0, 1},
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0xcd},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
                                        ErrorCode: []byte{0, 0, 0, 0},
                                },
@@ -780,11 +892,10 @@ func TestHandleNewFolder(t *testing.T) {
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessCreateFolder)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        ID: &[]byte{0, 1},
@@ -792,25 +903,25 @@ func TestHandleNewFolder(t *testing.T) {
                                                Config: &Config{
                                                        FileRoot: "/Files",
                                                },
+                                               FS: func() *MockFileStore {
+                                                       mfs := &MockFileStore{}
+                                                       mfs.On("Mkdir", "/Files/testFolder", fs.FileMode(0777)).Return(nil)
+                                                       mfs.On("Stat", "/Files/testFolder").Return(nil, os.ErrNotExist)
+                                                       return mfs
+                                               }(),
                                        },
                                },
                                t: NewTransaction(
-                                       tranNewFolder, &[]byte{0, 1},
-                                       NewField(fieldFileName, []byte("testFolder")),
+                                       TranNewFolder, &[]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testFolder")),
                                ),
                        },
-                       setup: func() {
-                               mfs := &MockFileStore{}
-                               mfs.On("Mkdir", "/Files/testFolder", fs.FileMode(0777)).Return(nil)
-                               mfs.On("Stat", "/Files/testFolder").Return(nil, os.ErrNotExist)
-                               FS = mfs
-                       },
                        wantRes: []Transaction{
                                {
                                        clientID:  &[]byte{0, 1},
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0xcd},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
                                        ErrorCode: []byte{0, 0, 0, 0},
                                },
@@ -818,15 +929,14 @@ func TestHandleNewFolder(t *testing.T) {
                        wantErr: false,
                },
                {
-                       name: "when UnmarshalBinary returns an err",
+                       name: "when Write returns an err",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessCreateFolder)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        ID: &[]byte{0, 1},
@@ -834,35 +944,34 @@ func TestHandleNewFolder(t *testing.T) {
                                                Config: &Config{
                                                        FileRoot: "/Files/",
                                                },
+                                               FS: func() *MockFileStore {
+                                                       mfs := &MockFileStore{}
+                                                       mfs.On("Mkdir", "/Files/aaa/testFolder", fs.FileMode(0777)).Return(nil)
+                                                       mfs.On("Stat", "/Files/aaa/testFolder").Return(nil, os.ErrNotExist)
+                                                       return mfs
+                                               }(),
                                        },
                                },
                                t: NewTransaction(
-                                       tranNewFolder, &[]byte{0, 1},
-                                       NewField(fieldFileName, []byte("testFolder")),
-                                       NewField(fieldFilePath, []byte{
+                                       TranNewFolder, &[]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testFolder")),
+                                       NewField(FieldFilePath, []byte{
                                                0x00,
                                        }),
                                ),
                        },
-                       setup: func() {
-                               mfs := &MockFileStore{}
-                               mfs.On("Mkdir", "/Files/aaa/testFolder", fs.FileMode(0777)).Return(nil)
-                               mfs.On("Stat", "/Files/aaa/testFolder").Return(nil, os.ErrNotExist)
-                               FS = mfs
-                       },
                        wantRes: []Transaction{},
                        wantErr: true,
                },
                {
-                       name: "fieldFileName does not allow directory traversal",
+                       name: "FieldFileName does not allow directory traversal",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessCreateFolder)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        ID: &[]byte{0, 1},
@@ -870,40 +979,39 @@ func TestHandleNewFolder(t *testing.T) {
                                                Config: &Config{
                                                        FileRoot: "/Files/",
                                                },
+                                               FS: func() *MockFileStore {
+                                                       mfs := &MockFileStore{}
+                                                       mfs.On("Mkdir", "/Files/testFolder", fs.FileMode(0777)).Return(nil)
+                                                       mfs.On("Stat", "/Files/testFolder").Return(nil, os.ErrNotExist)
+                                                       return mfs
+                                               }(),
                                        },
                                },
                                t: NewTransaction(
-                                       tranNewFolder, &[]byte{0, 1},
-                                       NewField(fieldFileName, []byte("../../testFolder")),
+                                       TranNewFolder, &[]byte{0, 1},
+                                       NewField(FieldFileName, []byte("../../testFolder")),
                                ),
                        },
-                       setup: func() {
-                               mfs := &MockFileStore{}
-                               mfs.On("Mkdir", "/Files/testFolder", fs.FileMode(0777)).Return(nil)
-                               mfs.On("Stat", "/Files/testFolder").Return(nil, os.ErrNotExist)
-                               FS = mfs
-                       },
                        wantRes: []Transaction{
                                {
                                        clientID:  &[]byte{0, 1},
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0xcd},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
                                        ErrorCode: []byte{0, 0, 0, 0},
                                },
                        }, wantErr: false,
                },
                {
-                       name: "fieldFilePath does not allow directory traversal",
+                       name: "FieldFilePath does not allow directory traversal",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessCreateFolder)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        ID: &[]byte{0, 1},
@@ -911,12 +1019,18 @@ func TestHandleNewFolder(t *testing.T) {
                                                Config: &Config{
                                                        FileRoot: "/Files/",
                                                },
+                                               FS: func() *MockFileStore {
+                                                       mfs := &MockFileStore{}
+                                                       mfs.On("Mkdir", "/Files/foo/testFolder", fs.FileMode(0777)).Return(nil)
+                                                       mfs.On("Stat", "/Files/foo/testFolder").Return(nil, os.ErrNotExist)
+                                                       return mfs
+                                               }(),
                                        },
                                },
                                t: NewTransaction(
-                                       tranNewFolder, &[]byte{0, 1},
-                                       NewField(fieldFileName, []byte("testFolder")),
-                                       NewField(fieldFilePath, []byte{
+                                       TranNewFolder, &[]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testFolder")),
+                                       NewField(FieldFilePath, []byte{
                                                0x00, 0x02,
                                                0x00, 0x00,
                                                0x03,
@@ -927,18 +1041,12 @@ func TestHandleNewFolder(t *testing.T) {
                                        }),
                                ),
                        },
-                       setup: func() {
-                               mfs := &MockFileStore{}
-                               mfs.On("Mkdir", "/Files/foo/testFolder", fs.FileMode(0777)).Return(nil)
-                               mfs.On("Stat", "/Files/foo/testFolder").Return(nil, os.ErrNotExist)
-                               FS = mfs
-                       },
                        wantRes: []Transaction{
                                {
                                        clientID:  &[]byte{0, 1},
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0xcd},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
                                        ErrorCode: []byte{0, 0, 0, 0},
                                },
@@ -947,8 +1055,6 @@ func TestHandleNewFolder(t *testing.T) {
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       tt.setup()
-
                        gotRes, err := HandleNewFolder(tt.args.cc, tt.args.t)
                        if (err != nil) != tt.wantErr {
                                t.Errorf("HandleNewFolder() error = %v, wantErr %v", err, tt.wantErr)
@@ -978,22 +1084,27 @@ func TestHandleUploadFile(t *testing.T) {
                        args: args{
                                cc: &ClientConn{
                                        Server: &Server{
-                                               FileTransfers: map[uint32]*FileTransfer{},
+                                               FS:            &OSFileStore{},
+                                               fileTransfers: map[[4]byte]*FileTransfer{},
+                                               Config: &Config{
+                                                       FileRoot: func() string { path, _ := os.Getwd(); return path + "/test/config/Files" }(),
+                                               }},
+                                       transfers: map[int]map[[4]byte]*FileTransfer{
+                                               FileUpload: {},
                                        },
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessUploadFile)
                                                        bits.Set(accessUploadAnywhere)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                },
                                t: NewTransaction(
-                                       tranUploadFile, &[]byte{0, 1},
-                                       NewField(fieldFileName, []byte("testFile")),
-                                       NewField(fieldFilePath, []byte{
+                                       TranUploadFile, &[]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testFile")),
+                                       NewField(FieldFilePath, []byte{
                                                0x00, 0x01,
                                                0x00, 0x00,
                                                0x03,
@@ -1005,11 +1116,11 @@ func TestHandleUploadFile(t *testing.T) {
                                {
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0xcb},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 0},
                                        Fields: []Field{
-                                               NewField(fieldRefNum, []byte{0x52, 0xfd, 0xfc, 0x07}), // rand.Seed(1)
+                                               NewField(FieldRefNum, []byte{0x52, 0xfd, 0xfc, 0x07}), // rand.Seed(1)
                                        },
                                },
                        },
@@ -1020,20 +1131,16 @@ func TestHandleUploadFile(t *testing.T) {
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
-                                       Server: &Server{
-                                               FileTransfers: map[uint32]*FileTransfer{},
-                                       },
                                },
                                t: NewTransaction(
-                                       tranUploadFile, &[]byte{0, 1},
-                                       NewField(fieldFileName, []byte("testFile")),
-                                       NewField(fieldFilePath, []byte{
+                                       TranUploadFile, &[]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testFile")),
+                                       NewField(FieldFilePath, []byte{
                                                0x00, 0x01,
                                                0x00, 0x00,
                                                0x03,
@@ -1045,11 +1152,11 @@ func TestHandleUploadFile(t *testing.T) {
                                {
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to upload files.")), // rand.Seed(1)
+                                               NewField(FieldError, []byte("You are not allowed to upload files.")), // rand.Seed(1)
                                        },
                                },
                        },
@@ -1066,7 +1173,6 @@ func TestHandleUploadFile(t *testing.T) {
                        }
 
                        tranAssertEqual(t, tt.wantRes, gotRes)
-
                })
        }
 }
@@ -1078,31 +1184,20 @@ func TestHandleMakeAlias(t *testing.T) {
        }
        tests := []struct {
                name    string
-               setup   func()
                args    args
                wantRes []Transaction
                wantErr bool
        }{
                {
                        name: "with valid input and required permissions",
-                       setup: func() {
-                               mfs := &MockFileStore{}
-                               path, _ := os.Getwd()
-                               mfs.On(
-                                       "Symlink",
-                                       path+"/test/config/Files/foo/testFile",
-                                       path+"/test/config/Files/bar/testFile",
-                               ).Return(nil)
-                               FS = mfs
-                       },
                        args: args{
                                cc: &ClientConn{
+                                       logger: NewTestLogger(),
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessMakeAlias)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1113,20 +1208,30 @@ func TestHandleMakeAlias(t *testing.T) {
                                                        }(),
                                                },
                                                Logger: NewTestLogger(),
+                                               FS: func() *MockFileStore {
+                                                       mfs := &MockFileStore{}
+                                                       path, _ := os.Getwd()
+                                                       mfs.On(
+                                                               "Symlink",
+                                                               path+"/test/config/Files/foo/testFile",
+                                                               path+"/test/config/Files/bar/testFile",
+                                                       ).Return(nil)
+                                                       return mfs
+                                               }(),
                                        },
                                },
                                t: NewTransaction(
-                                       tranMakeFileAlias, &[]byte{0, 1},
-                                       NewField(fieldFileName, []byte("testFile")),
-                                       NewField(fieldFilePath, EncodeFilePath(strings.Join([]string{"foo"}, "/"))),
-                                       NewField(fieldFileNewPath, EncodeFilePath(strings.Join([]string{"bar"}, "/"))),
+                                       TranMakeFileAlias, &[]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testFile")),
+                                       NewField(FieldFilePath, EncodeFilePath(strings.Join([]string{"foo"}, "/"))),
+                                       NewField(FieldFileNewPath, EncodeFilePath(strings.Join([]string{"bar"}, "/"))),
                                ),
                        },
                        wantRes: []Transaction{
                                {
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0xd1},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 0},
                                        Fields:    []Field(nil),
@@ -1136,24 +1241,14 @@ func TestHandleMakeAlias(t *testing.T) {
                },
                {
                        name: "when symlink returns an error",
-                       setup: func() {
-                               mfs := &MockFileStore{}
-                               path, _ := os.Getwd()
-                               mfs.On(
-                                       "Symlink",
-                                       path+"/test/config/Files/foo/testFile",
-                                       path+"/test/config/Files/bar/testFile",
-                               ).Return(errors.New("ohno"))
-                               FS = mfs
-                       },
                        args: args{
                                cc: &ClientConn{
+                                       logger: NewTestLogger(),
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessMakeAlias)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1164,39 +1259,48 @@ func TestHandleMakeAlias(t *testing.T) {
                                                        }(),
                                                },
                                                Logger: NewTestLogger(),
+                                               FS: func() *MockFileStore {
+                                                       mfs := &MockFileStore{}
+                                                       path, _ := os.Getwd()
+                                                       mfs.On(
+                                                               "Symlink",
+                                                               path+"/test/config/Files/foo/testFile",
+                                                               path+"/test/config/Files/bar/testFile",
+                                                       ).Return(errors.New("ohno"))
+                                                       return mfs
+                                               }(),
                                        },
                                },
                                t: NewTransaction(
-                                       tranMakeFileAlias, &[]byte{0, 1},
-                                       NewField(fieldFileName, []byte("testFile")),
-                                       NewField(fieldFilePath, EncodeFilePath(strings.Join([]string{"foo"}, "/"))),
-                                       NewField(fieldFileNewPath, EncodeFilePath(strings.Join([]string{"bar"}, "/"))),
+                                       TranMakeFileAlias, &[]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testFile")),
+                                       NewField(FieldFilePath, EncodeFilePath(strings.Join([]string{"foo"}, "/"))),
+                                       NewField(FieldFileNewPath, EncodeFilePath(strings.Join([]string{"bar"}, "/"))),
                                ),
                        },
                        wantRes: []Transaction{
                                {
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("Error creating alias")),
+                                               NewField(FieldError, []byte("Error creating alias")),
                                        },
                                },
                        },
                        wantErr: false,
                },
                {
-                       name:  "when user does not have required permission",
-                       setup: func() {},
+                       name: "when user does not have required permission",
                        args: args{
                                cc: &ClientConn{
+                                       logger: NewTestLogger(),
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1209,15 +1313,15 @@ func TestHandleMakeAlias(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranMakeFileAlias, &[]byte{0, 1},
-                                       NewField(fieldFileName, []byte("testFile")),
-                                       NewField(fieldFilePath, []byte{
+                                       TranMakeFileAlias, &[]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testFile")),
+                                       NewField(FieldFilePath, []byte{
                                                0x00, 0x01,
                                                0x00, 0x00,
                                                0x03,
                                                0x2e, 0x2e, 0x2e,
                                        }),
-                                       NewField(fieldFileNewPath, []byte{
+                                       NewField(FieldFileNewPath, []byte{
                                                0x00, 0x01,
                                                0x00, 0x00,
                                                0x03,
@@ -1229,11 +1333,11 @@ func TestHandleMakeAlias(t *testing.T) {
                                {
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to make aliases.")),
+                                               NewField(FieldError, []byte("You are not allowed to make aliases.")),
                                        },
                                },
                        },
@@ -1242,8 +1346,6 @@ func TestHandleMakeAlias(t *testing.T) {
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       tt.setup()
-
                        gotRes, err := HandleMakeAlias(tt.args.cc, tt.args.t)
                        if (err != nil) != tt.wantErr {
                                t.Errorf("HandleMakeAlias(%v, %v)", tt.args.cc, tt.args.t)
@@ -1271,11 +1373,10 @@ func TestHandleGetUser(t *testing.T) {
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessOpenUser)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1284,28 +1385,28 @@ func TestHandleGetUser(t *testing.T) {
                                                                Login:    "guest",
                                                                Name:     "Guest",
                                                                Password: "password",
-                                                               Access:   &[]byte{1},
+                                                               Access:   accessBitmap{},
                                                        },
                                                },
                                        },
                                },
                                t: NewTransaction(
-                                       tranGetUser, &[]byte{0, 1},
-                                       NewField(fieldUserLogin, []byte("guest")),
+                                       TranGetUser, &[]byte{0, 1},
+                                       NewField(FieldUserLogin, []byte("guest")),
                                ),
                        },
                        wantRes: []Transaction{
                                {
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0x01, 0x60},
+                                       Type:      []byte{00},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 0},
                                        Fields: []Field{
-                                               NewField(fieldUserName, []byte("Guest")),
-                                               NewField(fieldUserLogin, negateString([]byte("guest"))),
-                                               NewField(fieldUserPassword, []byte("password")),
-                                               NewField(fieldUserAccess, []byte{1}),
+                                               NewField(FieldUserName, []byte("Guest")),
+                                               NewField(FieldUserLogin, encodeString([]byte("guest"))),
+                                               NewField(FieldUserPassword, []byte("password")),
+                                               NewField(FieldUserAccess, []byte{0, 0, 0, 0, 0, 0, 0, 0}),
                                        },
                                },
                        },
@@ -1316,10 +1417,9 @@ func TestHandleGetUser(t *testing.T) {
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1327,19 +1427,19 @@ func TestHandleGetUser(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranGetUser, &[]byte{0, 1},
-                                       NewField(fieldUserLogin, []byte("nonExistentUser")),
+                                       TranGetUser, &[]byte{0, 1},
+                                       NewField(FieldUserLogin, []byte("nonExistentUser")),
                                ),
                        },
                        wantRes: []Transaction{
                                {
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to view accounts.")),
+                                               NewField(FieldError, []byte("You are not allowed to view accounts.")),
                                        },
                                },
                        },
@@ -1350,11 +1450,10 @@ func TestHandleGetUser(t *testing.T) {
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessOpenUser)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1362,19 +1461,19 @@ func TestHandleGetUser(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranGetUser, &[]byte{0, 1},
-                                       NewField(fieldUserLogin, []byte("nonExistentUser")),
+                                       TranGetUser, &[]byte{0, 1},
+                                       NewField(FieldUserLogin, []byte("nonExistentUser")),
                                ),
                        },
                        wantRes: []Transaction{
                                {
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("Account does not exist.")),
+                                               NewField(FieldError, []byte("Account does not exist.")),
                                        },
                                },
                        },
@@ -1400,26 +1499,19 @@ func TestHandleDeleteUser(t *testing.T) {
        }
        tests := []struct {
                name    string
-               setup   func()
                args    args
                wantRes []Transaction
                wantErr assert.ErrorAssertionFunc
        }{
                {
-                       name: "when user exists",
-                       setup: func() {
-                               mfs := &MockFileStore{}
-                               mfs.On("Remove", "Users/testuser.yaml").Return(nil)
-                               FS = mfs
-                       },
+                       name: "when user dataFile",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessDeleteUser)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1428,21 +1520,26 @@ func TestHandleDeleteUser(t *testing.T) {
                                                                Login:    "testuser",
                                                                Name:     "Testy McTest",
                                                                Password: "password",
-                                                               Access:   &[]byte{1},
+                                                               Access:   accessBitmap{},
                                                        },
                                                },
+                                               FS: func() *MockFileStore {
+                                                       mfs := &MockFileStore{}
+                                                       mfs.On("Remove", "Users/testuser.yaml").Return(nil)
+                                                       return mfs
+                                               }(),
                                        },
                                },
                                t: NewTransaction(
-                                       tranDeleteUser, &[]byte{0, 1},
-                                       NewField(fieldUserLogin, negateString([]byte("testuser"))),
+                                       TranDeleteUser, &[]byte{0, 1},
+                                       NewField(FieldUserLogin, encodeString([]byte("testuser"))),
                                ),
                        },
                        wantRes: []Transaction{
                                {
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0x1, 0x5f},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 0},
                                        Fields:    []Field(nil),
@@ -1451,15 +1548,13 @@ func TestHandleDeleteUser(t *testing.T) {
                        wantErr: assert.NoError,
                },
                {
-                       name:  "when user does not have required permission",
-                       setup: func() {},
+                       name: "when user does not have required permission",
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1467,19 +1562,19 @@ func TestHandleDeleteUser(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranDeleteUser, &[]byte{0, 1},
-                                       NewField(fieldUserLogin, negateString([]byte("testuser"))),
+                                       TranDeleteUser, &[]byte{0, 1},
+                                       NewField(FieldUserLogin, encodeString([]byte("testuser"))),
                                ),
                        },
                        wantRes: []Transaction{
                                {
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to delete accounts.")),
+                                               NewField(FieldError, []byte("You are not allowed to delete accounts.")),
                                        },
                                },
                        },
@@ -1488,7 +1583,6 @@ func TestHandleDeleteUser(t *testing.T) {
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       tt.setup()
                        gotRes, err := HandleDeleteUser(tt.args.cc, tt.args.t)
                        if !tt.wantErr(t, err, fmt.Sprintf("HandleDeleteUser(%v, %v)", tt.args.cc, tt.args.t)) {
                                return
@@ -1515,11 +1609,10 @@ func TestHandleGetMsgs(t *testing.T) {
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessNewsReadArt)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1527,18 +1620,18 @@ func TestHandleGetMsgs(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranGetMsgs, &[]byte{0, 1},
+                                       TranGetMsgs, &[]byte{0, 1},
                                ),
                        },
                        wantRes: []Transaction{
                                {
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x65},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 0},
                                        Fields: []Field{
-                                               NewField(fieldData, []byte("TEST")),
+                                               NewField(FieldData, []byte("TEST")),
                                        },
                                },
                        },
@@ -1549,10 +1642,9 @@ func TestHandleGetMsgs(t *testing.T) {
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1560,18 +1652,18 @@ func TestHandleGetMsgs(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranGetMsgs, &[]byte{0, 1},
+                                       TranGetMsgs, &[]byte{0, 1},
                                ),
                        },
                        wantRes: []Transaction{
                                {
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to read news.")),
+                                               NewField(FieldError, []byte("You are not allowed to read news.")),
                                        },
                                },
                        },
@@ -1606,10 +1698,42 @@ func TestHandleNewUser(t *testing.T) {
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       return bits
+                                               }(),
+                                       },
+                                       Server: &Server{
+                                               Accounts: map[string]*Account{},
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranNewUser, &[]byte{0, 1},
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      []byte{0, 0},
+                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
+                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       Fields: []Field{
+                                               NewField(FieldError, []byte("You are not allowed to create new accounts.")),
+                                       },
+                               },
+                       },
+                       wantErr: assert.NoError,
+               },
+               {
+                       name: "when user attempts to create account with greater access",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       bits.Set(accessCreateUser)
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1617,18 +1741,27 @@ func TestHandleNewUser(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranNewUser, &[]byte{0, 1},
+                                       TranNewUser, &[]byte{0, 1},
+                                       NewField(FieldUserLogin, []byte("userB")),
+                                       NewField(
+                                               FieldUserAccess,
+                                               func() []byte {
+                                                       var bits accessBitmap
+                                                       bits.Set(accessDisconUser)
+                                                       return bits[:]
+                                               }(),
+                                       ),
                                ),
                        },
                        wantRes: []Transaction{
                                {
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to create new accounts.")),
+                                               NewField(FieldError, []byte("Cannot create account with more access than yourself.")),
                                        },
                                },
                        },
@@ -1663,10 +1796,9 @@ func TestHandleListUsers(t *testing.T) {
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
@@ -1674,18 +1806,63 @@ func TestHandleListUsers(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranNewUser, &[]byte{0, 1},
+                                       TranNewUser, &[]byte{0, 1},
                                ),
                        },
                        wantRes: []Transaction{
                                {
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to view accounts.")),
+                                               NewField(FieldError, []byte("You are not allowed to view accounts.")),
+                                       },
+                               },
+                       },
+                       wantErr: assert.NoError,
+               },
+               {
+                       name: "when user has required permission",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       bits.Set(accessOpenUser)
+                                                       return bits
+                                               }(),
+                                       },
+                                       Server: &Server{
+                                               Accounts: map[string]*Account{
+                                                       "guest": {
+                                                               Name:     "guest",
+                                                               Login:    "guest",
+                                                               Password: "zz",
+                                                               Access:   accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
+                                                       },
+                                               },
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranGetClientInfoText, &[]byte{0, 1},
+                                       NewField(FieldUserID, []byte{0, 1}),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      []byte{0, 0},
+                                       ID:        []byte{0, 0, 0, 0},
+                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       Fields: []Field{
+                                               NewField(FieldData, []byte{
+                                                       0x00, 0x04, 0x00, 0x66, 0x00, 0x05, 0x67, 0x75, 0x65, 0x73, 0x74, 0x00, 0x69, 0x00, 0x05, 0x98,
+                                                       0x8a, 0x9a, 0x8c, 0x8b, 0x00, 0x6e, 0x00, 0x08, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+                                                       0x00, 0x6a, 0x00, 0x01, 0x78,
+                                               }),
                                        },
                                },
                        },
@@ -1720,25 +1897,24 @@ func TestHandleDownloadFile(t *testing.T) {
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{},
                                },
-                               t: NewTransaction(tranDownloadFile, &[]byte{0, 1}),
+                               t: NewTransaction(TranDownloadFile, &[]byte{0, 1}),
                        },
                        wantRes: []Transaction{
                                {
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to download files.")),
+                                               NewField(FieldError, []byte("You are not allowed to download files.")),
                                        },
                                },
                        },
@@ -1748,17 +1924,83 @@ func TestHandleDownloadFile(t *testing.T) {
                        name: "with a valid file",
                        args: args{
                                cc: &ClientConn{
-                                       Transfers: make(map[int][]*FileTransfer),
+                                       transfers: map[int]map[[4]byte]*FileTransfer{
+                                               FileDownload: {},
+                                       },
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       bits.Set(accessDownloadFile)
+                                                       return bits
+                                               }(),
+                                       },
+                                       Server: &Server{
+                                               FS:            &OSFileStore{},
+                                               fileTransfers: map[[4]byte]*FileTransfer{},
+                                               Config: &Config{
+                                                       FileRoot: func() string { path, _ := os.Getwd(); return path + "/test/config/Files" }(),
+                                               },
+                                               Accounts: map[string]*Account{},
+                                       },
+                               },
+                               t: NewTransaction(
+                                       accessDownloadFile,
+                                       &[]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testfile.txt")),
+                                       NewField(FieldFilePath, []byte{0x0, 0x00}),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      []byte{0, 0},
+                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
+                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       Fields: []Field{
+                                               NewField(FieldRefNum, []byte{0x52, 0xfd, 0xfc, 0x07}),
+                                               NewField(FieldWaitingCount, []byte{0x00, 0x00}),
+                                               NewField(FieldTransferSize, []byte{0x00, 0x00, 0x00, 0xa5}),
+                                               NewField(FieldFileSize, []byte{0x00, 0x00, 0x00, 0x17}),
+                                       },
+                               },
+                       },
+                       wantErr: assert.NoError,
+               },
+               {
+                       name: "when client requests to resume 1k test file at offset 256",
+                       args: args{
+                               cc: &ClientConn{
+                                       transfers: map[int]map[[4]byte]*FileTransfer{
+                                               FileDownload: {},
+                                       }, Account: &Account{
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessDownloadFile)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                        Server: &Server{
-                                               FileTransfers: make(map[uint32]*FileTransfer),
+                                               FS: &OSFileStore{},
+
+                                               // FS: func() *MockFileStore {
+                                               //      path, _ := os.Getwd()
+                                               //      testFile, err := os.Open(path + "/test/config/Files/testfile-1k")
+                                               //      if err != nil {
+                                               //              panic(err)
+                                               //      }
+                                               //
+                                               //      mfi := &MockFileInfo{}
+                                               //      mfi.On("Mode").Return(fs.FileMode(0))
+                                               //      mfs := &MockFileStore{}
+                                               //      mfs.On("Stat", "/fakeRoot/Files/testfile.txt").Return(mfi, nil)
+                                               //      mfs.On("Open", "/fakeRoot/Files/testfile.txt").Return(testFile, nil)
+                                               //      mfs.On("Stat", "/fakeRoot/Files/.info_testfile.txt").Return(nil, errors.New("no"))
+                                               //      mfs.On("Stat", "/fakeRoot/Files/.rsrc_testfile.txt").Return(nil, errors.New("no"))
+                                               //
+                                               //      return mfs
+                                               // }(),
+                                               fileTransfers: map[[4]byte]*FileTransfer{},
                                                Config: &Config{
                                                        FileRoot: func() string { path, _ := os.Getwd(); return path + "/test/config/Files" }(),
                                                },
@@ -1768,22 +2010,49 @@ func TestHandleDownloadFile(t *testing.T) {
                                t: NewTransaction(
                                        accessDownloadFile,
                                        &[]byte{0, 1},
-                                       NewField(fieldFileName, []byte("testfile.txt")),
-                                       NewField(fieldFilePath, []byte{0x0, 0x00}),
+                                       NewField(FieldFileName, []byte("testfile-1k")),
+                                       NewField(FieldFilePath, []byte{0x00, 0x00}),
+                                       NewField(
+                                               FieldFileResumeData,
+                                               func() []byte {
+                                                       frd := FileResumeData{
+                                                               Format:    [4]byte{},
+                                                               Version:   [2]byte{},
+                                                               RSVD:      [34]byte{},
+                                                               ForkCount: [2]byte{0, 2},
+                                                               ForkInfoList: []ForkInfoList{
+                                                                       {
+                                                                               Fork:     [4]byte{0x44, 0x41, 0x54, 0x41}, // "DATA"
+                                                                               DataSize: [4]byte{0, 0, 0x01, 0x00},       // request offset 256
+                                                                               RSVDA:    [4]byte{},
+                                                                               RSVDB:    [4]byte{},
+                                                                       },
+                                                                       {
+                                                                               Fork:     [4]byte{0x4d, 0x41, 0x43, 0x52}, // "MACR"
+                                                                               DataSize: [4]byte{0, 0, 0, 0},
+                                                                               RSVDA:    [4]byte{},
+                                                                               RSVDB:    [4]byte{},
+                                                                       },
+                                                               },
+                                                       }
+                                                       b, _ := frd.BinaryMarshal()
+                                                       return b
+                                               }(),
+                                       ),
                                ),
                        },
                        wantRes: []Transaction{
                                {
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x2},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 0},
                                        Fields: []Field{
-                                               NewField(fieldRefNum, []byte{0x52, 0xfd, 0xfc, 0x07}),
-                                               NewField(fieldWaitingCount, []byte{0x00, 0x00}),
-                                               NewField(fieldTransferSize, []byte{0x00, 0x00, 0x00, 0xa5}),
-                                               NewField(fieldFileSize, []byte{0x00, 0x00, 0x00, 0x17}),
+                                               NewField(FieldRefNum, []byte{0x52, 0xfd, 0xfc, 0x07}),
+                                               NewField(FieldWaitingCount, []byte{0x00, 0x00}),
+                                               NewField(FieldTransferSize, []byte{0x00, 0x00, 0x03, 0x8d}),
+                                               NewField(FieldFileSize, []byte{0x00, 0x00, 0x03, 0x00}),
                                        },
                                },
                        },
@@ -1792,9 +2061,6 @@ func TestHandleDownloadFile(t *testing.T) {
        }
        for _, tt := range tests {
                t.Run(tt.name, func(t *testing.T) {
-                       // reset the rand seed so that the random fieldRefNum will be deterministic
-                       rand.Seed(1)
-
                        gotRes, err := HandleDownloadFile(tt.args.cc, tt.args.t)
                        if !tt.wantErr(t, err, fmt.Sprintf("HandleDownloadFile(%v, %v)", tt.args.cc, tt.args.t)) {
                                return
@@ -1820,36 +2086,36 @@ func TestHandleUpdateUser(t *testing.T) {
                        name: "when action is create user without required permission",
                        args: args{
                                cc: &ClientConn{
+                                       logger: NewTestLogger(),
                                        Server: &Server{
                                                Logger: NewTestLogger(),
                                        },
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                },
                                t: NewTransaction(
-                                       tranUpdateUser,
+                                       TranUpdateUser,
                                        &[]byte{0, 0},
-                                       NewField(fieldData, []byte{
+                                       NewField(FieldData, []byte{
                                                0x00, 0x04, // field count
 
-                                               0x00, 0x69, // fieldUserLogin = 105
+                                               0x00, 0x69, // FieldUserLogin = 105
                                                0x00, 0x03,
                                                0x9d, 0x9d, 0x9d,
 
-                                               0x00, 0x6a, // fieldUserPassword = 106
+                                               0x00, 0x6a, // FieldUserPassword = 106
                                                0x00, 0x03,
                                                0x9c, 0x9c, 0x9c,
 
-                                               0x00, 0x66, // fieldUserName = 102
+                                               0x00, 0x66, // FieldUserName = 102
                                                0x00, 0x03,
                                                0x61, 0x61, 0x61,
 
-                                               0x00, 0x6e, // fieldUserAccess = 110
+                                               0x00, 0x6e, // FieldUserAccess = 110
                                                0x00, 0x08,
                                                0x60, 0x70, 0x0c, 0x20, 0x03, 0x80, 0x00, 0x00,
                                        }),
@@ -1859,11 +2125,11 @@ func TestHandleUpdateUser(t *testing.T) {
                                {
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to create new accounts.")),
+                                               NewField(FieldError, []byte("You are not allowed to create new accounts.")),
                                        },
                                },
                        },
@@ -1873,6 +2139,7 @@ func TestHandleUpdateUser(t *testing.T) {
                        name: "when action is modify user without required permission",
                        args: args{
                                cc: &ClientConn{
+                                       logger: NewTestLogger(),
                                        Server: &Server{
                                                Logger: NewTestLogger(),
                                                Accounts: map[string]*Account{
@@ -1880,32 +2147,31 @@ func TestHandleUpdateUser(t *testing.T) {
                                                },
                                        },
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                },
                                t: NewTransaction(
-                                       tranUpdateUser,
+                                       TranUpdateUser,
                                        &[]byte{0, 0},
-                                       NewField(fieldData, []byte{
+                                       NewField(FieldData, []byte{
                                                0x00, 0x04, // field count
 
-                                               0x00, 0x69, // fieldUserLogin = 105
+                                               0x00, 0x69, // FieldUserLogin = 105
                                                0x00, 0x03,
                                                0x9d, 0x9d, 0x9d,
 
-                                               0x00, 0x6a, // fieldUserPassword = 106
+                                               0x00, 0x6a, // FieldUserPassword = 106
                                                0x00, 0x03,
                                                0x9c, 0x9c, 0x9c,
 
-                                               0x00, 0x66, // fieldUserName = 102
+                                               0x00, 0x66, // FieldUserName = 102
                                                0x00, 0x03,
                                                0x61, 0x61, 0x61,
 
-                                               0x00, 0x6e, // fieldUserAccess = 110
+                                               0x00, 0x6e, // FieldUserAccess = 110
                                                0x00, 0x08,
                                                0x60, 0x70, 0x0c, 0x20, 0x03, 0x80, 0x00, 0x00,
                                        }),
@@ -1915,11 +2181,11 @@ func TestHandleUpdateUser(t *testing.T) {
                                {
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to modify accounts.")),
+                                               NewField(FieldError, []byte("You are not allowed to modify accounts.")),
                                        },
                                },
                        },
@@ -1929,24 +2195,23 @@ func TestHandleUpdateUser(t *testing.T) {
                        name: "when action is delete user without required permission",
                        args: args{
                                cc: &ClientConn{
+                                       logger: NewTestLogger(),
                                        Server: &Server{
-                                               Logger: NewTestLogger(),
                                                Accounts: map[string]*Account{
                                                        "bbb": {},
                                                },
                                        },
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                },
                                t: NewTransaction(
-                                       tranUpdateUser,
+                                       TranUpdateUser,
                                        &[]byte{0, 0},
-                                       NewField(fieldData, []byte{
+                                       NewField(FieldData, []byte{
                                                0x00, 0x01,
                                                0x00, 0x65,
                                                0x00, 0x03,
@@ -1958,11 +2223,11 @@ func TestHandleUpdateUser(t *testing.T) {
                                {
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to delete accounts.")),
+                                               NewField(FieldError, []byte("You are not allowed to delete accounts.")),
                                        },
                                },
                        },
@@ -1997,15 +2262,14 @@ func TestHandleDelNewsArt(t *testing.T) {
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                },
                                t: NewTransaction(
-                                       tranDelNewsArt,
+                                       TranDelNewsArt,
                                        &[]byte{0, 0},
                                ),
                        },
@@ -2013,11 +2277,11 @@ func TestHandleDelNewsArt(t *testing.T) {
                                {
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to delete news articles.")),
+                                               NewField(FieldError, []byte("You are not allowed to delete news articles.")),
                                        },
                                },
                        },
@@ -2051,15 +2315,14 @@ func TestHandleDisconnectUser(t *testing.T) {
                        args: args{
                                cc: &ClientConn{
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                },
                                t: NewTransaction(
-                                       tranDelNewsArt,
+                                       TranDelNewsArt,
                                        &[]byte{0, 0},
                                ),
                        },
@@ -2067,11 +2330,11 @@ func TestHandleDisconnectUser(t *testing.T) {
                                {
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("You are not allowed to disconnect users.")),
+                                               NewField(FieldError, []byte("You are not allowed to disconnect users.")),
                                        },
                                },
                        },
@@ -2086,40 +2349,38 @@ func TestHandleDisconnectUser(t *testing.T) {
                                                        uint16(1): {
                                                                Account: &Account{
                                                                        Login: "unnamed",
-                                                                       Access: func() *[]byte {
+                                                                       Access: func() accessBitmap {
                                                                                var bits accessBitmap
                                                                                bits.Set(accessCannotBeDiscon)
-                                                                               access := bits[:]
-                                                                               return &access
+                                                                               return bits
                                                                        }(),
                                                                },
                                                        },
                                                },
                                        },
                                        Account: &Account{
-                                               Access: func() *[]byte {
+                                               Access: func() accessBitmap {
                                                        var bits accessBitmap
                                                        bits.Set(accessDisconUser)
-                                                       access := bits[:]
-                                                       return &access
+                                                       return bits
                                                }(),
                                        },
                                },
                                t: NewTransaction(
-                                       tranDelNewsArt,
+                                       TranDelNewsArt,
                                        &[]byte{0, 0},
-                                       NewField(fieldUserID, []byte{0, 1}),
+                                       NewField(FieldUserID, []byte{0, 1}),
                                ),
                        },
                        wantRes: []Transaction{
                                {
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0, 0x00},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
                                        ErrorCode: []byte{0, 0, 0, 1},
                                        Fields: []Field{
-                                               NewField(fieldError, []byte("unnamed is not allowed to be disconnected.")),
+                                               NewField(FieldError, []byte("unnamed is not allowed to be disconnected.")),
                                        },
                                },
                        },
@@ -2149,40 +2410,78 @@ func TestHandleSendInstantMsg(t *testing.T) {
                wantErr assert.ErrorAssertionFunc
        }{
                {
-                       name: "when client 1 sends a message to client 2",
+                       name: "without required permission",
                        args: args{
                                cc: &ClientConn{
-                                       ID:       &[]byte{0, 1},
-                                       UserName: []byte("User1"),
-                                       Server: &Server{
-                                               Clients: map[uint16]*ClientConn{
-                                                       uint16(2): {
-                                                               AutoReply: []byte(nil),
-                                                       },
-                                               },
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       return bits
+                                               }(),
                                        },
                                },
                                t: NewTransaction(
-                                       tranSendInstantMsg,
-                                       &[]byte{0, 1},
-                                       NewField(fieldData, []byte("hai")),
-                                       NewField(fieldUserID, []byte{0, 2}),
+                                       TranDelNewsArt,
+                                       &[]byte{0, 0},
                                ),
                        },
                        wantRes: []Transaction{
-                               *NewTransaction(
-                                       tranServerMsg,
-                                       &[]byte{0, 2},
-                                       NewField(fieldData, []byte("hai")),
-                                       NewField(fieldUserName, []byte("User1")),
-                                       NewField(fieldUserID, []byte{0, 1}),
-                                       NewField(fieldOptions, []byte{0, 1}),
-                               ),
+                               {
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      []byte{0, 0},
+                                       ID:        []byte{0, 0, 0, 0},
+                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       Fields: []Field{
+                                               NewField(FieldError, []byte("You are not allowed to send private messages.")),
+                                       },
+                               },
+                       },
+                       wantErr: assert.Error,
+               },
+               {
+                       name: "when client 1 sends a message to client 2",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       bits.Set(accessSendPrivMsg)
+                                                       return bits
+                                               }(),
+                                       },
+                                       ID:       &[]byte{0, 1},
+                                       UserName: []byte("User1"),
+                                       Server: &Server{
+                                               Clients: map[uint16]*ClientConn{
+                                                       uint16(2): {
+                                                               AutoReply: []byte(nil),
+                                                               Flags:     []byte{0, 0},
+                                                       },
+                                               },
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranSendInstantMsg,
+                                       &[]byte{0, 1},
+                                       NewField(FieldData, []byte("hai")),
+                                       NewField(FieldUserID, []byte{0, 2}),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               *NewTransaction(
+                                       TranServerMsg,
+                                       &[]byte{0, 2},
+                                       NewField(FieldData, []byte("hai")),
+                                       NewField(FieldUserName, []byte("User1")),
+                                       NewField(FieldUserID, []byte{0, 1}),
+                                       NewField(FieldOptions, []byte{0, 1}),
+                               ),
                                {
                                        clientID:  &[]byte{0, 1},
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0x0, 0x6c},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0, 0, 0, 0},
                                        ErrorCode: []byte{0, 0, 0, 0},
                                        Fields:    []Field(nil),
@@ -2194,11 +2493,19 @@ func TestHandleSendInstantMsg(t *testing.T) {
                        name: "when client 2 has autoreply enabled",
                        args: args{
                                cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       bits.Set(accessSendPrivMsg)
+                                                       return bits
+                                               }(),
+                                       },
                                        ID:       &[]byte{0, 1},
                                        UserName: []byte("User1"),
                                        Server: &Server{
                                                Clients: map[uint16]*ClientConn{
                                                        uint16(2): {
+                                                               Flags:     []byte{0, 0},
                                                                ID:        &[]byte{0, 2},
                                                                UserName:  []byte("User2"),
                                                                AutoReply: []byte("autohai"),
@@ -2207,34 +2514,85 @@ func TestHandleSendInstantMsg(t *testing.T) {
                                        },
                                },
                                t: NewTransaction(
-                                       tranSendInstantMsg,
+                                       TranSendInstantMsg,
                                        &[]byte{0, 1},
-                                       NewField(fieldData, []byte("hai")),
-                                       NewField(fieldUserID, []byte{0, 2}),
+                                       NewField(FieldData, []byte("hai")),
+                                       NewField(FieldUserID, []byte{0, 2}),
                                ),
                        },
                        wantRes: []Transaction{
                                *NewTransaction(
-                                       tranServerMsg,
+                                       TranServerMsg,
                                        &[]byte{0, 2},
-                                       NewField(fieldData, []byte("hai")),
-                                       NewField(fieldUserName, []byte("User1")),
-                                       NewField(fieldUserID, []byte{0, 1}),
-                                       NewField(fieldOptions, []byte{0, 1}),
+                                       NewField(FieldData, []byte("hai")),
+                                       NewField(FieldUserName, []byte("User1")),
+                                       NewField(FieldUserID, []byte{0, 1}),
+                                       NewField(FieldOptions, []byte{0, 1}),
+                               ),
+                               *NewTransaction(
+                                       TranServerMsg,
+                                       &[]byte{0, 1},
+                                       NewField(FieldData, []byte("autohai")),
+                                       NewField(FieldUserName, []byte("User2")),
+                                       NewField(FieldUserID, []byte{0, 2}),
+                                       NewField(FieldOptions, []byte{0, 1}),
+                               ),
+                               {
+                                       clientID:  &[]byte{0, 1},
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      []byte{0, 0},
+                                       ID:        []byte{0, 0, 0, 0},
+                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       Fields:    []Field(nil),
+                               },
+                       },
+                       wantErr: assert.NoError,
+               },
+               {
+                       name: "when client 2 has refuse private messages enabled",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       bits.Set(accessSendPrivMsg)
+                                                       return bits
+                                               }(),
+                                       },
+                                       ID:       &[]byte{0, 1},
+                                       UserName: []byte("User1"),
+                                       Server: &Server{
+                                               Clients: map[uint16]*ClientConn{
+                                                       uint16(2): {
+                                                               Flags:    []byte{255, 255},
+                                                               ID:       &[]byte{0, 2},
+                                                               UserName: []byte("User2"),
+                                                       },
+                                               },
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranSendInstantMsg,
+                                       &[]byte{0, 1},
+                                       NewField(FieldData, []byte("hai")),
+                                       NewField(FieldUserID, []byte{0, 2}),
                                ),
+                       },
+                       wantRes: []Transaction{
                                *NewTransaction(
-                                       tranServerMsg,
+                                       TranServerMsg,
                                        &[]byte{0, 1},
-                                       NewField(fieldData, []byte("autohai")),
-                                       NewField(fieldUserName, []byte("User2")),
-                                       NewField(fieldUserID, []byte{0, 2}),
-                                       NewField(fieldOptions, []byte{0, 1}),
+                                       NewField(FieldData, []byte("User2 does not accept private messages.")),
+                                       NewField(FieldUserName, []byte("User2")),
+                                       NewField(FieldUserID, []byte{0, 2}),
+                                       NewField(FieldOptions, []byte{0, 2}),
                                ),
                                {
                                        clientID:  &[]byte{0, 1},
                                        Flags:     0x00,
                                        IsReply:   0x01,
-                                       Type:      []byte{0x0, 0x6c},
+                                       Type:      []byte{0, 0},
                                        ID:        []byte{0, 0, 0, 0},
                                        ErrorCode: []byte{0, 0, 0, 0},
                                        Fields:    []Field(nil),
@@ -2254,3 +2612,1341 @@ func TestHandleSendInstantMsg(t *testing.T) {
                })
        }
 }
+
+func TestHandleDeleteFile(t *testing.T) {
+       type args struct {
+               cc *ClientConn
+               t  *Transaction
+       }
+       tests := []struct {
+               name    string
+               args    args
+               wantRes []Transaction
+               wantErr assert.ErrorAssertionFunc
+       }{
+               {
+                       name: "when user does not have required permission to delete a folder",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       return bits
+                                               }(),
+                                       },
+                                       Server: &Server{
+                                               Config: &Config{
+                                                       FileRoot: func() string {
+                                                               return "/fakeRoot/Files"
+                                                       }(),
+                                               },
+                                               FS: func() *MockFileStore {
+                                                       mfi := &MockFileInfo{}
+                                                       mfi.On("Mode").Return(fs.FileMode(0))
+                                                       mfi.On("Size").Return(int64(100))
+                                                       mfi.On("ModTime").Return(time.Parse(time.Layout, time.Layout))
+                                                       mfi.On("IsDir").Return(false)
+                                                       mfi.On("Name").Return("testfile")
+
+                                                       mfs := &MockFileStore{}
+                                                       mfs.On("Stat", "/fakeRoot/Files/aaa/testfile").Return(mfi, nil)
+                                                       mfs.On("Stat", "/fakeRoot/Files/aaa/.info_testfile").Return(nil, errors.New("err"))
+                                                       mfs.On("Stat", "/fakeRoot/Files/aaa/.rsrc_testfile").Return(nil, errors.New("err"))
+
+                                                       return mfs
+                                               }(),
+                                               Accounts: map[string]*Account{},
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranDeleteFile, &[]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testfile")),
+                                       NewField(FieldFilePath, []byte{
+                                               0x00, 0x01,
+                                               0x00, 0x00,
+                                               0x03,
+                                               0x61, 0x61, 0x61,
+                                       }),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      []byte{0, 0},
+                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
+                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       Fields: []Field{
+                                               NewField(FieldError, []byte("You are not allowed to delete files.")),
+                                       },
+                               },
+                       },
+                       wantErr: assert.NoError,
+               },
+               {
+                       name: "deletes all associated metadata files",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       bits.Set(accessDeleteFile)
+                                                       return bits
+                                               }(),
+                                       },
+                                       Server: &Server{
+                                               Config: &Config{
+                                                       FileRoot: func() string {
+                                                               return "/fakeRoot/Files"
+                                                       }(),
+                                               },
+                                               FS: func() *MockFileStore {
+                                                       mfi := &MockFileInfo{}
+                                                       mfi.On("Mode").Return(fs.FileMode(0))
+                                                       mfi.On("Size").Return(int64(100))
+                                                       mfi.On("ModTime").Return(time.Parse(time.Layout, time.Layout))
+                                                       mfi.On("IsDir").Return(false)
+                                                       mfi.On("Name").Return("testfile")
+
+                                                       mfs := &MockFileStore{}
+                                                       mfs.On("Stat", "/fakeRoot/Files/aaa/testfile").Return(mfi, nil)
+                                                       mfs.On("Stat", "/fakeRoot/Files/aaa/.info_testfile").Return(nil, errors.New("err"))
+                                                       mfs.On("Stat", "/fakeRoot/Files/aaa/.rsrc_testfile").Return(nil, errors.New("err"))
+
+                                                       mfs.On("RemoveAll", "/fakeRoot/Files/aaa/testfile").Return(nil)
+                                                       mfs.On("Remove", "/fakeRoot/Files/aaa/testfile.incomplete").Return(nil)
+                                                       mfs.On("Remove", "/fakeRoot/Files/aaa/.rsrc_testfile").Return(nil)
+                                                       mfs.On("Remove", "/fakeRoot/Files/aaa/.info_testfile").Return(nil)
+
+                                                       return mfs
+                                               }(),
+                                               Accounts: map[string]*Account{},
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranDeleteFile, &[]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testfile")),
+                                       NewField(FieldFilePath, []byte{
+                                               0x00, 0x01,
+                                               0x00, 0x00,
+                                               0x03,
+                                               0x61, 0x61, 0x61,
+                                       }),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      []byte{0, 0},
+                                       ID:        []byte{0x0, 0x0, 0x0, 0x0},
+                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       Fields:    []Field(nil),
+                               },
+                       },
+                       wantErr: assert.NoError,
+               },
+       }
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+                       gotRes, err := HandleDeleteFile(tt.args.cc, tt.args.t)
+                       if !tt.wantErr(t, err, fmt.Sprintf("HandleDeleteFile(%v, %v)", tt.args.cc, tt.args.t)) {
+                               return
+                       }
+
+                       tranAssertEqual(t, tt.wantRes, gotRes)
+
+                       tt.args.cc.Server.FS.(*MockFileStore).AssertExpectations(t)
+               })
+       }
+}
+
+func TestHandleGetFileNameList(t *testing.T) {
+       type args struct {
+               cc *ClientConn
+               t  *Transaction
+       }
+       tests := []struct {
+               name    string
+               args    args
+               wantRes []Transaction
+               wantErr assert.ErrorAssertionFunc
+       }{
+               {
+                       name: "when FieldFilePath is a drop box, but user does not have accessViewDropBoxes ",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       return bits
+                                               }(),
+                                       },
+                                       Server: &Server{
+
+                                               Config: &Config{
+                                                       FileRoot: func() string {
+                                                               path, _ := os.Getwd()
+                                                               return filepath.Join(path, "/test/config/Files/getFileNameListTestDir")
+                                                       }(),
+                                               },
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranGetFileNameList, &[]byte{0, 1},
+                                       NewField(FieldFilePath, []byte{
+                                               0x00, 0x01,
+                                               0x00, 0x00,
+                                               0x08,
+                                               0x64, 0x72, 0x6f, 0x70, 0x20, 0x62, 0x6f, 0x78, // "drop box"
+                                       }),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      []byte{0, 0},
+                                       ID:        []byte{0, 0, 0, 0},
+                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       Fields: []Field{
+                                               NewField(FieldError, []byte("You are not allowed to view drop boxes.")),
+                                       },
+                               },
+                       },
+                       wantErr: assert.NoError,
+               },
+               {
+                       name: "with file root",
+                       args: args{
+                               cc: &ClientConn{
+                                       Server: &Server{
+                                               Config: &Config{
+                                                       FileRoot: func() string {
+                                                               path, _ := os.Getwd()
+                                                               return filepath.Join(path, "/test/config/Files/getFileNameListTestDir")
+                                                       }(),
+                                               },
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranGetFileNameList, &[]byte{0, 1},
+                                       NewField(FieldFilePath, []byte{
+                                               0x00, 0x00,
+                                               0x00, 0x00,
+                                       }),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      []byte{0, 0},
+                                       ID:        []byte{0, 0, 0, 0},
+                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       Fields: []Field{
+                                               NewField(
+                                                       FieldFileNameWithInfo,
+                                                       func() []byte {
+                                                               fnwi := FileNameWithInfo{
+                                                                       fileNameWithInfoHeader: fileNameWithInfoHeader{
+                                                                               Type:       [4]byte{0x54, 0x45, 0x58, 0x54},
+                                                                               Creator:    [4]byte{0x54, 0x54, 0x58, 0x54},
+                                                                               FileSize:   [4]byte{0, 0, 0x04, 0},
+                                                                               RSVD:       [4]byte{},
+                                                                               NameScript: [2]byte{},
+                                                                               NameSize:   [2]byte{0, 0x0b},
+                                                                       },
+                                                                       name: []byte("testfile-1k"),
+                                                               }
+                                                               b, _ := fnwi.MarshalBinary()
+                                                               return b
+                                                       }(),
+                                               ),
+                                       },
+                               },
+                       },
+                       wantErr: assert.NoError,
+               },
+       }
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+                       gotRes, err := HandleGetFileNameList(tt.args.cc, tt.args.t)
+                       if !tt.wantErr(t, err, fmt.Sprintf("HandleGetFileNameList(%v, %v)", tt.args.cc, tt.args.t)) {
+                               return
+                       }
+
+                       tranAssertEqual(t, tt.wantRes, gotRes)
+               })
+       }
+}
+
+func TestHandleGetClientInfoText(t *testing.T) {
+       type args struct {
+               cc *ClientConn
+               t  *Transaction
+       }
+       tests := []struct {
+               name    string
+               args    args
+               wantRes []Transaction
+               wantErr assert.ErrorAssertionFunc
+       }{
+               {
+                       name: "when user does not have required permission",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       return bits
+                                               }(),
+                                       },
+                                       Server: &Server{
+                                               Accounts: map[string]*Account{},
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranGetClientInfoText, &[]byte{0, 1},
+                                       NewField(FieldUserID, []byte{0, 1}),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      []byte{0, 0},
+                                       ID:        []byte{0, 0, 0, 0},
+                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       Fields: []Field{
+                                               NewField(FieldError, []byte("You are not allowed to get client info.")),
+                                       },
+                               },
+                       },
+                       wantErr: assert.NoError,
+               },
+               {
+                       name: "with a valid user",
+                       args: args{
+                               cc: &ClientConn{
+                                       UserName:   []byte("Testy McTest"),
+                                       RemoteAddr: "1.2.3.4:12345",
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       bits.Set(accessGetClientInfo)
+                                                       return bits
+                                               }(),
+                                               Name:  "test",
+                                               Login: "test",
+                                       },
+                                       Server: &Server{
+                                               Accounts: map[string]*Account{},
+                                               Clients: map[uint16]*ClientConn{
+                                                       uint16(1): {
+                                                               UserName:   []byte("Testy McTest"),
+                                                               RemoteAddr: "1.2.3.4:12345",
+                                                               Account: &Account{
+                                                                       Access: func() accessBitmap {
+                                                                               var bits accessBitmap
+                                                                               bits.Set(accessGetClientInfo)
+                                                                               return bits
+                                                                       }(),
+                                                                       Name:  "test",
+                                                                       Login: "test",
+                                                               },
+                                                       },
+                                               },
+                                       },
+                                       transfers: map[int]map[[4]byte]*FileTransfer{
+                                               FileDownload:   {},
+                                               FileUpload:     {},
+                                               FolderDownload: {},
+                                               FolderUpload:   {},
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranGetClientInfoText, &[]byte{0, 1},
+                                       NewField(FieldUserID, []byte{0, 1}),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      []byte{0, 0},
+                                       ID:        []byte{0, 0, 0, 0},
+                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       Fields: []Field{
+                                               NewField(FieldData, []byte(
+                                                       strings.ReplaceAll(`Nickname:   Testy McTest
+Name:       test
+Account:    test
+Address:    1.2.3.4:12345
+
+-------- File Downloads ---------
+
+None.
+
+------- Folder Downloads --------
+
+None.
+
+--------- File Uploads ----------
+
+None.
+
+-------- Folder Uploads ---------
+
+None.
+
+------- Waiting Downloads -------
+
+None.
+
+`, "\n", "\r")),
+                                               ),
+                                               NewField(FieldUserName, []byte("Testy McTest")),
+                                       },
+                               },
+                       },
+                       wantErr: assert.NoError,
+               },
+       }
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+                       gotRes, err := HandleGetClientInfoText(tt.args.cc, tt.args.t)
+                       if !tt.wantErr(t, err, fmt.Sprintf("HandleGetClientInfoText(%v, %v)", tt.args.cc, tt.args.t)) {
+                               return
+                       }
+                       tranAssertEqual(t, tt.wantRes, gotRes)
+               })
+       }
+}
+
+func TestHandleTranAgreed(t *testing.T) {
+       type args struct {
+               cc *ClientConn
+               t  *Transaction
+       }
+       tests := []struct {
+               name    string
+               args    args
+               wantRes []Transaction
+               wantErr assert.ErrorAssertionFunc
+       }{
+               {
+                       name: "normal request flow",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       bits.Set(accessDisconUser)
+                                                       bits.Set(accessAnyName)
+                                                       return bits
+                                               }()},
+                                       Icon:    []byte{0, 1},
+                                       Flags:   []byte{0, 1},
+                                       Version: []byte{0, 1},
+                                       ID:      &[]byte{0, 1},
+                                       logger:  NewTestLogger(),
+                                       Server: &Server{
+                                               Config: &Config{
+                                                       BannerFile: "banner.jpg",
+                                               },
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranAgreed, nil,
+                                       NewField(FieldUserName, []byte("username")),
+                                       NewField(FieldUserIconID, []byte{0, 1}),
+                                       NewField(FieldOptions, []byte{0, 0}),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       clientID:  &[]byte{0, 1},
+                                       Flags:     0x00,
+                                       IsReply:   0x00,
+                                       Type:      []byte{0, 0x7a},
+                                       ID:        []byte{0, 0, 0, 0},
+                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       Fields: []Field{
+                                               NewField(FieldBannerType, []byte("JPEG")),
+                                       },
+                               },
+                               {
+                                       clientID:  &[]byte{0, 1},
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      []byte{0, 0},
+                                       ID:        []byte{0, 0, 0, 0},
+                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       Fields:    []Field{},
+                               },
+                       },
+                       wantErr: assert.NoError,
+               },
+       }
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+                       gotRes, err := HandleTranAgreed(tt.args.cc, tt.args.t)
+                       if !tt.wantErr(t, err, fmt.Sprintf("HandleTranAgreed(%v, %v)", tt.args.cc, tt.args.t)) {
+                               return
+                       }
+                       tranAssertEqual(t, tt.wantRes, gotRes)
+               })
+       }
+}
+
+func TestHandleSetClientUserInfo(t *testing.T) {
+       type args struct {
+               cc *ClientConn
+               t  *Transaction
+       }
+       tests := []struct {
+               name    string
+               args    args
+               wantRes []Transaction
+               wantErr assert.ErrorAssertionFunc
+       }{
+               {
+                       name: "when client does not have accessAnyName",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       return bits
+                                               }(),
+                                       },
+                                       ID:       &[]byte{0, 1},
+                                       UserName: []byte("Guest"),
+                                       Flags:    []byte{0, 1},
+                                       Server: &Server{
+                                               Clients: map[uint16]*ClientConn{
+                                                       uint16(1): {
+                                                               ID: &[]byte{0, 1},
+                                                       },
+                                               },
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranSetClientUserInfo, nil,
+                                       NewField(FieldUserIconID, []byte{0, 1}),
+                                       NewField(FieldUserName, []byte("NOPE")),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       clientID:  &[]byte{0, 1},
+                                       Flags:     0x00,
+                                       IsReply:   0x00,
+                                       Type:      []byte{0x01, 0x2d},
+                                       ID:        []byte{0, 0, 0, 0},
+                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       Fields: []Field{
+                                               NewField(FieldUserID, []byte{0, 1}),
+                                               NewField(FieldUserIconID, []byte{0, 1}),
+                                               NewField(FieldUserFlags, []byte{0, 1}),
+                                               NewField(FieldUserName, []byte("Guest"))},
+                               },
+                       },
+                       wantErr: assert.NoError,
+               },
+       }
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+                       gotRes, err := HandleSetClientUserInfo(tt.args.cc, tt.args.t)
+                       if !tt.wantErr(t, err, fmt.Sprintf("HandleSetClientUserInfo(%v, %v)", tt.args.cc, tt.args.t)) {
+                               return
+                       }
+
+                       tranAssertEqual(t, tt.wantRes, gotRes)
+               })
+       }
+}
+
+func TestHandleDelNewsItem(t *testing.T) {
+       type args struct {
+               cc *ClientConn
+               t  *Transaction
+       }
+       tests := []struct {
+               name    string
+               args    args
+               wantRes []Transaction
+               wantErr assert.ErrorAssertionFunc
+       }{
+               {
+                       name: "when user does not have permission to delete a news category",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: accessBitmap{},
+                                       },
+                                       ID: &[]byte{0, 1},
+                                       Server: &Server{
+                                               ThreadedNews: &ThreadedNews{Categories: map[string]NewsCategoryListData15{
+                                                       "test": {
+                                                               Type:     []byte{0, 3},
+                                                               Count:    nil,
+                                                               NameSize: 0,
+                                                               Name:     "zz",
+                                                       },
+                                               }},
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranDelNewsItem, nil,
+                                       NewField(FieldNewsPath,
+                                               []byte{
+                                                       0, 1,
+                                                       0, 0,
+                                                       4,
+                                                       0x74, 0x65, 0x73, 0x74,
+                                               },
+                                       ),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       clientID:  &[]byte{0, 1},
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      []byte{0, 0},
+                                       ID:        []byte{0, 0, 0, 0},
+                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       Fields: []Field{
+                                               NewField(FieldError, []byte("You are not allowed to delete news categories.")),
+                                       },
+                               },
+                       },
+                       wantErr: assert.NoError,
+               },
+               {
+                       name: "when user does not have permission to delete a news folder",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: accessBitmap{},
+                                       },
+                                       ID: &[]byte{0, 1},
+                                       Server: &Server{
+                                               ThreadedNews: &ThreadedNews{Categories: map[string]NewsCategoryListData15{
+                                                       "testcat": {
+                                                               Type:     []byte{0, 2},
+                                                               Count:    nil,
+                                                               NameSize: 0,
+                                                               Name:     "test",
+                                                       },
+                                               }},
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranDelNewsItem, nil,
+                                       NewField(FieldNewsPath,
+                                               []byte{
+                                                       0, 1,
+                                                       0, 0,
+                                                       4,
+                                                       0x74, 0x65, 0x73, 0x74,
+                                               },
+                                       ),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       clientID:  &[]byte{0, 1},
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      []byte{0, 0},
+                                       ID:        []byte{0, 0, 0, 0},
+                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       Fields: []Field{
+                                               NewField(FieldError, []byte("You are not allowed to delete news folders.")),
+                                       },
+                               },
+                       },
+                       wantErr: assert.NoError,
+               },
+               {
+                       name: "when user deletes a news folder",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       bits.Set(accessNewsDeleteFldr)
+                                                       return bits
+                                               }(),
+                                       },
+                                       ID: &[]byte{0, 1},
+                                       Server: &Server{
+                                               ConfigDir: "/fakeConfigRoot",
+                                               FS: func() *MockFileStore {
+                                                       mfs := &MockFileStore{}
+                                                       mfs.On("WriteFile", "/fakeConfigRoot/ThreadedNews.yaml", mock.Anything, mock.Anything).Return(nil, os.ErrNotExist)
+                                                       return mfs
+                                               }(),
+                                               ThreadedNews: &ThreadedNews{Categories: map[string]NewsCategoryListData15{
+                                                       "testcat": {
+                                                               Type:     []byte{0, 2},
+                                                               Count:    nil,
+                                                               NameSize: 0,
+                                                               Name:     "test",
+                                                       },
+                                               }},
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranDelNewsItem, nil,
+                                       NewField(FieldNewsPath,
+                                               []byte{
+                                                       0, 1,
+                                                       0, 0,
+                                                       4,
+                                                       0x74, 0x65, 0x73, 0x74,
+                                               },
+                                       ),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       clientID:  &[]byte{0, 1},
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      []byte{0, 0},
+                                       ID:        []byte{0, 0, 0, 0},
+                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       Fields:    []Field{},
+                               },
+                       },
+                       wantErr: assert.NoError,
+               },
+       }
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+                       gotRes, err := HandleDelNewsItem(tt.args.cc, tt.args.t)
+                       if !tt.wantErr(t, err, fmt.Sprintf("HandleDelNewsItem(%v, %v)", tt.args.cc, tt.args.t)) {
+                               return
+                       }
+                       tranAssertEqual(t, tt.wantRes, gotRes)
+               })
+       }
+}
+
+func TestHandleDownloadBanner(t *testing.T) {
+       type args struct {
+               cc *ClientConn
+               t  *Transaction
+       }
+       tests := []struct {
+               name    string
+               args    args
+               wantRes []Transaction
+               wantErr assert.ErrorAssertionFunc
+       }{
+               {
+                       name: "returns expected response",
+                       args: args{
+                               cc: &ClientConn{
+                                       ID: &[]byte{0, 1},
+                                       transfers: map[int]map[[4]byte]*FileTransfer{
+                                               bannerDownload: {},
+                                       },
+                                       Server: &Server{
+                                               ConfigDir: "/config",
+                                               Config: &Config{
+                                                       BannerFile: "banner.jpg",
+                                               },
+                                               fileTransfers: map[[4]byte]*FileTransfer{},
+                                               FS: func() *MockFileStore {
+                                                       mfi := &MockFileInfo{}
+                                                       mfi.On("Size").Return(int64(100))
+
+                                                       mfs := &MockFileStore{}
+                                                       mfs.On("Stat", "/config/banner.jpg").Return(mfi, nil)
+                                                       return mfs
+                                               }(),
+                                       },
+                               },
+                               t: NewTransaction(TranDownloadBanner, nil),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       clientID:  &[]byte{0, 1},
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      []byte{0, 0},
+                                       ID:        []byte{0, 0, 0, 0},
+                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       Fields: []Field{
+                                               NewField(FieldRefNum, []byte{1, 2, 3, 4}),
+                                               NewField(FieldTransferSize, []byte{0, 0, 0, 0x64}),
+                                       },
+                               },
+                       },
+                       wantErr: assert.NoError,
+               },
+       }
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+                       gotRes, err := HandleDownloadBanner(tt.args.cc, tt.args.t)
+                       if !tt.wantErr(t, err, fmt.Sprintf("HandleDownloadBanner(%v, %v)", tt.args.cc, tt.args.t)) {
+                               return
+                       }
+
+                       tranAssertEqual(t, tt.wantRes, gotRes)
+               })
+       }
+}
+
+func TestHandleTranOldPostNews(t *testing.T) {
+       type args struct {
+               cc *ClientConn
+               t  *Transaction
+       }
+       tests := []struct {
+               name    string
+               args    args
+               wantRes []Transaction
+               wantErr assert.ErrorAssertionFunc
+       }{
+               {
+                       name: "when user does not have required permission",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       return bits
+                                               }(),
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranOldPostNews, &[]byte{0, 1},
+                                       NewField(FieldData, []byte("hai")),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      []byte{0, 0},
+                                       ID:        []byte{0, 0, 0, 0},
+                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       Fields: []Field{
+                                               NewField(FieldError, []byte("You are not allowed to post news.")),
+                                       },
+                               },
+                       },
+                       wantErr: assert.NoError,
+               },
+               {
+                       name: "when user posts news update",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       bits.Set(accessNewsPostArt)
+                                                       return bits
+                                               }(),
+                                       },
+                                       Server: &Server{
+                                               FS: func() *MockFileStore {
+                                                       mfs := &MockFileStore{}
+                                                       mfs.On("WriteFile", "/fakeConfigRoot/MessageBoard.txt", mock.Anything, mock.Anything).Return(nil, os.ErrNotExist)
+                                                       return mfs
+                                               }(),
+                                               ConfigDir: "/fakeConfigRoot",
+                                               Config:    &Config{},
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranOldPostNews, &[]byte{0, 1},
+                                       NewField(FieldData, []byte("hai")),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      []byte{0, 0},
+                                       ID:        []byte{0, 0, 0, 0},
+                                       ErrorCode: []byte{0, 0, 0, 0},
+                               },
+                       },
+                       wantErr: assert.NoError,
+               },
+       }
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+                       gotRes, err := HandleTranOldPostNews(tt.args.cc, tt.args.t)
+                       if !tt.wantErr(t, err, fmt.Sprintf("HandleTranOldPostNews(%v, %v)", tt.args.cc, tt.args.t)) {
+                               return
+                       }
+
+                       tranAssertEqual(t, tt.wantRes, gotRes)
+               })
+       }
+}
+
+func TestHandleInviteNewChat(t *testing.T) {
+       type args struct {
+               cc *ClientConn
+               t  *Transaction
+       }
+       tests := []struct {
+               name    string
+               args    args
+               wantRes []Transaction
+               wantErr assert.ErrorAssertionFunc
+       }{
+               {
+                       name: "when user does not have required permission",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       return bits
+                                               }(),
+                                       },
+                               },
+                               t: NewTransaction(TranInviteNewChat, &[]byte{0, 1}),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      []byte{0, 0},
+                                       ID:        []byte{0, 0, 0, 0},
+                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       Fields: []Field{
+                                               NewField(FieldError, []byte("You are not allowed to request private chat.")),
+                                       },
+                               },
+                       },
+                       wantErr: assert.NoError,
+               },
+               {
+                       name: "when userA invites userB to new private chat",
+                       args: args{
+                               cc: &ClientConn{
+                                       ID: &[]byte{0, 1},
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       bits.Set(accessOpenChat)
+                                                       return bits
+                                               }(),
+                                       },
+                                       UserName: []byte("UserA"),
+                                       Icon:     []byte{0, 1},
+                                       Flags:    []byte{0, 0},
+                                       Server: &Server{
+                                               Clients: map[uint16]*ClientConn{
+                                                       uint16(2): {
+                                                               ID:       &[]byte{0, 2},
+                                                               UserName: []byte("UserB"),
+                                                               Flags:    []byte{0, 0},
+                                                       },
+                                               },
+                                               PrivateChats: make(map[uint32]*PrivateChat),
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranInviteNewChat, &[]byte{0, 1},
+                                       NewField(FieldUserID, []byte{0, 2}),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       clientID:  &[]byte{0, 2},
+                                       Flags:     0x00,
+                                       IsReply:   0x00,
+                                       Type:      []byte{0, 0x71},
+                                       ID:        []byte{0, 0, 0, 0},
+                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       Fields: []Field{
+                                               NewField(FieldChatID, []byte{0x52, 0xfd, 0xfc, 0x07}),
+                                               NewField(FieldUserName, []byte("UserA")),
+                                               NewField(FieldUserID, []byte{0, 1}),
+                                       },
+                               },
+
+                               {
+                                       clientID:  &[]byte{0, 1},
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      []byte{0, 0},
+                                       ID:        []byte{0, 0, 0, 0},
+                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       Fields: []Field{
+                                               NewField(FieldChatID, []byte{0x52, 0xfd, 0xfc, 0x07}),
+                                               NewField(FieldUserName, []byte("UserA")),
+                                               NewField(FieldUserID, []byte{0, 1}),
+                                               NewField(FieldUserIconID, []byte{0, 1}),
+                                               NewField(FieldUserFlags, []byte{0, 0}),
+                                       },
+                               },
+                       },
+                       wantErr: assert.NoError,
+               },
+               {
+                       name: "when userA invites userB to new private chat, but UserB has refuse private chat enabled",
+                       args: args{
+                               cc: &ClientConn{
+                                       ID: &[]byte{0, 1},
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       bits.Set(accessOpenChat)
+                                                       return bits
+                                               }(),
+                                       },
+                                       UserName: []byte("UserA"),
+                                       Icon:     []byte{0, 1},
+                                       Flags:    []byte{0, 0},
+                                       Server: &Server{
+                                               Clients: map[uint16]*ClientConn{
+                                                       uint16(2): {
+                                                               ID:       &[]byte{0, 2},
+                                                               UserName: []byte("UserB"),
+                                                               Flags:    []byte{255, 255},
+                                                       },
+                                               },
+                                               PrivateChats: make(map[uint32]*PrivateChat),
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranInviteNewChat, &[]byte{0, 1},
+                                       NewField(FieldUserID, []byte{0, 2}),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       clientID:  &[]byte{0, 1},
+                                       Flags:     0x00,
+                                       IsReply:   0x00,
+                                       Type:      []byte{0, 0x68},
+                                       ID:        []byte{0, 0, 0, 0},
+                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       Fields: []Field{
+                                               NewField(FieldData, []byte("UserB does not accept private chats.")),
+                                               NewField(FieldUserName, []byte("UserB")),
+                                               NewField(FieldUserID, []byte{0, 2}),
+                                               NewField(FieldOptions, []byte{0, 2}),
+                                       },
+                               },
+                               {
+                                       clientID:  &[]byte{0, 1},
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      []byte{0, 0},
+                                       ID:        []byte{0, 0, 0, 0},
+                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       Fields: []Field{
+                                               NewField(FieldChatID, []byte{0x52, 0xfd, 0xfc, 0x07}),
+                                               NewField(FieldUserName, []byte("UserA")),
+                                               NewField(FieldUserID, []byte{0, 1}),
+                                               NewField(FieldUserIconID, []byte{0, 1}),
+                                               NewField(FieldUserFlags, []byte{0, 0}),
+                                       },
+                               },
+                       },
+                       wantErr: assert.NoError,
+               },
+       }
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+                       rand.Seed(1)
+                       gotRes, err := HandleInviteNewChat(tt.args.cc, tt.args.t)
+                       if !tt.wantErr(t, err, fmt.Sprintf("HandleInviteNewChat(%v, %v)", tt.args.cc, tt.args.t)) {
+                               return
+                       }
+                       tranAssertEqual(t, tt.wantRes, gotRes)
+               })
+       }
+}
+
+func TestHandleGetNewsArtData(t *testing.T) {
+       type args struct {
+               cc *ClientConn
+               t  *Transaction
+       }
+       tests := []struct {
+               name    string
+               args    args
+               wantRes []Transaction
+               wantErr assert.ErrorAssertionFunc
+       }{
+               {
+                       name: "when user does not have required permission",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       return bits
+                                               }(),
+                                       },
+                                       Server: &Server{
+                                               Accounts: map[string]*Account{},
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranGetNewsArtData, &[]byte{0, 1},
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      []byte{0, 0},
+                                       ID:        []byte{0x9a, 0xcb, 0x04, 0x42},
+                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       Fields: []Field{
+                                               NewField(FieldError, []byte("You are not allowed to read news.")),
+                                       },
+                               },
+                       },
+                       wantErr: assert.NoError,
+               },
+       }
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+                       gotRes, err := HandleGetNewsArtData(tt.args.cc, tt.args.t)
+                       if !tt.wantErr(t, err, fmt.Sprintf("HandleGetNewsArtData(%v, %v)", tt.args.cc, tt.args.t)) {
+                               return
+                       }
+                       tranAssertEqual(t, tt.wantRes, gotRes)
+               })
+       }
+}
+
+func TestHandleGetNewsArtNameList(t *testing.T) {
+       type args struct {
+               cc *ClientConn
+               t  *Transaction
+       }
+       tests := []struct {
+               name    string
+               args    args
+               wantRes []Transaction
+               wantErr assert.ErrorAssertionFunc
+       }{
+               {
+                       name: "when user does not have required permission",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       return bits
+                                               }(),
+                                       },
+                                       Server: &Server{
+                                               Accounts: map[string]*Account{},
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranGetNewsArtNameList, &[]byte{0, 1},
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      []byte{0, 0},
+                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       Fields: []Field{
+                                               NewField(FieldError, []byte("You are not allowed to read news.")),
+                                       },
+                               },
+                       },
+                       wantErr: assert.NoError,
+               },
+       }
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+                       gotRes, err := HandleGetNewsArtNameList(tt.args.cc, tt.args.t)
+                       if !tt.wantErr(t, err, fmt.Sprintf("HandleGetNewsArtNameList(%v, %v)", tt.args.cc, tt.args.t)) {
+                               return
+                       }
+                       tranAssertEqual(t, tt.wantRes, gotRes)
+               })
+       }
+}
+
+func TestHandleNewNewsFldr(t *testing.T) {
+       type args struct {
+               cc *ClientConn
+               t  *Transaction
+       }
+       tests := []struct {
+               name    string
+               args    args
+               wantRes []Transaction
+               wantErr assert.ErrorAssertionFunc
+       }{
+               {
+                       name: "when user does not have required permission",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       return bits
+                                               }(),
+                                       },
+                                       Server: &Server{
+                                               Accounts: map[string]*Account{},
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranGetNewsArtNameList, &[]byte{0, 1},
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      []byte{0, 0},
+                                       ErrorCode: []byte{0, 0, 0, 1},
+                                       Fields: []Field{
+                                               NewField(FieldError, []byte("You are not allowed to create news folders.")),
+                                       },
+                               },
+                       },
+                       wantErr: assert.NoError,
+               },
+               {
+                       name: "with a valid request",
+                       args: args{
+                               cc: &ClientConn{
+                                       Account: &Account{
+                                               Access: func() accessBitmap {
+                                                       var bits accessBitmap
+                                                       bits.Set(accessNewsCreateFldr)
+                                                       return bits
+                                               }(),
+                                       },
+                                       logger: NewTestLogger(),
+                                       ID:     &[]byte{0, 1},
+                                       Server: &Server{
+                                               ConfigDir: "/fakeConfigRoot",
+                                               FS: func() *MockFileStore {
+                                                       mfs := &MockFileStore{}
+                                                       mfs.On("WriteFile", "/fakeConfigRoot/ThreadedNews.yaml", mock.Anything, mock.Anything).Return(nil)
+                                                       return mfs
+                                               }(),
+                                               ThreadedNews: &ThreadedNews{Categories: map[string]NewsCategoryListData15{
+                                                       "test": {
+                                                               Type:     []byte{0, 2},
+                                                               Count:    nil,
+                                                               NameSize: 0,
+                                                               Name:     "test",
+                                                               SubCats:  make(map[string]NewsCategoryListData15),
+                                                       },
+                                               }},
+                                       },
+                               },
+                               t: NewTransaction(
+                                       TranGetNewsArtNameList, &[]byte{0, 1},
+                                       NewField(FieldFileName, []byte("testFolder")),
+                                       NewField(FieldNewsPath,
+                                               []byte{
+                                                       0, 1,
+                                                       0, 0,
+                                                       4,
+                                                       0x74, 0x65, 0x73, 0x74,
+                                               },
+                                       ),
+                               ),
+                       },
+                       wantRes: []Transaction{
+                               {
+                                       clientID:  &[]byte{0, 1},
+                                       Flags:     0x00,
+                                       IsReply:   0x01,
+                                       Type:      []byte{0, 0},
+                                       ID:        []byte{0, 0, 0, 0},
+                                       ErrorCode: []byte{0, 0, 0, 0},
+                                       Fields:    []Field{},
+                               },
+                       },
+                       wantErr: assert.NoError,
+               },
+               //{
+               //      name: "when there is an error writing the threaded news file",
+               //      args: args{
+               //              cc: &ClientConn{
+               //                      Account: &Account{
+               //                              Access: func() accessBitmap {
+               //                                      var bits accessBitmap
+               //                                      bits.Set(accessNewsCreateFldr)
+               //                                      return bits
+               //                              }(),
+               //                      },
+               //                      logger: NewTestLogger(),
+               //                      ID:     &[]byte{0, 1},
+               //                      Server: &Server{
+               //                              ConfigDir: "/fakeConfigRoot",
+               //                              FS: func() *MockFileStore {
+               //                                      mfs := &MockFileStore{}
+               //                                      mfs.On("WriteFile", "/fakeConfigRoot/ThreadedNews.yaml", mock.Anything, mock.Anything).Return(os.ErrNotExist)
+               //                                      return mfs
+               //                              }(),
+               //                              ThreadedNews: &ThreadedNews{Categories: map[string]NewsCategoryListData15{
+               //                                      "test": {
+               //                                              Type:     []byte{0, 2},
+               //                                              Count:    nil,
+               //                                              NameSize: 0,
+               //                                              Name:     "test",
+               //                                              SubCats:  make(map[string]NewsCategoryListData15),
+               //                                      },
+               //                              }},
+               //                      },
+               //              },
+               //              t: NewTransaction(
+               //                      TranGetNewsArtNameList, &[]byte{0, 1},
+               //                      NewField(FieldFileName, []byte("testFolder")),
+               //                      NewField(FieldNewsPath,
+               //                              []byte{
+               //                                      0, 1,
+               //                                      0, 0,
+               //                                      4,
+               //                                      0x74, 0x65, 0x73, 0x74,
+               //                              },
+               //                      ),
+               //              ),
+               //      },
+               //      wantRes: []Transaction{
+               //              {
+               //                      clientID:  &[]byte{0, 1},
+               //                      Flags:     0x00,
+               //                      IsReply:   0x01,
+               //                      Type:      []byte{0, 0},
+               //                      ErrorCode: []byte{0, 0, 0, 1},
+               //                      Fields: []Field{
+               //                              NewField(FieldError, []byte("Error creating news folder.")),
+               //                      },
+               //              },
+               //      },
+               //      wantErr: assert.Error,
+               // },
+       }
+       for _, tt := range tests {
+               t.Run(tt.name, func(t *testing.T) {
+                       gotRes, err := HandleNewNewsFldr(tt.args.cc, tt.args.t)
+                       if !tt.wantErr(t, err, fmt.Sprintf("HandleNewNewsFldr(%v, %v)", tt.args.cc, tt.args.t)) {
+                               return
+                       }
+                       tranAssertEqual(t, tt.wantRes, gotRes)
+               })
+       }
+}