6 "github.com/stretchr/testify/assert"
16 func TestHandleSetChatSubject(t *testing.T) {
28 name: "sends chat subject to private chat members",
31 UserName: []byte{0x00, 0x01},
33 PrivateChats: map[uint32]*PrivateChat{
36 ClientConn: map[uint16]*ClientConn{
39 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
45 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
52 Clients: map[uint16]*ClientConn{
55 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
61 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
71 Type: []byte{0, 0x6a},
72 ID: []byte{0, 0, 0, 1},
73 ErrorCode: []byte{0, 0, 0, 0},
75 NewField(fieldChatID, []byte{0, 0, 0, 1}),
76 NewField(fieldChatSubject, []byte("Test Subject")),
82 clientID: &[]byte{0, 1},
85 Type: []byte{0, 0x77},
86 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
87 ErrorCode: []byte{0, 0, 0, 0},
89 NewField(fieldChatID, []byte{0, 0, 0, 1}),
90 NewField(fieldChatSubject, []byte("Test Subject")),
94 clientID: &[]byte{0, 2},
97 Type: []byte{0, 0x77},
98 ID: []byte{0xf0, 0xc5, 0x34, 0x1e}, // Random ID from rand.Seed(1)
99 ErrorCode: []byte{0, 0, 0, 0},
101 NewField(fieldChatID, []byte{0, 0, 0, 1}),
102 NewField(fieldChatSubject, []byte("Test Subject")),
109 for _, tt := range tests {
110 rand.Seed(1) // reset seed between tests to make transaction IDs predictable
112 t.Run(tt.name, func(t *testing.T) {
113 got, err := HandleSetChatSubject(tt.args.cc, tt.args.t)
114 if (err != nil) != tt.wantErr {
115 t.Errorf("HandleSetChatSubject() error = %v, wantErr %v", err, tt.wantErr)
118 if !assert.Equal(t, tt.want, got) {
119 t.Errorf("HandleSetChatSubject() got = %v, want %v", got, tt.want)
125 func TestHandleLeaveChat(t *testing.T) {
137 name: "returns expected transactions",
142 PrivateChats: map[uint32]*PrivateChat{
144 ClientConn: map[uint16]*ClientConn{
147 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
153 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
160 Clients: map[uint16]*ClientConn{
163 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
169 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
176 t: NewTransaction(tranDeleteUser, nil, NewField(fieldChatID, []byte{0, 0, 0, 1})),
180 clientID: &[]byte{0, 1},
183 Type: []byte{0, 0x76},
184 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
185 ErrorCode: []byte{0, 0, 0, 0},
187 NewField(fieldChatID, []byte{0, 0, 0, 1}),
188 NewField(fieldUserID, []byte{0, 2}),
195 for _, tt := range tests {
197 t.Run(tt.name, func(t *testing.T) {
198 got, err := HandleLeaveChat(tt.args.cc, tt.args.t)
199 if (err != nil) != tt.wantErr {
200 t.Errorf("HandleLeaveChat() error = %v, wantErr %v", err, tt.wantErr)
203 if !assert.Equal(t, tt.want, got) {
204 t.Errorf("HandleLeaveChat() got = %v, want %v", got, tt.want)
210 func TestHandleGetUserNameList(t *testing.T) {
222 name: "replies with userlist transaction",
228 Clients: map[uint16]*ClientConn{
232 Flags: &[]byte{0, 3},
233 UserName: []byte{0, 4},
239 Flags: &[]byte{0, 3},
240 UserName: []byte{0, 4},
246 Flags: &[]byte{0, 3},
247 UserName: []byte{0, 4},
254 ID: []byte{0, 0, 0, 1},
260 clientID: &[]byte{1, 1},
264 ID: []byte{0, 0, 0, 1},
265 ErrorCode: []byte{0, 0, 0, 0},
268 fieldUsernameWithInfo,
269 []byte{00, 01, 00, 02, 00, 03, 00, 02, 00, 04},
272 fieldUsernameWithInfo,
273 []byte{00, 02, 00, 02, 00, 03, 00, 02, 00, 04},
281 for _, tt := range tests {
282 t.Run(tt.name, func(t *testing.T) {
283 got, err := HandleGetUserNameList(tt.args.cc, tt.args.t)
284 if (err != nil) != tt.wantErr {
285 t.Errorf("HandleGetUserNameList() error = %v, wantErr %v", err, tt.wantErr)
288 assert.Equal(t, tt.want, got)
293 func TestHandleChatSend(t *testing.T) {
305 name: "sends chat msg transaction to all clients",
309 Access: func() *[]byte {
310 var bits accessBitmap
311 bits.Set(accessSendChat)
316 UserName: []byte{0x00, 0x01},
318 Clients: map[uint16]*ClientConn{
321 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
327 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
336 NewField(fieldData, []byte("hai")),
342 clientID: &[]byte{0, 1},
345 Type: []byte{0, 0x6a},
346 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
347 ErrorCode: []byte{0, 0, 0, 0},
349 NewField(fieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
353 clientID: &[]byte{0, 2},
356 Type: []byte{0, 0x6a},
357 ID: []byte{0xf0, 0xc5, 0x34, 0x1e}, // Random ID from rand.Seed(1)
358 ErrorCode: []byte{0, 0, 0, 0},
360 NewField(fieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
367 name: "when user does not have required permission",
371 Access: func() *[]byte {
372 var bits accessBitmap
378 Accounts: map[string]*Account{},
382 tranChatSend, &[]byte{0, 1},
383 NewField(fieldData, []byte("hai")),
390 Type: []byte{0, 0x00},
391 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
392 ErrorCode: []byte{0, 0, 0, 1},
394 NewField(fieldError, []byte("You are not allowed to participate in chat.")),
401 name: "sends chat msg as emote if fieldChatOptions is set",
405 Access: func() *[]byte {
406 var bits accessBitmap
407 bits.Set(accessSendChat)
412 UserName: []byte("Testy McTest"),
414 Clients: map[uint16]*ClientConn{
417 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
423 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
432 NewField(fieldData, []byte("performed action")),
433 NewField(fieldChatOptions, []byte{0x00, 0x01}),
439 clientID: &[]byte{0, 1},
442 Type: []byte{0, 0x6a},
443 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
444 ErrorCode: []byte{0, 0, 0, 0},
446 NewField(fieldData, []byte("\r*** Testy McTest performed action")),
450 clientID: &[]byte{0, 2},
453 Type: []byte{0, 0x6a},
454 ID: []byte{0xf0, 0xc5, 0x34, 0x1e},
455 ErrorCode: []byte{0, 0, 0, 0},
457 NewField(fieldData, []byte("\r*** Testy McTest performed action")),
464 name: "only sends chat msg to clients with accessReadChat permission",
468 Access: func() *[]byte {
469 var bits accessBitmap
470 bits.Set(accessSendChat)
475 UserName: []byte{0x00, 0x01},
477 Clients: map[uint16]*ClientConn{
480 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
486 Access: &[]byte{0, 0, 0, 0, 0, 0, 0, 0},
495 NewField(fieldData, []byte("hai")),
501 clientID: &[]byte{0, 1},
504 Type: []byte{0, 0x6a},
505 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
506 ErrorCode: []byte{0, 0, 0, 0},
508 NewField(fieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
515 name: "only sends private chat msg to members of private chat",
519 Access: func() *[]byte {
520 var bits accessBitmap
521 bits.Set(accessSendChat)
526 UserName: []byte{0x00, 0x01},
528 PrivateChats: map[uint32]*PrivateChat{
530 ClientConn: map[uint16]*ClientConn{
540 Clients: map[uint16]*ClientConn{
543 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
549 Access: &[]byte{0, 0, 0, 0, 0, 0, 0, 0},
555 Access: &[]byte{0, 0, 0, 0, 0, 0, 0, 0},
564 NewField(fieldData, []byte("hai")),
565 NewField(fieldChatID, []byte{0, 0, 0, 1}),
571 clientID: &[]byte{0, 1},
574 Type: []byte{0, 0x6a},
575 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
576 ErrorCode: []byte{0, 0, 0, 0},
578 NewField(fieldChatID, []byte{0, 0, 0, 1}),
579 NewField(fieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
583 clientID: &[]byte{0, 2},
586 Type: []byte{0, 0x6a},
587 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
588 ErrorCode: []byte{0, 0, 0, 0},
590 NewField(fieldChatID, []byte{0, 0, 0, 1}),
591 NewField(fieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
598 for _, tt := range tests {
599 t.Run(tt.name, func(t *testing.T) {
600 got, err := HandleChatSend(tt.args.cc, tt.args.t)
602 if (err != nil) != tt.wantErr {
603 t.Errorf("HandleChatSend() error = %v, wantErr %v", err, tt.wantErr)
606 tranAssertEqual(t, tt.want, got)
611 func TestHandleGetFileInfo(t *testing.T) {
612 rand.Seed(1) // reset seed between tests to make transaction IDs predictable
621 wantRes []Transaction
625 name: "returns expected fields when a valid file is requested",
628 ID: &[]byte{0x00, 0x01},
632 FileRoot: func() string {
633 path, _ := os.Getwd()
634 return filepath.Join(path, "/test/config/Files")
640 tranGetFileInfo, nil,
641 NewField(fieldFileName, []byte("testfile.txt")),
642 NewField(fieldFilePath, []byte{0x00, 0x00}),
645 wantRes: []Transaction{
647 clientID: &[]byte{0, 1},
650 Type: []byte{0, 0xce},
651 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
652 ErrorCode: []byte{0, 0, 0, 0},
654 NewField(fieldFileName, []byte("testfile.txt")),
655 NewField(fieldFileTypeString, []byte("Text File")),
656 NewField(fieldFileCreatorString, []byte("ttxt")),
657 NewField(fieldFileComment, []byte{}),
658 NewField(fieldFileType, []byte("TEXT")),
659 NewField(fieldFileCreateDate, make([]byte, 8)),
660 NewField(fieldFileModifyDate, make([]byte, 8)),
661 NewField(fieldFileSize, []byte{0x0, 0x0, 0x0, 0x17}),
668 for _, tt := range tests {
669 t.Run(tt.name, func(t *testing.T) {
670 rand.Seed(1) // reset seed between tests to make transaction IDs predictable
672 gotRes, err := HandleGetFileInfo(tt.args.cc, tt.args.t)
673 if (err != nil) != tt.wantErr {
674 t.Errorf("HandleGetFileInfo() error = %v, wantErr %v", err, tt.wantErr)
678 // Clear the fileWrapper timestamp fields to work around problems running the tests in multiple timezones
679 // TODO: revisit how to test this by mocking the stat calls
680 gotRes[0].Fields[5].Data = make([]byte, 8)
681 gotRes[0].Fields[6].Data = make([]byte, 8)
682 if !assert.Equal(t, tt.wantRes, gotRes) {
683 t.Errorf("HandleGetFileInfo() gotRes = %v, want %v", gotRes, tt.wantRes)
689 func TestHandleNewFolder(t *testing.T) {
697 wantRes []Transaction
701 name: "without required permission",
705 Access: func() *[]byte {
706 var bits accessBitmap
717 wantRes: []Transaction{
721 Type: []byte{0, 0x00},
722 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
723 ErrorCode: []byte{0, 0, 0, 1},
725 NewField(fieldError, []byte("You are not allowed to create folders.")),
732 name: "when path is nested",
736 Access: func() *[]byte {
737 var bits accessBitmap
738 bits.Set(accessCreateFolder)
748 FS: func() *MockFileStore {
749 mfs := &MockFileStore{}
750 mfs.On("Mkdir", "/Files/aaa/testFolder", fs.FileMode(0777)).Return(nil)
751 mfs.On("Stat", "/Files/aaa/testFolder").Return(nil, os.ErrNotExist)
757 tranNewFolder, &[]byte{0, 1},
758 NewField(fieldFileName, []byte("testFolder")),
759 NewField(fieldFilePath, []byte{
767 wantRes: []Transaction{
769 clientID: &[]byte{0, 1},
772 Type: []byte{0, 0xcd},
773 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
774 ErrorCode: []byte{0, 0, 0, 0},
780 name: "when path is not nested",
784 Access: func() *[]byte {
785 var bits accessBitmap
786 bits.Set(accessCreateFolder)
796 FS: func() *MockFileStore {
797 mfs := &MockFileStore{}
798 mfs.On("Mkdir", "/Files/testFolder", fs.FileMode(0777)).Return(nil)
799 mfs.On("Stat", "/Files/testFolder").Return(nil, os.ErrNotExist)
805 tranNewFolder, &[]byte{0, 1},
806 NewField(fieldFileName, []byte("testFolder")),
809 wantRes: []Transaction{
811 clientID: &[]byte{0, 1},
814 Type: []byte{0, 0xcd},
815 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
816 ErrorCode: []byte{0, 0, 0, 0},
822 name: "when UnmarshalBinary returns an err",
826 Access: func() *[]byte {
827 var bits accessBitmap
828 bits.Set(accessCreateFolder)
838 FS: func() *MockFileStore {
839 mfs := &MockFileStore{}
840 mfs.On("Mkdir", "/Files/aaa/testFolder", fs.FileMode(0777)).Return(nil)
841 mfs.On("Stat", "/Files/aaa/testFolder").Return(nil, os.ErrNotExist)
847 tranNewFolder, &[]byte{0, 1},
848 NewField(fieldFileName, []byte("testFolder")),
849 NewField(fieldFilePath, []byte{
854 wantRes: []Transaction{},
858 name: "fieldFileName does not allow directory traversal",
862 Access: func() *[]byte {
863 var bits accessBitmap
864 bits.Set(accessCreateFolder)
874 FS: func() *MockFileStore {
875 mfs := &MockFileStore{}
876 mfs.On("Mkdir", "/Files/testFolder", fs.FileMode(0777)).Return(nil)
877 mfs.On("Stat", "/Files/testFolder").Return(nil, os.ErrNotExist)
883 tranNewFolder, &[]byte{0, 1},
884 NewField(fieldFileName, []byte("../../testFolder")),
887 wantRes: []Transaction{
889 clientID: &[]byte{0, 1},
892 Type: []byte{0, 0xcd},
893 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
894 ErrorCode: []byte{0, 0, 0, 0},
899 name: "fieldFilePath does not allow directory traversal",
903 Access: func() *[]byte {
904 var bits accessBitmap
905 bits.Set(accessCreateFolder)
915 FS: func() *MockFileStore {
916 mfs := &MockFileStore{}
917 mfs.On("Mkdir", "/Files/foo/testFolder", fs.FileMode(0777)).Return(nil)
918 mfs.On("Stat", "/Files/foo/testFolder").Return(nil, os.ErrNotExist)
924 tranNewFolder, &[]byte{0, 1},
925 NewField(fieldFileName, []byte("testFolder")),
926 NewField(fieldFilePath, []byte{
937 wantRes: []Transaction{
939 clientID: &[]byte{0, 1},
942 Type: []byte{0, 0xcd},
943 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
944 ErrorCode: []byte{0, 0, 0, 0},
949 for _, tt := range tests {
950 t.Run(tt.name, func(t *testing.T) {
952 gotRes, err := HandleNewFolder(tt.args.cc, tt.args.t)
953 if (err != nil) != tt.wantErr {
954 t.Errorf("HandleNewFolder() error = %v, wantErr %v", err, tt.wantErr)
958 if !tranAssertEqual(t, tt.wantRes, gotRes) {
959 t.Errorf("HandleNewFolder() gotRes = %v, want %v", gotRes, tt.wantRes)
965 func TestHandleUploadFile(t *testing.T) {
973 wantRes []Transaction
977 name: "when request is valid and user has Upload Anywhere permission",
981 FileTransfers: map[uint32]*FileTransfer{},
984 Access: func() *[]byte {
985 var bits accessBitmap
986 bits.Set(accessUploadFile)
987 bits.Set(accessUploadAnywhere)
994 tranUploadFile, &[]byte{0, 1},
995 NewField(fieldFileName, []byte("testFile")),
996 NewField(fieldFilePath, []byte{
1004 wantRes: []Transaction{
1008 Type: []byte{0, 0xcb},
1009 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1010 ErrorCode: []byte{0, 0, 0, 0},
1012 NewField(fieldRefNum, []byte{0x52, 0xfd, 0xfc, 0x07}), // rand.Seed(1)
1019 name: "when user does not have required access",
1023 Access: func() *[]byte {
1024 var bits accessBitmap
1030 FileTransfers: map[uint32]*FileTransfer{},
1034 tranUploadFile, &[]byte{0, 1},
1035 NewField(fieldFileName, []byte("testFile")),
1036 NewField(fieldFilePath, []byte{
1044 wantRes: []Transaction{
1048 Type: []byte{0, 0x00},
1049 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1050 ErrorCode: []byte{0, 0, 0, 1},
1052 NewField(fieldError, []byte("You are not allowed to upload files.")), // rand.Seed(1)
1059 for _, tt := range tests {
1060 t.Run(tt.name, func(t *testing.T) {
1062 gotRes, err := HandleUploadFile(tt.args.cc, tt.args.t)
1063 if (err != nil) != tt.wantErr {
1064 t.Errorf("HandleUploadFile() error = %v, wantErr %v", err, tt.wantErr)
1068 tranAssertEqual(t, tt.wantRes, gotRes)
1074 func TestHandleMakeAlias(t *testing.T) {
1082 wantRes []Transaction
1086 name: "with valid input and required permissions",
1090 Access: func() *[]byte {
1091 var bits accessBitmap
1092 bits.Set(accessMakeAlias)
1099 FileRoot: func() string {
1100 path, _ := os.Getwd()
1101 return path + "/test/config/Files"
1104 Logger: NewTestLogger(),
1105 FS: func() *MockFileStore {
1106 mfs := &MockFileStore{}
1107 path, _ := os.Getwd()
1110 path+"/test/config/Files/foo/testFile",
1111 path+"/test/config/Files/bar/testFile",
1118 tranMakeFileAlias, &[]byte{0, 1},
1119 NewField(fieldFileName, []byte("testFile")),
1120 NewField(fieldFilePath, EncodeFilePath(strings.Join([]string{"foo"}, "/"))),
1121 NewField(fieldFileNewPath, EncodeFilePath(strings.Join([]string{"bar"}, "/"))),
1124 wantRes: []Transaction{
1128 Type: []byte{0, 0xd1},
1129 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1130 ErrorCode: []byte{0, 0, 0, 0},
1131 Fields: []Field(nil),
1137 name: "when symlink returns an error",
1141 Access: func() *[]byte {
1142 var bits accessBitmap
1143 bits.Set(accessMakeAlias)
1150 FileRoot: func() string {
1151 path, _ := os.Getwd()
1152 return path + "/test/config/Files"
1155 Logger: NewTestLogger(),
1156 FS: func() *MockFileStore {
1157 mfs := &MockFileStore{}
1158 path, _ := os.Getwd()
1161 path+"/test/config/Files/foo/testFile",
1162 path+"/test/config/Files/bar/testFile",
1163 ).Return(errors.New("ohno"))
1169 tranMakeFileAlias, &[]byte{0, 1},
1170 NewField(fieldFileName, []byte("testFile")),
1171 NewField(fieldFilePath, EncodeFilePath(strings.Join([]string{"foo"}, "/"))),
1172 NewField(fieldFileNewPath, EncodeFilePath(strings.Join([]string{"bar"}, "/"))),
1175 wantRes: []Transaction{
1179 Type: []byte{0, 0x00},
1180 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1181 ErrorCode: []byte{0, 0, 0, 1},
1183 NewField(fieldError, []byte("Error creating alias")),
1190 name: "when user does not have required permission",
1194 Access: func() *[]byte {
1195 var bits accessBitmap
1202 FileRoot: func() string {
1203 path, _ := os.Getwd()
1204 return path + "/test/config/Files"
1210 tranMakeFileAlias, &[]byte{0, 1},
1211 NewField(fieldFileName, []byte("testFile")),
1212 NewField(fieldFilePath, []byte{
1218 NewField(fieldFileNewPath, []byte{
1226 wantRes: []Transaction{
1230 Type: []byte{0, 0x00},
1231 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1232 ErrorCode: []byte{0, 0, 0, 1},
1234 NewField(fieldError, []byte("You are not allowed to make aliases.")),
1241 for _, tt := range tests {
1242 t.Run(tt.name, func(t *testing.T) {
1243 gotRes, err := HandleMakeAlias(tt.args.cc, tt.args.t)
1244 if (err != nil) != tt.wantErr {
1245 t.Errorf("HandleMakeAlias(%v, %v)", tt.args.cc, tt.args.t)
1249 tranAssertEqual(t, tt.wantRes, gotRes)
1254 func TestHandleGetUser(t *testing.T) {
1262 wantRes []Transaction
1263 wantErr assert.ErrorAssertionFunc
1266 name: "when account is valid",
1270 Access: func() *[]byte {
1271 var bits accessBitmap
1272 bits.Set(accessOpenUser)
1278 Accounts: map[string]*Account{
1282 Password: "password",
1289 tranGetUser, &[]byte{0, 1},
1290 NewField(fieldUserLogin, []byte("guest")),
1293 wantRes: []Transaction{
1297 Type: []byte{0x01, 0x60},
1298 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1299 ErrorCode: []byte{0, 0, 0, 0},
1301 NewField(fieldUserName, []byte("Guest")),
1302 NewField(fieldUserLogin, negateString([]byte("guest"))),
1303 NewField(fieldUserPassword, []byte("password")),
1304 NewField(fieldUserAccess, []byte{1}),
1308 wantErr: assert.NoError,
1311 name: "when user does not have required permission",
1315 Access: func() *[]byte {
1316 var bits accessBitmap
1322 Accounts: map[string]*Account{},
1326 tranGetUser, &[]byte{0, 1},
1327 NewField(fieldUserLogin, []byte("nonExistentUser")),
1330 wantRes: []Transaction{
1334 Type: []byte{0, 0x00},
1335 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1336 ErrorCode: []byte{0, 0, 0, 1},
1338 NewField(fieldError, []byte("You are not allowed to view accounts.")),
1342 wantErr: assert.NoError,
1345 name: "when account does not exist",
1349 Access: func() *[]byte {
1350 var bits accessBitmap
1351 bits.Set(accessOpenUser)
1357 Accounts: map[string]*Account{},
1361 tranGetUser, &[]byte{0, 1},
1362 NewField(fieldUserLogin, []byte("nonExistentUser")),
1365 wantRes: []Transaction{
1369 Type: []byte{0, 0x00},
1370 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1371 ErrorCode: []byte{0, 0, 0, 1},
1373 NewField(fieldError, []byte("Account does not exist.")),
1377 wantErr: assert.NoError,
1380 for _, tt := range tests {
1381 t.Run(tt.name, func(t *testing.T) {
1382 gotRes, err := HandleGetUser(tt.args.cc, tt.args.t)
1383 if !tt.wantErr(t, err, fmt.Sprintf("HandleGetUser(%v, %v)", tt.args.cc, tt.args.t)) {
1387 tranAssertEqual(t, tt.wantRes, gotRes)
1392 func TestHandleDeleteUser(t *testing.T) {
1400 wantRes []Transaction
1401 wantErr assert.ErrorAssertionFunc
1404 name: "when user dataFile",
1408 Access: func() *[]byte {
1409 var bits accessBitmap
1410 bits.Set(accessDeleteUser)
1416 Accounts: map[string]*Account{
1419 Name: "Testy McTest",
1420 Password: "password",
1424 FS: func() *MockFileStore {
1425 mfs := &MockFileStore{}
1426 mfs.On("Remove", "Users/testuser.yaml").Return(nil)
1432 tranDeleteUser, &[]byte{0, 1},
1433 NewField(fieldUserLogin, negateString([]byte("testuser"))),
1436 wantRes: []Transaction{
1440 Type: []byte{0x1, 0x5f},
1441 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1442 ErrorCode: []byte{0, 0, 0, 0},
1443 Fields: []Field(nil),
1446 wantErr: assert.NoError,
1449 name: "when user does not have required permission",
1453 Access: func() *[]byte {
1454 var bits accessBitmap
1460 Accounts: map[string]*Account{},
1464 tranDeleteUser, &[]byte{0, 1},
1465 NewField(fieldUserLogin, negateString([]byte("testuser"))),
1468 wantRes: []Transaction{
1472 Type: []byte{0, 0x00},
1473 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1474 ErrorCode: []byte{0, 0, 0, 1},
1476 NewField(fieldError, []byte("You are not allowed to delete accounts.")),
1480 wantErr: assert.NoError,
1483 for _, tt := range tests {
1484 t.Run(tt.name, func(t *testing.T) {
1485 gotRes, err := HandleDeleteUser(tt.args.cc, tt.args.t)
1486 if !tt.wantErr(t, err, fmt.Sprintf("HandleDeleteUser(%v, %v)", tt.args.cc, tt.args.t)) {
1490 tranAssertEqual(t, tt.wantRes, gotRes)
1495 func TestHandleGetMsgs(t *testing.T) {
1503 wantRes []Transaction
1504 wantErr assert.ErrorAssertionFunc
1507 name: "returns news data",
1511 Access: func() *[]byte {
1512 var bits accessBitmap
1513 bits.Set(accessNewsReadArt)
1519 FlatNews: []byte("TEST"),
1523 tranGetMsgs, &[]byte{0, 1},
1526 wantRes: []Transaction{
1530 Type: []byte{0, 0x65},
1531 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1532 ErrorCode: []byte{0, 0, 0, 0},
1534 NewField(fieldData, []byte("TEST")),
1538 wantErr: assert.NoError,
1541 name: "when user does not have required permission",
1545 Access: func() *[]byte {
1546 var bits accessBitmap
1552 Accounts: map[string]*Account{},
1556 tranGetMsgs, &[]byte{0, 1},
1559 wantRes: []Transaction{
1563 Type: []byte{0, 0x00},
1564 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1565 ErrorCode: []byte{0, 0, 0, 1},
1567 NewField(fieldError, []byte("You are not allowed to read news.")),
1571 wantErr: assert.NoError,
1574 for _, tt := range tests {
1575 t.Run(tt.name, func(t *testing.T) {
1576 gotRes, err := HandleGetMsgs(tt.args.cc, tt.args.t)
1577 if !tt.wantErr(t, err, fmt.Sprintf("HandleGetMsgs(%v, %v)", tt.args.cc, tt.args.t)) {
1581 tranAssertEqual(t, tt.wantRes, gotRes)
1586 func TestHandleNewUser(t *testing.T) {
1594 wantRes []Transaction
1595 wantErr assert.ErrorAssertionFunc
1598 name: "when user does not have required permission",
1602 Access: func() *[]byte {
1603 var bits accessBitmap
1609 Accounts: map[string]*Account{},
1613 tranNewUser, &[]byte{0, 1},
1616 wantRes: []Transaction{
1620 Type: []byte{0, 0x00},
1621 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1622 ErrorCode: []byte{0, 0, 0, 1},
1624 NewField(fieldError, []byte("You are not allowed to create new accounts.")),
1628 wantErr: assert.NoError,
1631 for _, tt := range tests {
1632 t.Run(tt.name, func(t *testing.T) {
1633 gotRes, err := HandleNewUser(tt.args.cc, tt.args.t)
1634 if !tt.wantErr(t, err, fmt.Sprintf("HandleNewUser(%v, %v)", tt.args.cc, tt.args.t)) {
1638 tranAssertEqual(t, tt.wantRes, gotRes)
1643 func TestHandleListUsers(t *testing.T) {
1651 wantRes []Transaction
1652 wantErr assert.ErrorAssertionFunc
1655 name: "when user does not have required permission",
1659 Access: func() *[]byte {
1660 var bits accessBitmap
1666 Accounts: map[string]*Account{},
1670 tranNewUser, &[]byte{0, 1},
1673 wantRes: []Transaction{
1677 Type: []byte{0, 0x00},
1678 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1679 ErrorCode: []byte{0, 0, 0, 1},
1681 NewField(fieldError, []byte("You are not allowed to view accounts.")),
1685 wantErr: assert.NoError,
1688 for _, tt := range tests {
1689 t.Run(tt.name, func(t *testing.T) {
1690 gotRes, err := HandleListUsers(tt.args.cc, tt.args.t)
1691 if !tt.wantErr(t, err, fmt.Sprintf("HandleListUsers(%v, %v)", tt.args.cc, tt.args.t)) {
1695 tranAssertEqual(t, tt.wantRes, gotRes)
1700 func TestHandleDownloadFile(t *testing.T) {
1708 wantRes []Transaction
1709 wantErr assert.ErrorAssertionFunc
1712 name: "when user does not have required permission",
1716 Access: func() *[]byte {
1717 var bits accessBitmap
1724 t: NewTransaction(tranDownloadFile, &[]byte{0, 1}),
1726 wantRes: []Transaction{
1730 Type: []byte{0, 0x00},
1731 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1732 ErrorCode: []byte{0, 0, 0, 1},
1734 NewField(fieldError, []byte("You are not allowed to download files.")),
1738 wantErr: assert.NoError,
1741 name: "with a valid file",
1744 Transfers: make(map[int][]*FileTransfer),
1746 Access: func() *[]byte {
1747 var bits accessBitmap
1748 bits.Set(accessDownloadFile)
1755 FileTransfers: make(map[uint32]*FileTransfer),
1757 FileRoot: func() string { path, _ := os.Getwd(); return path + "/test/config/Files" }(),
1759 Accounts: map[string]*Account{},
1765 NewField(fieldFileName, []byte("testfile.txt")),
1766 NewField(fieldFilePath, []byte{0x0, 0x00}),
1769 wantRes: []Transaction{
1773 Type: []byte{0, 0x2},
1774 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1775 ErrorCode: []byte{0, 0, 0, 0},
1777 NewField(fieldRefNum, []byte{0x52, 0xfd, 0xfc, 0x07}),
1778 NewField(fieldWaitingCount, []byte{0x00, 0x00}),
1779 NewField(fieldTransferSize, []byte{0x00, 0x00, 0x00, 0xa5}),
1780 NewField(fieldFileSize, []byte{0x00, 0x00, 0x00, 0x17}),
1784 wantErr: assert.NoError,
1787 name: "when client requests to resume 1k test file at offset 256",
1790 Transfers: make(map[int][]*FileTransfer),
1792 Access: func() *[]byte {
1793 var bits accessBitmap
1794 bits.Set(accessDownloadFile)
1801 // FS: func() *MockFileStore {
1802 // path, _ := os.Getwd()
1803 // testFile, err := os.Open(path + "/test/config/Files/testfile-1k")
1808 // mfi := &MockFileInfo{}
1809 // mfi.On("Mode").Return(fs.FileMode(0))
1810 // mfs := &MockFileStore{}
1811 // mfs.On("Stat", "/fakeRoot/Files/testfile.txt").Return(mfi, nil)
1812 // mfs.On("Open", "/fakeRoot/Files/testfile.txt").Return(testFile, nil)
1813 // mfs.On("Stat", "/fakeRoot/Files/.info_testfile.txt").Return(nil, errors.New("no"))
1814 // mfs.On("Stat", "/fakeRoot/Files/.rsrc_testfile.txt").Return(nil, errors.New("no"))
1818 FileTransfers: make(map[uint32]*FileTransfer),
1820 FileRoot: func() string { path, _ := os.Getwd(); return path + "/test/config/Files" }(),
1822 Accounts: map[string]*Account{},
1828 NewField(fieldFileName, []byte("testfile-1k")),
1829 NewField(fieldFilePath, []byte{0x00, 0x00}),
1831 fieldFileResumeData,
1833 frd := FileResumeData{
1837 ForkCount: [2]byte{0, 2},
1838 ForkInfoList: []ForkInfoList{
1840 Fork: [4]byte{0x44, 0x41, 0x54, 0x41}, // "DATA"
1841 DataSize: [4]byte{0, 0, 0x01, 0x00}, // request offset 256
1846 Fork: [4]byte{0x4d, 0x41, 0x43, 0x52}, // "MACR"
1847 DataSize: [4]byte{0, 0, 0, 0},
1853 b, _ := frd.BinaryMarshal()
1859 wantRes: []Transaction{
1863 Type: []byte{0, 0x2},
1864 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1865 ErrorCode: []byte{0, 0, 0, 0},
1867 NewField(fieldRefNum, []byte{0x52, 0xfd, 0xfc, 0x07}),
1868 NewField(fieldWaitingCount, []byte{0x00, 0x00}),
1869 NewField(fieldTransferSize, []byte{0x00, 0x00, 0x03, 0x8d}),
1870 NewField(fieldFileSize, []byte{0x00, 0x00, 0x03, 0x00}),
1874 wantErr: assert.NoError,
1877 for _, tt := range tests {
1878 t.Run(tt.name, func(t *testing.T) {
1879 gotRes, err := HandleDownloadFile(tt.args.cc, tt.args.t)
1880 if !tt.wantErr(t, err, fmt.Sprintf("HandleDownloadFile(%v, %v)", tt.args.cc, tt.args.t)) {
1884 tranAssertEqual(t, tt.wantRes, gotRes)
1889 func TestHandleUpdateUser(t *testing.T) {
1897 wantRes []Transaction
1898 wantErr assert.ErrorAssertionFunc
1901 name: "when action is create user without required permission",
1905 Logger: NewTestLogger(),
1908 Access: func() *[]byte {
1909 var bits accessBitmap
1918 NewField(fieldData, []byte{
1919 0x00, 0x04, // field count
1921 0x00, 0x69, // fieldUserLogin = 105
1925 0x00, 0x6a, // fieldUserPassword = 106
1929 0x00, 0x66, // fieldUserName = 102
1933 0x00, 0x6e, // fieldUserAccess = 110
1935 0x60, 0x70, 0x0c, 0x20, 0x03, 0x80, 0x00, 0x00,
1939 wantRes: []Transaction{
1943 Type: []byte{0, 0x00},
1944 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1945 ErrorCode: []byte{0, 0, 0, 1},
1947 NewField(fieldError, []byte("You are not allowed to create new accounts.")),
1951 wantErr: assert.NoError,
1954 name: "when action is modify user without required permission",
1958 Logger: NewTestLogger(),
1959 Accounts: map[string]*Account{
1964 Access: func() *[]byte {
1965 var bits accessBitmap
1974 NewField(fieldData, []byte{
1975 0x00, 0x04, // field count
1977 0x00, 0x69, // fieldUserLogin = 105
1981 0x00, 0x6a, // fieldUserPassword = 106
1985 0x00, 0x66, // fieldUserName = 102
1989 0x00, 0x6e, // fieldUserAccess = 110
1991 0x60, 0x70, 0x0c, 0x20, 0x03, 0x80, 0x00, 0x00,
1995 wantRes: []Transaction{
1999 Type: []byte{0, 0x00},
2000 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
2001 ErrorCode: []byte{0, 0, 0, 1},
2003 NewField(fieldError, []byte("You are not allowed to modify accounts.")),
2007 wantErr: assert.NoError,
2010 name: "when action is delete user without required permission",
2014 Logger: NewTestLogger(),
2015 Accounts: map[string]*Account{
2020 Access: func() *[]byte {
2021 var bits accessBitmap
2030 NewField(fieldData, []byte{
2038 wantRes: []Transaction{
2042 Type: []byte{0, 0x00},
2043 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
2044 ErrorCode: []byte{0, 0, 0, 1},
2046 NewField(fieldError, []byte("You are not allowed to delete accounts.")),
2050 wantErr: assert.NoError,
2053 for _, tt := range tests {
2054 t.Run(tt.name, func(t *testing.T) {
2055 gotRes, err := HandleUpdateUser(tt.args.cc, tt.args.t)
2056 if !tt.wantErr(t, err, fmt.Sprintf("HandleUpdateUser(%v, %v)", tt.args.cc, tt.args.t)) {
2060 tranAssertEqual(t, tt.wantRes, gotRes)
2065 func TestHandleDelNewsArt(t *testing.T) {
2073 wantRes []Transaction
2074 wantErr assert.ErrorAssertionFunc
2077 name: "without required permission",
2081 Access: func() *[]byte {
2082 var bits accessBitmap
2093 wantRes: []Transaction{
2097 Type: []byte{0, 0x00},
2098 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
2099 ErrorCode: []byte{0, 0, 0, 1},
2101 NewField(fieldError, []byte("You are not allowed to delete news articles.")),
2105 wantErr: assert.NoError,
2108 for _, tt := range tests {
2109 t.Run(tt.name, func(t *testing.T) {
2110 gotRes, err := HandleDelNewsArt(tt.args.cc, tt.args.t)
2111 if !tt.wantErr(t, err, fmt.Sprintf("HandleDelNewsArt(%v, %v)", tt.args.cc, tt.args.t)) {
2114 tranAssertEqual(t, tt.wantRes, gotRes)
2119 func TestHandleDisconnectUser(t *testing.T) {
2127 wantRes []Transaction
2128 wantErr assert.ErrorAssertionFunc
2131 name: "without required permission",
2135 Access: func() *[]byte {
2136 var bits accessBitmap
2147 wantRes: []Transaction{
2151 Type: []byte{0, 0x00},
2152 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
2153 ErrorCode: []byte{0, 0, 0, 1},
2155 NewField(fieldError, []byte("You are not allowed to disconnect users.")),
2159 wantErr: assert.NoError,
2162 name: "when target user has 'cannot be disconnected' priv",
2166 Clients: map[uint16]*ClientConn{
2170 Access: func() *[]byte {
2171 var bits accessBitmap
2172 bits.Set(accessCannotBeDiscon)
2181 Access: func() *[]byte {
2182 var bits accessBitmap
2183 bits.Set(accessDisconUser)
2192 NewField(fieldUserID, []byte{0, 1}),
2195 wantRes: []Transaction{
2199 Type: []byte{0, 0x00},
2200 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
2201 ErrorCode: []byte{0, 0, 0, 1},
2203 NewField(fieldError, []byte("unnamed is not allowed to be disconnected.")),
2207 wantErr: assert.NoError,
2210 for _, tt := range tests {
2211 t.Run(tt.name, func(t *testing.T) {
2212 gotRes, err := HandleDisconnectUser(tt.args.cc, tt.args.t)
2213 if !tt.wantErr(t, err, fmt.Sprintf("HandleDisconnectUser(%v, %v)", tt.args.cc, tt.args.t)) {
2216 tranAssertEqual(t, tt.wantRes, gotRes)
2221 func TestHandleSendInstantMsg(t *testing.T) {
2229 wantRes []Transaction
2230 wantErr assert.ErrorAssertionFunc
2233 name: "when client 1 sends a message to client 2",
2237 UserName: []byte("User1"),
2239 Clients: map[uint16]*ClientConn{
2241 AutoReply: []byte(nil),
2249 NewField(fieldData, []byte("hai")),
2250 NewField(fieldUserID, []byte{0, 2}),
2253 wantRes: []Transaction{
2257 NewField(fieldData, []byte("hai")),
2258 NewField(fieldUserName, []byte("User1")),
2259 NewField(fieldUserID, []byte{0, 1}),
2260 NewField(fieldOptions, []byte{0, 1}),
2263 clientID: &[]byte{0, 1},
2266 Type: []byte{0x0, 0x6c},
2267 ID: []byte{0, 0, 0, 0},
2268 ErrorCode: []byte{0, 0, 0, 0},
2269 Fields: []Field(nil),
2272 wantErr: assert.NoError,
2275 name: "when client 2 has autoreply enabled",
2279 UserName: []byte("User1"),
2281 Clients: map[uint16]*ClientConn{
2284 UserName: []byte("User2"),
2285 AutoReply: []byte("autohai"),
2293 NewField(fieldData, []byte("hai")),
2294 NewField(fieldUserID, []byte{0, 2}),
2297 wantRes: []Transaction{
2301 NewField(fieldData, []byte("hai")),
2302 NewField(fieldUserName, []byte("User1")),
2303 NewField(fieldUserID, []byte{0, 1}),
2304 NewField(fieldOptions, []byte{0, 1}),
2309 NewField(fieldData, []byte("autohai")),
2310 NewField(fieldUserName, []byte("User2")),
2311 NewField(fieldUserID, []byte{0, 2}),
2312 NewField(fieldOptions, []byte{0, 1}),
2315 clientID: &[]byte{0, 1},
2318 Type: []byte{0x0, 0x6c},
2319 ID: []byte{0, 0, 0, 0},
2320 ErrorCode: []byte{0, 0, 0, 0},
2321 Fields: []Field(nil),
2324 wantErr: assert.NoError,
2327 for _, tt := range tests {
2328 t.Run(tt.name, func(t *testing.T) {
2329 gotRes, err := HandleSendInstantMsg(tt.args.cc, tt.args.t)
2330 if !tt.wantErr(t, err, fmt.Sprintf("HandleSendInstantMsg(%v, %v)", tt.args.cc, tt.args.t)) {
2334 tranAssertEqual(t, tt.wantRes, gotRes)
2339 func TestHandleDeleteFile(t *testing.T) {
2347 wantRes []Transaction
2348 wantErr assert.ErrorAssertionFunc
2351 name: "when user does not have required permission to delete a folder",
2355 Access: func() *[]byte {
2356 var bits accessBitmap
2363 FileRoot: func() string {
2364 return "/fakeRoot/Files"
2367 FS: func() *MockFileStore {
2368 mfi := &MockFileInfo{}
2369 mfi.On("Mode").Return(fs.FileMode(0))
2370 mfi.On("Size").Return(int64(100))
2371 mfi.On("ModTime").Return(time.Parse(time.Layout, time.Layout))
2372 mfi.On("IsDir").Return(false)
2373 mfi.On("Name").Return("testfile")
2375 mfs := &MockFileStore{}
2376 mfs.On("Stat", "/fakeRoot/Files/aaa/testfile").Return(mfi, nil)
2377 mfs.On("Stat", "/fakeRoot/Files/aaa/.info_testfile").Return(nil, errors.New("err"))
2378 mfs.On("Stat", "/fakeRoot/Files/aaa/.rsrc_testfile").Return(nil, errors.New("err"))
2382 Accounts: map[string]*Account{},
2386 tranDeleteFile, &[]byte{0, 1},
2387 NewField(fieldFileName, []byte("testfile")),
2388 NewField(fieldFilePath, []byte{
2396 wantRes: []Transaction{
2400 Type: []byte{0, 0x00},
2401 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
2402 ErrorCode: []byte{0, 0, 0, 1},
2404 NewField(fieldError, []byte("You are not allowed to delete files.")),
2408 wantErr: assert.NoError,
2411 name: "deletes all associated metadata files",
2415 Access: func() *[]byte {
2416 var bits accessBitmap
2417 bits.Set(accessDeleteFile)
2424 FileRoot: func() string {
2425 return "/fakeRoot/Files"
2428 FS: func() *MockFileStore {
2429 mfi := &MockFileInfo{}
2430 mfi.On("Mode").Return(fs.FileMode(0))
2431 mfi.On("Size").Return(int64(100))
2432 mfi.On("ModTime").Return(time.Parse(time.Layout, time.Layout))
2433 mfi.On("IsDir").Return(false)
2434 mfi.On("Name").Return("testfile")
2436 mfs := &MockFileStore{}
2437 mfs.On("Stat", "/fakeRoot/Files/aaa/testfile").Return(mfi, nil)
2438 mfs.On("Stat", "/fakeRoot/Files/aaa/.info_testfile").Return(nil, errors.New("err"))
2439 mfs.On("Stat", "/fakeRoot/Files/aaa/.rsrc_testfile").Return(nil, errors.New("err"))
2441 mfs.On("RemoveAll", "/fakeRoot/Files/aaa/testfile").Return(nil)
2442 mfs.On("Remove", "/fakeRoot/Files/aaa/testfile.incomplete").Return(nil)
2443 mfs.On("Remove", "/fakeRoot/Files/aaa/.rsrc_testfile").Return(nil)
2444 mfs.On("Remove", "/fakeRoot/Files/aaa/.info_testfile").Return(nil)
2448 Accounts: map[string]*Account{},
2452 tranDeleteFile, &[]byte{0, 1},
2453 NewField(fieldFileName, []byte("testfile")),
2454 NewField(fieldFilePath, []byte{
2462 wantRes: []Transaction{
2466 Type: []byte{0x0, 0xcc},
2467 ID: []byte{0x0, 0x0, 0x0, 0x0},
2468 ErrorCode: []byte{0, 0, 0, 0},
2469 Fields: []Field(nil),
2472 wantErr: assert.NoError,
2475 for _, tt := range tests {
2476 t.Run(tt.name, func(t *testing.T) {
2477 gotRes, err := HandleDeleteFile(tt.args.cc, tt.args.t)
2478 if !tt.wantErr(t, err, fmt.Sprintf("HandleDeleteFile(%v, %v)", tt.args.cc, tt.args.t)) {
2482 tranAssertEqual(t, tt.wantRes, gotRes)
2484 tt.args.cc.Server.FS.(*MockFileStore).AssertExpectations(t)