6 "github.com/stretchr/testify/assert"
15 func TestHandleSetChatSubject(t *testing.T) {
27 name: "sends chat subject to private chat members",
30 UserName: []byte{0x00, 0x01},
32 PrivateChats: map[uint32]*PrivateChat{
35 ClientConn: map[uint16]*ClientConn{
38 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
44 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
51 Clients: map[uint16]*ClientConn{
54 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
60 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
70 Type: []byte{0, 0x6a},
71 ID: []byte{0, 0, 0, 1},
72 ErrorCode: []byte{0, 0, 0, 0},
74 NewField(fieldChatID, []byte{0, 0, 0, 1}),
75 NewField(fieldChatSubject, []byte("Test Subject")),
81 clientID: &[]byte{0, 1},
84 Type: []byte{0, 0x77},
85 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
86 ErrorCode: []byte{0, 0, 0, 0},
88 NewField(fieldChatID, []byte{0, 0, 0, 1}),
89 NewField(fieldChatSubject, []byte("Test Subject")),
93 clientID: &[]byte{0, 2},
96 Type: []byte{0, 0x77},
97 ID: []byte{0xf0, 0xc5, 0x34, 0x1e}, // Random ID from rand.Seed(1)
98 ErrorCode: []byte{0, 0, 0, 0},
100 NewField(fieldChatID, []byte{0, 0, 0, 1}),
101 NewField(fieldChatSubject, []byte("Test Subject")),
108 for _, tt := range tests {
109 rand.Seed(1) // reset seed between tests to make transaction IDs predictable
111 t.Run(tt.name, func(t *testing.T) {
112 got, err := HandleSetChatSubject(tt.args.cc, tt.args.t)
113 if (err != nil) != tt.wantErr {
114 t.Errorf("HandleSetChatSubject() error = %v, wantErr %v", err, tt.wantErr)
117 if !assert.Equal(t, tt.want, got) {
118 t.Errorf("HandleSetChatSubject() got = %v, want %v", got, tt.want)
124 func TestHandleLeaveChat(t *testing.T) {
136 name: "returns expected transactions",
141 PrivateChats: map[uint32]*PrivateChat{
143 ClientConn: map[uint16]*ClientConn{
146 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
152 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
159 Clients: map[uint16]*ClientConn{
162 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
168 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
175 t: NewTransaction(tranDeleteUser, nil, NewField(fieldChatID, []byte{0, 0, 0, 1})),
179 clientID: &[]byte{0, 1},
182 Type: []byte{0, 0x76},
183 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
184 ErrorCode: []byte{0, 0, 0, 0},
186 NewField(fieldChatID, []byte{0, 0, 0, 1}),
187 NewField(fieldUserID, []byte{0, 2}),
194 for _, tt := range tests {
196 t.Run(tt.name, func(t *testing.T) {
197 got, err := HandleLeaveChat(tt.args.cc, tt.args.t)
198 if (err != nil) != tt.wantErr {
199 t.Errorf("HandleLeaveChat() error = %v, wantErr %v", err, tt.wantErr)
202 if !assert.Equal(t, tt.want, got) {
203 t.Errorf("HandleLeaveChat() got = %v, want %v", got, tt.want)
209 func TestHandleGetUserNameList(t *testing.T) {
221 name: "replies with userlist transaction",
227 Clients: map[uint16]*ClientConn{
231 Flags: &[]byte{0, 3},
232 UserName: []byte{0, 4},
238 Flags: &[]byte{0, 3},
239 UserName: []byte{0, 4},
245 Flags: &[]byte{0, 3},
246 UserName: []byte{0, 4},
253 ID: []byte{0, 0, 0, 1},
259 clientID: &[]byte{1, 1},
263 ID: []byte{0, 0, 0, 1},
264 ErrorCode: []byte{0, 0, 0, 0},
267 fieldUsernameWithInfo,
268 []byte{00, 01, 00, 02, 00, 03, 00, 02, 00, 04},
271 fieldUsernameWithInfo,
272 []byte{00, 02, 00, 02, 00, 03, 00, 02, 00, 04},
280 for _, tt := range tests {
281 t.Run(tt.name, func(t *testing.T) {
282 got, err := HandleGetUserNameList(tt.args.cc, tt.args.t)
283 if (err != nil) != tt.wantErr {
284 t.Errorf("HandleGetUserNameList() error = %v, wantErr %v", err, tt.wantErr)
287 assert.Equal(t, tt.want, got)
292 func TestHandleChatSend(t *testing.T) {
304 name: "sends chat msg transaction to all clients",
308 Access: func() *[]byte {
309 var bits accessBitmap
310 bits.Set(accessSendChat)
315 UserName: []byte{0x00, 0x01},
317 Clients: map[uint16]*ClientConn{
320 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
326 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
335 NewField(fieldData, []byte("hai")),
341 clientID: &[]byte{0, 1},
344 Type: []byte{0, 0x6a},
345 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
346 ErrorCode: []byte{0, 0, 0, 0},
348 NewField(fieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
352 clientID: &[]byte{0, 2},
355 Type: []byte{0, 0x6a},
356 ID: []byte{0xf0, 0xc5, 0x34, 0x1e}, // Random ID from rand.Seed(1)
357 ErrorCode: []byte{0, 0, 0, 0},
359 NewField(fieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
366 name: "when user does not have required permission",
370 Access: func() *[]byte {
371 var bits accessBitmap
377 Accounts: map[string]*Account{},
381 tranChatSend, &[]byte{0, 1},
382 NewField(fieldData, []byte("hai")),
389 Type: []byte{0, 0x00},
390 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
391 ErrorCode: []byte{0, 0, 0, 1},
393 NewField(fieldError, []byte("You are not allowed to participate in chat.")),
400 name: "sends chat msg as emote if fieldChatOptions is set",
404 Access: func() *[]byte {
405 var bits accessBitmap
406 bits.Set(accessSendChat)
411 UserName: []byte("Testy McTest"),
413 Clients: map[uint16]*ClientConn{
416 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
422 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
431 NewField(fieldData, []byte("performed action")),
432 NewField(fieldChatOptions, []byte{0x00, 0x01}),
438 clientID: &[]byte{0, 1},
441 Type: []byte{0, 0x6a},
442 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
443 ErrorCode: []byte{0, 0, 0, 0},
445 NewField(fieldData, []byte("\r*** Testy McTest performed action")),
449 clientID: &[]byte{0, 2},
452 Type: []byte{0, 0x6a},
453 ID: []byte{0xf0, 0xc5, 0x34, 0x1e},
454 ErrorCode: []byte{0, 0, 0, 0},
456 NewField(fieldData, []byte("\r*** Testy McTest performed action")),
463 name: "only sends chat msg to clients with accessReadChat permission",
467 Access: func() *[]byte {
468 var bits accessBitmap
469 bits.Set(accessSendChat)
474 UserName: []byte{0x00, 0x01},
476 Clients: map[uint16]*ClientConn{
479 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
485 Access: &[]byte{0, 0, 0, 0, 0, 0, 0, 0},
494 NewField(fieldData, []byte("hai")),
500 clientID: &[]byte{0, 1},
503 Type: []byte{0, 0x6a},
504 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
505 ErrorCode: []byte{0, 0, 0, 0},
507 NewField(fieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
514 name: "only sends private chat msg to members of private chat",
518 Access: func() *[]byte {
519 var bits accessBitmap
520 bits.Set(accessSendChat)
525 UserName: []byte{0x00, 0x01},
527 PrivateChats: map[uint32]*PrivateChat{
529 ClientConn: map[uint16]*ClientConn{
539 Clients: map[uint16]*ClientConn{
542 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
548 Access: &[]byte{0, 0, 0, 0, 0, 0, 0, 0},
554 Access: &[]byte{0, 0, 0, 0, 0, 0, 0, 0},
563 NewField(fieldData, []byte("hai")),
564 NewField(fieldChatID, []byte{0, 0, 0, 1}),
570 clientID: &[]byte{0, 1},
573 Type: []byte{0, 0x6a},
574 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
575 ErrorCode: []byte{0, 0, 0, 0},
577 NewField(fieldChatID, []byte{0, 0, 0, 1}),
578 NewField(fieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
582 clientID: &[]byte{0, 2},
585 Type: []byte{0, 0x6a},
586 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
587 ErrorCode: []byte{0, 0, 0, 0},
589 NewField(fieldChatID, []byte{0, 0, 0, 1}),
590 NewField(fieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
597 for _, tt := range tests {
598 t.Run(tt.name, func(t *testing.T) {
599 got, err := HandleChatSend(tt.args.cc, tt.args.t)
601 if (err != nil) != tt.wantErr {
602 t.Errorf("HandleChatSend() error = %v, wantErr %v", err, tt.wantErr)
605 tranAssertEqual(t, tt.want, got)
610 func TestHandleGetFileInfo(t *testing.T) {
611 rand.Seed(1) // reset seed between tests to make transaction IDs predictable
620 wantRes []Transaction
624 name: "returns expected fields when a valid file is requested",
627 ID: &[]byte{0x00, 0x01},
631 FileRoot: func() string {
632 path, _ := os.Getwd()
633 return path + "/test/config/Files"
639 tranGetFileInfo, nil,
640 NewField(fieldFileName, []byte("testfile.txt")),
641 NewField(fieldFilePath, []byte{0x00, 0x00}),
644 wantRes: []Transaction{
646 clientID: &[]byte{0, 1},
649 Type: []byte{0, 0xce},
650 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
651 ErrorCode: []byte{0, 0, 0, 0},
653 NewField(fieldFileName, []byte("testfile.txt")),
654 NewField(fieldFileTypeString, []byte("Text File")),
655 NewField(fieldFileCreatorString, []byte("ttxt")),
656 NewField(fieldFileComment, []byte{}),
657 NewField(fieldFileType, []byte("TEXT")),
658 NewField(fieldFileCreateDate, make([]byte, 8)),
659 NewField(fieldFileModifyDate, make([]byte, 8)),
660 NewField(fieldFileSize, []byte{0x0, 0x0, 0x0, 0x17}),
667 for _, tt := range tests {
668 t.Run(tt.name, func(t *testing.T) {
669 rand.Seed(1) // reset seed between tests to make transaction IDs predictable
671 gotRes, err := HandleGetFileInfo(tt.args.cc, tt.args.t)
672 if (err != nil) != tt.wantErr {
673 t.Errorf("HandleGetFileInfo() error = %v, wantErr %v", err, tt.wantErr)
677 // Clear the fileWrapper timestamp fields to work around problems running the tests in multiple timezones
678 // TODO: revisit how to test this by mocking the stat calls
679 gotRes[0].Fields[5].Data = make([]byte, 8)
680 gotRes[0].Fields[6].Data = make([]byte, 8)
681 if !assert.Equal(t, tt.wantRes, gotRes) {
682 t.Errorf("HandleGetFileInfo() gotRes = %v, want %v", gotRes, tt.wantRes)
688 func TestHandleNewFolder(t *testing.T) {
696 wantRes []Transaction
700 name: "without required permission",
704 Access: func() *[]byte {
705 var bits accessBitmap
716 wantRes: []Transaction{
720 Type: []byte{0, 0x00},
721 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
722 ErrorCode: []byte{0, 0, 0, 1},
724 NewField(fieldError, []byte("You are not allowed to create folders.")),
731 name: "when path is nested",
735 Access: func() *[]byte {
736 var bits accessBitmap
737 bits.Set(accessCreateFolder)
747 FS: func() *MockFileStore {
748 mfs := &MockFileStore{}
749 mfs.On("Mkdir", "/Files/aaa/testFolder", fs.FileMode(0777)).Return(nil)
750 mfs.On("Stat", "/Files/aaa/testFolder").Return(nil, os.ErrNotExist)
756 tranNewFolder, &[]byte{0, 1},
757 NewField(fieldFileName, []byte("testFolder")),
758 NewField(fieldFilePath, []byte{
766 wantRes: []Transaction{
768 clientID: &[]byte{0, 1},
771 Type: []byte{0, 0xcd},
772 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
773 ErrorCode: []byte{0, 0, 0, 0},
779 name: "when path is not nested",
783 Access: func() *[]byte {
784 var bits accessBitmap
785 bits.Set(accessCreateFolder)
795 FS: func() *MockFileStore {
796 mfs := &MockFileStore{}
797 mfs.On("Mkdir", "/Files/testFolder", fs.FileMode(0777)).Return(nil)
798 mfs.On("Stat", "/Files/testFolder").Return(nil, os.ErrNotExist)
804 tranNewFolder, &[]byte{0, 1},
805 NewField(fieldFileName, []byte("testFolder")),
808 wantRes: []Transaction{
810 clientID: &[]byte{0, 1},
813 Type: []byte{0, 0xcd},
814 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
815 ErrorCode: []byte{0, 0, 0, 0},
821 name: "when UnmarshalBinary returns an err",
825 Access: func() *[]byte {
826 var bits accessBitmap
827 bits.Set(accessCreateFolder)
837 FS: func() *MockFileStore {
838 mfs := &MockFileStore{}
839 mfs.On("Mkdir", "/Files/aaa/testFolder", fs.FileMode(0777)).Return(nil)
840 mfs.On("Stat", "/Files/aaa/testFolder").Return(nil, os.ErrNotExist)
846 tranNewFolder, &[]byte{0, 1},
847 NewField(fieldFileName, []byte("testFolder")),
848 NewField(fieldFilePath, []byte{
853 wantRes: []Transaction{},
857 name: "fieldFileName does not allow directory traversal",
861 Access: func() *[]byte {
862 var bits accessBitmap
863 bits.Set(accessCreateFolder)
873 FS: func() *MockFileStore {
874 mfs := &MockFileStore{}
875 mfs.On("Mkdir", "/Files/testFolder", fs.FileMode(0777)).Return(nil)
876 mfs.On("Stat", "/Files/testFolder").Return(nil, os.ErrNotExist)
882 tranNewFolder, &[]byte{0, 1},
883 NewField(fieldFileName, []byte("../../testFolder")),
886 wantRes: []Transaction{
888 clientID: &[]byte{0, 1},
891 Type: []byte{0, 0xcd},
892 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
893 ErrorCode: []byte{0, 0, 0, 0},
898 name: "fieldFilePath does not allow directory traversal",
902 Access: func() *[]byte {
903 var bits accessBitmap
904 bits.Set(accessCreateFolder)
914 FS: func() *MockFileStore {
915 mfs := &MockFileStore{}
916 mfs.On("Mkdir", "/Files/foo/testFolder", fs.FileMode(0777)).Return(nil)
917 mfs.On("Stat", "/Files/foo/testFolder").Return(nil, os.ErrNotExist)
923 tranNewFolder, &[]byte{0, 1},
924 NewField(fieldFileName, []byte("testFolder")),
925 NewField(fieldFilePath, []byte{
936 wantRes: []Transaction{
938 clientID: &[]byte{0, 1},
941 Type: []byte{0, 0xcd},
942 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
943 ErrorCode: []byte{0, 0, 0, 0},
948 for _, tt := range tests {
949 t.Run(tt.name, func(t *testing.T) {
951 gotRes, err := HandleNewFolder(tt.args.cc, tt.args.t)
952 if (err != nil) != tt.wantErr {
953 t.Errorf("HandleNewFolder() error = %v, wantErr %v", err, tt.wantErr)
957 if !tranAssertEqual(t, tt.wantRes, gotRes) {
958 t.Errorf("HandleNewFolder() gotRes = %v, want %v", gotRes, tt.wantRes)
964 func TestHandleUploadFile(t *testing.T) {
972 wantRes []Transaction
976 name: "when request is valid and user has Upload Anywhere permission",
980 FileTransfers: map[uint32]*FileTransfer{},
983 Access: func() *[]byte {
984 var bits accessBitmap
985 bits.Set(accessUploadFile)
986 bits.Set(accessUploadAnywhere)
993 tranUploadFile, &[]byte{0, 1},
994 NewField(fieldFileName, []byte("testFile")),
995 NewField(fieldFilePath, []byte{
1003 wantRes: []Transaction{
1007 Type: []byte{0, 0xcb},
1008 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1009 ErrorCode: []byte{0, 0, 0, 0},
1011 NewField(fieldRefNum, []byte{0x52, 0xfd, 0xfc, 0x07}), // rand.Seed(1)
1018 name: "when user does not have required access",
1022 Access: func() *[]byte {
1023 var bits accessBitmap
1029 FileTransfers: map[uint32]*FileTransfer{},
1033 tranUploadFile, &[]byte{0, 1},
1034 NewField(fieldFileName, []byte("testFile")),
1035 NewField(fieldFilePath, []byte{
1043 wantRes: []Transaction{
1047 Type: []byte{0, 0x00},
1048 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1049 ErrorCode: []byte{0, 0, 0, 1},
1051 NewField(fieldError, []byte("You are not allowed to upload files.")), // rand.Seed(1)
1058 for _, tt := range tests {
1059 t.Run(tt.name, func(t *testing.T) {
1061 gotRes, err := HandleUploadFile(tt.args.cc, tt.args.t)
1062 if (err != nil) != tt.wantErr {
1063 t.Errorf("HandleUploadFile() error = %v, wantErr %v", err, tt.wantErr)
1067 tranAssertEqual(t, tt.wantRes, gotRes)
1073 func TestHandleMakeAlias(t *testing.T) {
1081 wantRes []Transaction
1085 name: "with valid input and required permissions",
1089 Access: func() *[]byte {
1090 var bits accessBitmap
1091 bits.Set(accessMakeAlias)
1098 FileRoot: func() string {
1099 path, _ := os.Getwd()
1100 return path + "/test/config/Files"
1103 Logger: NewTestLogger(),
1104 FS: func() *MockFileStore {
1105 mfs := &MockFileStore{}
1106 path, _ := os.Getwd()
1109 path+"/test/config/Files/foo/testFile",
1110 path+"/test/config/Files/bar/testFile",
1117 tranMakeFileAlias, &[]byte{0, 1},
1118 NewField(fieldFileName, []byte("testFile")),
1119 NewField(fieldFilePath, EncodeFilePath(strings.Join([]string{"foo"}, "/"))),
1120 NewField(fieldFileNewPath, EncodeFilePath(strings.Join([]string{"bar"}, "/"))),
1123 wantRes: []Transaction{
1127 Type: []byte{0, 0xd1},
1128 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1129 ErrorCode: []byte{0, 0, 0, 0},
1130 Fields: []Field(nil),
1136 name: "when symlink returns an error",
1140 Access: func() *[]byte {
1141 var bits accessBitmap
1142 bits.Set(accessMakeAlias)
1149 FileRoot: func() string {
1150 path, _ := os.Getwd()
1151 return path + "/test/config/Files"
1154 Logger: NewTestLogger(),
1155 FS: func() *MockFileStore {
1156 mfs := &MockFileStore{}
1157 path, _ := os.Getwd()
1160 path+"/test/config/Files/foo/testFile",
1161 path+"/test/config/Files/bar/testFile",
1162 ).Return(errors.New("ohno"))
1168 tranMakeFileAlias, &[]byte{0, 1},
1169 NewField(fieldFileName, []byte("testFile")),
1170 NewField(fieldFilePath, EncodeFilePath(strings.Join([]string{"foo"}, "/"))),
1171 NewField(fieldFileNewPath, EncodeFilePath(strings.Join([]string{"bar"}, "/"))),
1174 wantRes: []Transaction{
1178 Type: []byte{0, 0x00},
1179 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1180 ErrorCode: []byte{0, 0, 0, 1},
1182 NewField(fieldError, []byte("Error creating alias")),
1189 name: "when user does not have required permission",
1193 Access: func() *[]byte {
1194 var bits accessBitmap
1201 FileRoot: func() string {
1202 path, _ := os.Getwd()
1203 return path + "/test/config/Files"
1209 tranMakeFileAlias, &[]byte{0, 1},
1210 NewField(fieldFileName, []byte("testFile")),
1211 NewField(fieldFilePath, []byte{
1217 NewField(fieldFileNewPath, []byte{
1225 wantRes: []Transaction{
1229 Type: []byte{0, 0x00},
1230 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1231 ErrorCode: []byte{0, 0, 0, 1},
1233 NewField(fieldError, []byte("You are not allowed to make aliases.")),
1240 for _, tt := range tests {
1241 t.Run(tt.name, func(t *testing.T) {
1242 gotRes, err := HandleMakeAlias(tt.args.cc, tt.args.t)
1243 if (err != nil) != tt.wantErr {
1244 t.Errorf("HandleMakeAlias(%v, %v)", tt.args.cc, tt.args.t)
1248 tranAssertEqual(t, tt.wantRes, gotRes)
1253 func TestHandleGetUser(t *testing.T) {
1261 wantRes []Transaction
1262 wantErr assert.ErrorAssertionFunc
1265 name: "when account is valid",
1269 Access: func() *[]byte {
1270 var bits accessBitmap
1271 bits.Set(accessOpenUser)
1277 Accounts: map[string]*Account{
1281 Password: "password",
1288 tranGetUser, &[]byte{0, 1},
1289 NewField(fieldUserLogin, []byte("guest")),
1292 wantRes: []Transaction{
1296 Type: []byte{0x01, 0x60},
1297 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1298 ErrorCode: []byte{0, 0, 0, 0},
1300 NewField(fieldUserName, []byte("Guest")),
1301 NewField(fieldUserLogin, negateString([]byte("guest"))),
1302 NewField(fieldUserPassword, []byte("password")),
1303 NewField(fieldUserAccess, []byte{1}),
1307 wantErr: assert.NoError,
1310 name: "when user does not have required permission",
1314 Access: func() *[]byte {
1315 var bits accessBitmap
1321 Accounts: map[string]*Account{},
1325 tranGetUser, &[]byte{0, 1},
1326 NewField(fieldUserLogin, []byte("nonExistentUser")),
1329 wantRes: []Transaction{
1333 Type: []byte{0, 0x00},
1334 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1335 ErrorCode: []byte{0, 0, 0, 1},
1337 NewField(fieldError, []byte("You are not allowed to view accounts.")),
1341 wantErr: assert.NoError,
1344 name: "when account does not exist",
1348 Access: func() *[]byte {
1349 var bits accessBitmap
1350 bits.Set(accessOpenUser)
1356 Accounts: map[string]*Account{},
1360 tranGetUser, &[]byte{0, 1},
1361 NewField(fieldUserLogin, []byte("nonExistentUser")),
1364 wantRes: []Transaction{
1368 Type: []byte{0, 0x00},
1369 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1370 ErrorCode: []byte{0, 0, 0, 1},
1372 NewField(fieldError, []byte("Account does not exist.")),
1376 wantErr: assert.NoError,
1379 for _, tt := range tests {
1380 t.Run(tt.name, func(t *testing.T) {
1381 gotRes, err := HandleGetUser(tt.args.cc, tt.args.t)
1382 if !tt.wantErr(t, err, fmt.Sprintf("HandleGetUser(%v, %v)", tt.args.cc, tt.args.t)) {
1386 tranAssertEqual(t, tt.wantRes, gotRes)
1391 func TestHandleDeleteUser(t *testing.T) {
1399 wantRes []Transaction
1400 wantErr assert.ErrorAssertionFunc
1403 name: "when user dataFile",
1407 Access: func() *[]byte {
1408 var bits accessBitmap
1409 bits.Set(accessDeleteUser)
1415 Accounts: map[string]*Account{
1418 Name: "Testy McTest",
1419 Password: "password",
1423 FS: func() *MockFileStore {
1424 mfs := &MockFileStore{}
1425 mfs.On("Remove", "Users/testuser.yaml").Return(nil)
1431 tranDeleteUser, &[]byte{0, 1},
1432 NewField(fieldUserLogin, negateString([]byte("testuser"))),
1435 wantRes: []Transaction{
1439 Type: []byte{0x1, 0x5f},
1440 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1441 ErrorCode: []byte{0, 0, 0, 0},
1442 Fields: []Field(nil),
1445 wantErr: assert.NoError,
1448 name: "when user does not have required permission",
1452 Access: func() *[]byte {
1453 var bits accessBitmap
1459 Accounts: map[string]*Account{},
1463 tranDeleteUser, &[]byte{0, 1},
1464 NewField(fieldUserLogin, negateString([]byte("testuser"))),
1467 wantRes: []Transaction{
1471 Type: []byte{0, 0x00},
1472 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1473 ErrorCode: []byte{0, 0, 0, 1},
1475 NewField(fieldError, []byte("You are not allowed to delete accounts.")),
1479 wantErr: assert.NoError,
1482 for _, tt := range tests {
1483 t.Run(tt.name, func(t *testing.T) {
1484 gotRes, err := HandleDeleteUser(tt.args.cc, tt.args.t)
1485 if !tt.wantErr(t, err, fmt.Sprintf("HandleDeleteUser(%v, %v)", tt.args.cc, tt.args.t)) {
1489 tranAssertEqual(t, tt.wantRes, gotRes)
1494 func TestHandleGetMsgs(t *testing.T) {
1502 wantRes []Transaction
1503 wantErr assert.ErrorAssertionFunc
1506 name: "returns news data",
1510 Access: func() *[]byte {
1511 var bits accessBitmap
1512 bits.Set(accessNewsReadArt)
1518 FlatNews: []byte("TEST"),
1522 tranGetMsgs, &[]byte{0, 1},
1525 wantRes: []Transaction{
1529 Type: []byte{0, 0x65},
1530 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1531 ErrorCode: []byte{0, 0, 0, 0},
1533 NewField(fieldData, []byte("TEST")),
1537 wantErr: assert.NoError,
1540 name: "when user does not have required permission",
1544 Access: func() *[]byte {
1545 var bits accessBitmap
1551 Accounts: map[string]*Account{},
1555 tranGetMsgs, &[]byte{0, 1},
1558 wantRes: []Transaction{
1562 Type: []byte{0, 0x00},
1563 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1564 ErrorCode: []byte{0, 0, 0, 1},
1566 NewField(fieldError, []byte("You are not allowed to read news.")),
1570 wantErr: assert.NoError,
1573 for _, tt := range tests {
1574 t.Run(tt.name, func(t *testing.T) {
1575 gotRes, err := HandleGetMsgs(tt.args.cc, tt.args.t)
1576 if !tt.wantErr(t, err, fmt.Sprintf("HandleGetMsgs(%v, %v)", tt.args.cc, tt.args.t)) {
1580 tranAssertEqual(t, tt.wantRes, gotRes)
1585 func TestHandleNewUser(t *testing.T) {
1593 wantRes []Transaction
1594 wantErr assert.ErrorAssertionFunc
1597 name: "when user does not have required permission",
1601 Access: func() *[]byte {
1602 var bits accessBitmap
1608 Accounts: map[string]*Account{},
1612 tranNewUser, &[]byte{0, 1},
1615 wantRes: []Transaction{
1619 Type: []byte{0, 0x00},
1620 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1621 ErrorCode: []byte{0, 0, 0, 1},
1623 NewField(fieldError, []byte("You are not allowed to create new accounts.")),
1627 wantErr: assert.NoError,
1630 for _, tt := range tests {
1631 t.Run(tt.name, func(t *testing.T) {
1632 gotRes, err := HandleNewUser(tt.args.cc, tt.args.t)
1633 if !tt.wantErr(t, err, fmt.Sprintf("HandleNewUser(%v, %v)", tt.args.cc, tt.args.t)) {
1637 tranAssertEqual(t, tt.wantRes, gotRes)
1642 func TestHandleListUsers(t *testing.T) {
1650 wantRes []Transaction
1651 wantErr assert.ErrorAssertionFunc
1654 name: "when user does not have required permission",
1658 Access: func() *[]byte {
1659 var bits accessBitmap
1665 Accounts: map[string]*Account{},
1669 tranNewUser, &[]byte{0, 1},
1672 wantRes: []Transaction{
1676 Type: []byte{0, 0x00},
1677 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1678 ErrorCode: []byte{0, 0, 0, 1},
1680 NewField(fieldError, []byte("You are not allowed to view accounts.")),
1684 wantErr: assert.NoError,
1687 for _, tt := range tests {
1688 t.Run(tt.name, func(t *testing.T) {
1689 gotRes, err := HandleListUsers(tt.args.cc, tt.args.t)
1690 if !tt.wantErr(t, err, fmt.Sprintf("HandleListUsers(%v, %v)", tt.args.cc, tt.args.t)) {
1694 tranAssertEqual(t, tt.wantRes, gotRes)
1699 func TestHandleDownloadFile(t *testing.T) {
1707 wantRes []Transaction
1708 wantErr assert.ErrorAssertionFunc
1711 name: "when user does not have required permission",
1715 Access: func() *[]byte {
1716 var bits accessBitmap
1723 t: NewTransaction(tranDownloadFile, &[]byte{0, 1}),
1725 wantRes: []Transaction{
1729 Type: []byte{0, 0x00},
1730 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1731 ErrorCode: []byte{0, 0, 0, 1},
1733 NewField(fieldError, []byte("You are not allowed to download files.")),
1737 wantErr: assert.NoError,
1740 name: "with a valid file",
1743 Transfers: make(map[int][]*FileTransfer),
1745 Access: func() *[]byte {
1746 var bits accessBitmap
1747 bits.Set(accessDownloadFile)
1754 FileTransfers: make(map[uint32]*FileTransfer),
1756 FileRoot: func() string { path, _ := os.Getwd(); return path + "/test/config/Files" }(),
1758 Accounts: map[string]*Account{},
1764 NewField(fieldFileName, []byte("testfile.txt")),
1765 NewField(fieldFilePath, []byte{0x0, 0x00}),
1768 wantRes: []Transaction{
1772 Type: []byte{0, 0x2},
1773 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1774 ErrorCode: []byte{0, 0, 0, 0},
1776 NewField(fieldRefNum, []byte{0x52, 0xfd, 0xfc, 0x07}),
1777 NewField(fieldWaitingCount, []byte{0x00, 0x00}),
1778 NewField(fieldTransferSize, []byte{0x00, 0x00, 0x00, 0xa5}),
1779 NewField(fieldFileSize, []byte{0x00, 0x00, 0x00, 0x17}),
1783 wantErr: assert.NoError,
1786 name: "when client requests to resume 1k test file at offset 256",
1789 Transfers: make(map[int][]*FileTransfer),
1791 Access: func() *[]byte {
1792 var bits accessBitmap
1793 bits.Set(accessDownloadFile)
1800 // FS: func() *MockFileStore {
1801 // path, _ := os.Getwd()
1802 // testFile, err := os.Open(path + "/test/config/Files/testfile-1k")
1807 // mfi := &MockFileInfo{}
1808 // mfi.On("Mode").Return(fs.FileMode(0))
1809 // mfs := &MockFileStore{}
1810 // mfs.On("Stat", "/fakeRoot/Files/testfile.txt").Return(mfi, nil)
1811 // mfs.On("Open", "/fakeRoot/Files/testfile.txt").Return(testFile, nil)
1812 // mfs.On("Stat", "/fakeRoot/Files/.info_testfile.txt").Return(nil, errors.New("no"))
1813 // mfs.On("Stat", "/fakeRoot/Files/.rsrc_testfile.txt").Return(nil, errors.New("no"))
1817 FileTransfers: make(map[uint32]*FileTransfer),
1819 FileRoot: func() string { path, _ := os.Getwd(); return path + "/test/config/Files" }(),
1821 Accounts: map[string]*Account{},
1827 NewField(fieldFileName, []byte("testfile-1k")),
1828 NewField(fieldFilePath, []byte{0x00, 0x00}),
1830 fieldFileResumeData,
1832 frd := FileResumeData{
1836 ForkCount: [2]byte{0, 2},
1837 ForkInfoList: []ForkInfoList{
1839 Fork: [4]byte{0x44, 0x41, 0x54, 0x41}, // "DATA"
1840 DataSize: [4]byte{0, 0, 0x01, 0x00}, // request offset 256
1845 Fork: [4]byte{0x4d, 0x41, 0x43, 0x52}, // "MACR"
1846 DataSize: [4]byte{0, 0, 0, 0},
1852 b, _ := frd.BinaryMarshal()
1858 wantRes: []Transaction{
1862 Type: []byte{0, 0x2},
1863 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1864 ErrorCode: []byte{0, 0, 0, 0},
1866 NewField(fieldRefNum, []byte{0x52, 0xfd, 0xfc, 0x07}),
1867 NewField(fieldWaitingCount, []byte{0x00, 0x00}),
1868 NewField(fieldTransferSize, []byte{0x00, 0x00, 0x03, 0x8d}),
1869 NewField(fieldFileSize, []byte{0x00, 0x00, 0x03, 0x00}),
1873 wantErr: assert.NoError,
1876 for _, tt := range tests {
1877 t.Run(tt.name, func(t *testing.T) {
1878 gotRes, err := HandleDownloadFile(tt.args.cc, tt.args.t)
1879 if !tt.wantErr(t, err, fmt.Sprintf("HandleDownloadFile(%v, %v)", tt.args.cc, tt.args.t)) {
1883 tranAssertEqual(t, tt.wantRes, gotRes)
1888 func TestHandleUpdateUser(t *testing.T) {
1896 wantRes []Transaction
1897 wantErr assert.ErrorAssertionFunc
1900 name: "when action is create user without required permission",
1904 Logger: NewTestLogger(),
1907 Access: func() *[]byte {
1908 var bits accessBitmap
1917 NewField(fieldData, []byte{
1918 0x00, 0x04, // field count
1920 0x00, 0x69, // fieldUserLogin = 105
1924 0x00, 0x6a, // fieldUserPassword = 106
1928 0x00, 0x66, // fieldUserName = 102
1932 0x00, 0x6e, // fieldUserAccess = 110
1934 0x60, 0x70, 0x0c, 0x20, 0x03, 0x80, 0x00, 0x00,
1938 wantRes: []Transaction{
1942 Type: []byte{0, 0x00},
1943 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1944 ErrorCode: []byte{0, 0, 0, 1},
1946 NewField(fieldError, []byte("You are not allowed to create new accounts.")),
1950 wantErr: assert.NoError,
1953 name: "when action is modify user without required permission",
1957 Logger: NewTestLogger(),
1958 Accounts: map[string]*Account{
1963 Access: func() *[]byte {
1964 var bits accessBitmap
1973 NewField(fieldData, []byte{
1974 0x00, 0x04, // field count
1976 0x00, 0x69, // fieldUserLogin = 105
1980 0x00, 0x6a, // fieldUserPassword = 106
1984 0x00, 0x66, // fieldUserName = 102
1988 0x00, 0x6e, // fieldUserAccess = 110
1990 0x60, 0x70, 0x0c, 0x20, 0x03, 0x80, 0x00, 0x00,
1994 wantRes: []Transaction{
1998 Type: []byte{0, 0x00},
1999 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
2000 ErrorCode: []byte{0, 0, 0, 1},
2002 NewField(fieldError, []byte("You are not allowed to modify accounts.")),
2006 wantErr: assert.NoError,
2009 name: "when action is delete user without required permission",
2013 Logger: NewTestLogger(),
2014 Accounts: map[string]*Account{
2019 Access: func() *[]byte {
2020 var bits accessBitmap
2029 NewField(fieldData, []byte{
2037 wantRes: []Transaction{
2041 Type: []byte{0, 0x00},
2042 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
2043 ErrorCode: []byte{0, 0, 0, 1},
2045 NewField(fieldError, []byte("You are not allowed to delete accounts.")),
2049 wantErr: assert.NoError,
2052 for _, tt := range tests {
2053 t.Run(tt.name, func(t *testing.T) {
2054 gotRes, err := HandleUpdateUser(tt.args.cc, tt.args.t)
2055 if !tt.wantErr(t, err, fmt.Sprintf("HandleUpdateUser(%v, %v)", tt.args.cc, tt.args.t)) {
2059 tranAssertEqual(t, tt.wantRes, gotRes)
2064 func TestHandleDelNewsArt(t *testing.T) {
2072 wantRes []Transaction
2073 wantErr assert.ErrorAssertionFunc
2076 name: "without required permission",
2080 Access: func() *[]byte {
2081 var bits accessBitmap
2092 wantRes: []Transaction{
2096 Type: []byte{0, 0x00},
2097 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
2098 ErrorCode: []byte{0, 0, 0, 1},
2100 NewField(fieldError, []byte("You are not allowed to delete news articles.")),
2104 wantErr: assert.NoError,
2107 for _, tt := range tests {
2108 t.Run(tt.name, func(t *testing.T) {
2109 gotRes, err := HandleDelNewsArt(tt.args.cc, tt.args.t)
2110 if !tt.wantErr(t, err, fmt.Sprintf("HandleDelNewsArt(%v, %v)", tt.args.cc, tt.args.t)) {
2113 tranAssertEqual(t, tt.wantRes, gotRes)
2118 func TestHandleDisconnectUser(t *testing.T) {
2126 wantRes []Transaction
2127 wantErr assert.ErrorAssertionFunc
2130 name: "without required permission",
2134 Access: func() *[]byte {
2135 var bits accessBitmap
2146 wantRes: []Transaction{
2150 Type: []byte{0, 0x00},
2151 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
2152 ErrorCode: []byte{0, 0, 0, 1},
2154 NewField(fieldError, []byte("You are not allowed to disconnect users.")),
2158 wantErr: assert.NoError,
2161 name: "when target user has 'cannot be disconnected' priv",
2165 Clients: map[uint16]*ClientConn{
2169 Access: func() *[]byte {
2170 var bits accessBitmap
2171 bits.Set(accessCannotBeDiscon)
2180 Access: func() *[]byte {
2181 var bits accessBitmap
2182 bits.Set(accessDisconUser)
2191 NewField(fieldUserID, []byte{0, 1}),
2194 wantRes: []Transaction{
2198 Type: []byte{0, 0x00},
2199 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
2200 ErrorCode: []byte{0, 0, 0, 1},
2202 NewField(fieldError, []byte("unnamed is not allowed to be disconnected.")),
2206 wantErr: assert.NoError,
2209 for _, tt := range tests {
2210 t.Run(tt.name, func(t *testing.T) {
2211 gotRes, err := HandleDisconnectUser(tt.args.cc, tt.args.t)
2212 if !tt.wantErr(t, err, fmt.Sprintf("HandleDisconnectUser(%v, %v)", tt.args.cc, tt.args.t)) {
2215 tranAssertEqual(t, tt.wantRes, gotRes)
2220 func TestHandleSendInstantMsg(t *testing.T) {
2228 wantRes []Transaction
2229 wantErr assert.ErrorAssertionFunc
2232 name: "when client 1 sends a message to client 2",
2236 UserName: []byte("User1"),
2238 Clients: map[uint16]*ClientConn{
2240 AutoReply: []byte(nil),
2248 NewField(fieldData, []byte("hai")),
2249 NewField(fieldUserID, []byte{0, 2}),
2252 wantRes: []Transaction{
2256 NewField(fieldData, []byte("hai")),
2257 NewField(fieldUserName, []byte("User1")),
2258 NewField(fieldUserID, []byte{0, 1}),
2259 NewField(fieldOptions, []byte{0, 1}),
2262 clientID: &[]byte{0, 1},
2265 Type: []byte{0x0, 0x6c},
2266 ID: []byte{0, 0, 0, 0},
2267 ErrorCode: []byte{0, 0, 0, 0},
2268 Fields: []Field(nil),
2271 wantErr: assert.NoError,
2274 name: "when client 2 has autoreply enabled",
2278 UserName: []byte("User1"),
2280 Clients: map[uint16]*ClientConn{
2283 UserName: []byte("User2"),
2284 AutoReply: []byte("autohai"),
2292 NewField(fieldData, []byte("hai")),
2293 NewField(fieldUserID, []byte{0, 2}),
2296 wantRes: []Transaction{
2300 NewField(fieldData, []byte("hai")),
2301 NewField(fieldUserName, []byte("User1")),
2302 NewField(fieldUserID, []byte{0, 1}),
2303 NewField(fieldOptions, []byte{0, 1}),
2308 NewField(fieldData, []byte("autohai")),
2309 NewField(fieldUserName, []byte("User2")),
2310 NewField(fieldUserID, []byte{0, 2}),
2311 NewField(fieldOptions, []byte{0, 1}),
2314 clientID: &[]byte{0, 1},
2317 Type: []byte{0x0, 0x6c},
2318 ID: []byte{0, 0, 0, 0},
2319 ErrorCode: []byte{0, 0, 0, 0},
2320 Fields: []Field(nil),
2323 wantErr: assert.NoError,
2326 for _, tt := range tests {
2327 t.Run(tt.name, func(t *testing.T) {
2328 gotRes, err := HandleSendInstantMsg(tt.args.cc, tt.args.t)
2329 if !tt.wantErr(t, err, fmt.Sprintf("HandleSendInstantMsg(%v, %v)", tt.args.cc, tt.args.t)) {
2333 tranAssertEqual(t, tt.wantRes, gotRes)
2338 func TestHandleDeleteFile(t *testing.T) {
2346 wantRes []Transaction
2347 wantErr assert.ErrorAssertionFunc
2350 name: "when user does not have required permission to delete a folder",
2354 Access: func() *[]byte {
2355 var bits accessBitmap
2362 FileRoot: func() string {
2363 return "/fakeRoot/Files"
2366 FS: func() *MockFileStore {
2367 mfi := &MockFileInfo{}
2368 mfi.On("Mode").Return(fs.FileMode(0))
2369 mfi.On("Size").Return(int64(100))
2370 mfi.On("ModTime").Return(time.Parse(time.Layout, time.Layout))
2371 mfi.On("IsDir").Return(false)
2372 mfi.On("Name").Return("testfile")
2374 mfs := &MockFileStore{}
2375 mfs.On("Stat", "/fakeRoot/Files/aaa/testfile").Return(mfi, nil)
2376 mfs.On("Stat", "/fakeRoot/Files/aaa/.info_testfile").Return(nil, errors.New("err"))
2377 mfs.On("Stat", "/fakeRoot/Files/aaa/.rsrc_testfile").Return(nil, errors.New("err"))
2381 Accounts: map[string]*Account{},
2385 tranDeleteFile, &[]byte{0, 1},
2386 NewField(fieldFileName, []byte("testfile")),
2387 NewField(fieldFilePath, []byte{
2395 wantRes: []Transaction{
2399 Type: []byte{0, 0x00},
2400 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
2401 ErrorCode: []byte{0, 0, 0, 1},
2403 NewField(fieldError, []byte("You are not allowed to delete files.")),
2407 wantErr: assert.NoError,
2410 name: "deletes all associated metadata files",
2414 Access: func() *[]byte {
2415 var bits accessBitmap
2416 bits.Set(accessDeleteFile)
2423 FileRoot: func() string {
2424 return "/fakeRoot/Files"
2427 FS: func() *MockFileStore {
2428 mfi := &MockFileInfo{}
2429 mfi.On("Mode").Return(fs.FileMode(0))
2430 mfi.On("Size").Return(int64(100))
2431 mfi.On("ModTime").Return(time.Parse(time.Layout, time.Layout))
2432 mfi.On("IsDir").Return(false)
2433 mfi.On("Name").Return("testfile")
2435 mfs := &MockFileStore{}
2436 mfs.On("Stat", "/fakeRoot/Files/aaa/testfile").Return(mfi, nil)
2437 mfs.On("Stat", "/fakeRoot/Files/aaa/.info_testfile").Return(nil, errors.New("err"))
2438 mfs.On("Stat", "/fakeRoot/Files/aaa/.rsrc_testfile").Return(nil, errors.New("err"))
2440 mfs.On("RemoveAll", "/fakeRoot/Files/aaa/testfile").Return(nil)
2441 mfs.On("Remove", "/fakeRoot/Files/aaa/testfile.incomplete").Return(nil)
2442 mfs.On("Remove", "/fakeRoot/Files/aaa/.rsrc_testfile").Return(nil)
2443 mfs.On("Remove", "/fakeRoot/Files/aaa/.info_testfile").Return(nil)
2447 Accounts: map[string]*Account{},
2451 tranDeleteFile, &[]byte{0, 1},
2452 NewField(fieldFileName, []byte("testfile")),
2453 NewField(fieldFilePath, []byte{
2461 wantRes: []Transaction{
2465 Type: []byte{0x0, 0xcc},
2466 ID: []byte{0x0, 0x0, 0x0, 0x0},
2467 ErrorCode: []byte{0, 0, 0, 0},
2468 Fields: []Field(nil),
2471 wantErr: assert.NoError,
2474 for _, tt := range tests {
2475 t.Run(tt.name, func(t *testing.T) {
2476 gotRes, err := HandleDeleteFile(tt.args.cc, tt.args.t)
2477 if !tt.wantErr(t, err, fmt.Sprintf("HandleDeleteFile(%v, %v)", tt.args.cc, tt.args.t)) {
2481 tranAssertEqual(t, tt.wantRes, gotRes)
2483 tt.args.cc.Server.FS.(*MockFileStore).AssertExpectations(t)