6 "github.com/stretchr/testify/assert"
14 func TestHandleSetChatSubject(t *testing.T) {
26 name: "sends chat subject to private chat members",
29 UserName: []byte{0x00, 0x01},
31 PrivateChats: map[uint32]*PrivateChat{
34 ClientConn: map[uint16]*ClientConn{
37 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
43 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
50 Clients: map[uint16]*ClientConn{
53 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
59 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
69 Type: []byte{0, 0x6a},
70 ID: []byte{0, 0, 0, 1},
71 ErrorCode: []byte{0, 0, 0, 0},
73 NewField(fieldChatID, []byte{0, 0, 0, 1}),
74 NewField(fieldChatSubject, []byte("Test Subject")),
80 clientID: &[]byte{0, 1},
83 Type: []byte{0, 0x77},
84 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
85 ErrorCode: []byte{0, 0, 0, 0},
87 NewField(fieldChatID, []byte{0, 0, 0, 1}),
88 NewField(fieldChatSubject, []byte("Test Subject")),
92 clientID: &[]byte{0, 2},
95 Type: []byte{0, 0x77},
96 ID: []byte{0xf0, 0xc5, 0x34, 0x1e}, // Random ID from rand.Seed(1)
97 ErrorCode: []byte{0, 0, 0, 0},
99 NewField(fieldChatID, []byte{0, 0, 0, 1}),
100 NewField(fieldChatSubject, []byte("Test Subject")),
107 for _, tt := range tests {
108 rand.Seed(1) // reset seed between tests to make transaction IDs predictable
110 t.Run(tt.name, func(t *testing.T) {
111 got, err := HandleSetChatSubject(tt.args.cc, tt.args.t)
112 if (err != nil) != tt.wantErr {
113 t.Errorf("HandleSetChatSubject() error = %v, wantErr %v", err, tt.wantErr)
116 if !assert.Equal(t, tt.want, got) {
117 t.Errorf("HandleSetChatSubject() got = %v, want %v", got, tt.want)
123 func TestHandleLeaveChat(t *testing.T) {
135 name: "returns expected transactions",
140 PrivateChats: map[uint32]*PrivateChat{
142 ClientConn: map[uint16]*ClientConn{
145 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
151 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
158 Clients: map[uint16]*ClientConn{
161 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
167 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
174 t: NewTransaction(tranDeleteUser, nil, NewField(fieldChatID, []byte{0, 0, 0, 1})),
178 clientID: &[]byte{0, 1},
181 Type: []byte{0, 0x76},
182 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
183 ErrorCode: []byte{0, 0, 0, 0},
185 NewField(fieldChatID, []byte{0, 0, 0, 1}),
186 NewField(fieldUserID, []byte{0, 2}),
193 for _, tt := range tests {
195 t.Run(tt.name, func(t *testing.T) {
196 got, err := HandleLeaveChat(tt.args.cc, tt.args.t)
197 if (err != nil) != tt.wantErr {
198 t.Errorf("HandleLeaveChat() error = %v, wantErr %v", err, tt.wantErr)
201 if !assert.Equal(t, tt.want, got) {
202 t.Errorf("HandleLeaveChat() got = %v, want %v", got, tt.want)
208 func TestHandleGetUserNameList(t *testing.T) {
220 name: "replies with userlist transaction",
226 Clients: map[uint16]*ClientConn{
230 Flags: &[]byte{0, 3},
231 UserName: []byte{0, 4},
237 Flags: &[]byte{0, 3},
238 UserName: []byte{0, 4},
244 Flags: &[]byte{0, 3},
245 UserName: []byte{0, 4},
252 ID: []byte{0, 0, 0, 1},
258 clientID: &[]byte{1, 1},
262 ID: []byte{0, 0, 0, 1},
263 ErrorCode: []byte{0, 0, 0, 0},
266 fieldUsernameWithInfo,
267 []byte{00, 01, 00, 02, 00, 03, 00, 02, 00, 04},
270 fieldUsernameWithInfo,
271 []byte{00, 02, 00, 02, 00, 03, 00, 02, 00, 04},
279 for _, tt := range tests {
280 t.Run(tt.name, func(t *testing.T) {
281 got, err := HandleGetUserNameList(tt.args.cc, tt.args.t)
282 if (err != nil) != tt.wantErr {
283 t.Errorf("HandleGetUserNameList() error = %v, wantErr %v", err, tt.wantErr)
286 assert.Equal(t, tt.want, got)
291 func TestHandleChatSend(t *testing.T) {
303 name: "sends chat msg transaction to all clients",
307 Access: func() *[]byte {
308 var bits accessBitmap
309 bits.Set(accessSendChat)
314 UserName: []byte{0x00, 0x01},
316 Clients: map[uint16]*ClientConn{
319 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
325 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
334 NewField(fieldData, []byte("hai")),
340 clientID: &[]byte{0, 1},
343 Type: []byte{0, 0x6a},
344 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
345 ErrorCode: []byte{0, 0, 0, 0},
347 NewField(fieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
351 clientID: &[]byte{0, 2},
354 Type: []byte{0, 0x6a},
355 ID: []byte{0xf0, 0xc5, 0x34, 0x1e}, // Random ID from rand.Seed(1)
356 ErrorCode: []byte{0, 0, 0, 0},
358 NewField(fieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
365 name: "when user does not have required permission",
369 Access: func() *[]byte {
370 var bits accessBitmap
376 Accounts: map[string]*Account{},
380 tranChatSend, &[]byte{0, 1},
381 NewField(fieldData, []byte("hai")),
388 Type: []byte{0, 0x00},
389 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
390 ErrorCode: []byte{0, 0, 0, 1},
392 NewField(fieldError, []byte("You are not allowed to participate in chat.")),
399 name: "sends chat msg as emote if fieldChatOptions is set",
403 Access: func() *[]byte {
404 var bits accessBitmap
405 bits.Set(accessSendChat)
410 UserName: []byte("Testy McTest"),
412 Clients: map[uint16]*ClientConn{
415 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
421 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
430 NewField(fieldData, []byte("performed action")),
431 NewField(fieldChatOptions, []byte{0x00, 0x01}),
437 clientID: &[]byte{0, 1},
440 Type: []byte{0, 0x6a},
441 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
442 ErrorCode: []byte{0, 0, 0, 0},
444 NewField(fieldData, []byte("\r*** Testy McTest performed action")),
448 clientID: &[]byte{0, 2},
451 Type: []byte{0, 0x6a},
452 ID: []byte{0xf0, 0xc5, 0x34, 0x1e}, // Random ID from rand.Seed(1)
453 ErrorCode: []byte{0, 0, 0, 0},
455 NewField(fieldData, []byte("\r*** Testy McTest performed action")),
462 name: "only sends chat msg to clients with accessReadChat permission",
466 Access: func() *[]byte {
467 var bits accessBitmap
468 bits.Set(accessSendChat)
473 UserName: []byte{0x00, 0x01},
475 Clients: map[uint16]*ClientConn{
478 Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
484 Access: &[]byte{0, 0, 0, 0, 0, 0, 0, 0},
493 NewField(fieldData, []byte("hai")),
499 clientID: &[]byte{0, 1},
502 Type: []byte{0, 0x6a},
503 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
504 ErrorCode: []byte{0, 0, 0, 0},
506 NewField(fieldData, []byte{0x0d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x01, 0x3a, 0x20, 0x20, 0x68, 0x61, 0x69}),
513 for _, tt := range tests {
514 t.Run(tt.name, func(t *testing.T) {
515 got, err := HandleChatSend(tt.args.cc, tt.args.t)
517 if (err != nil) != tt.wantErr {
518 t.Errorf("HandleChatSend() error = %v, wantErr %v", err, tt.wantErr)
521 tranAssertEqual(t, tt.want, got)
526 func TestHandleGetFileInfo(t *testing.T) {
527 rand.Seed(1) // reset seed between tests to make transaction IDs predictable
536 wantRes []Transaction
540 name: "returns expected fields when a valid file is requested",
543 ID: &[]byte{0x00, 0x01},
546 FileRoot: func() string {
547 path, _ := os.Getwd()
548 return path + "/test/config/Files"
554 tranGetFileInfo, nil,
555 NewField(fieldFileName, []byte("testfile.txt")),
556 NewField(fieldFilePath, []byte{0x00, 0x00}),
559 wantRes: []Transaction{
561 clientID: &[]byte{0, 1},
564 Type: []byte{0, 0xce},
565 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
566 ErrorCode: []byte{0, 0, 0, 0},
568 NewField(fieldFileName, []byte("testfile.txt")),
569 NewField(fieldFileTypeString, []byte("TEXT")),
570 NewField(fieldFileCreatorString, []byte("ttxt")),
571 NewField(fieldFileComment, []byte{}),
572 NewField(fieldFileType, []byte("TEXT")),
573 NewField(fieldFileCreateDate, make([]byte, 8)),
574 NewField(fieldFileModifyDate, make([]byte, 8)),
575 NewField(fieldFileSize, []byte{0x0, 0x0, 0x0, 0x17}),
582 for _, tt := range tests {
583 t.Run(tt.name, func(t *testing.T) {
584 rand.Seed(1) // reset seed between tests to make transaction IDs predictable
586 gotRes, err := HandleGetFileInfo(tt.args.cc, tt.args.t)
587 if (err != nil) != tt.wantErr {
588 t.Errorf("HandleGetFileInfo() error = %v, wantErr %v", err, tt.wantErr)
592 // Clear the file timestamp fields to work around problems running the tests in multiple timezones
593 // TODO: revisit how to test this by mocking the stat calls
594 gotRes[0].Fields[5].Data = make([]byte, 8)
595 gotRes[0].Fields[6].Data = make([]byte, 8)
596 if !assert.Equal(t, tt.wantRes, gotRes) {
597 t.Errorf("HandleGetFileInfo() gotRes = %v, want %v", gotRes, tt.wantRes)
603 func TestHandleNewFolder(t *testing.T) {
612 wantRes []Transaction
616 name: "when path is nested",
627 tranNewFolder, &[]byte{0, 1},
628 NewField(fieldFileName, []byte("testFolder")),
629 NewField(fieldFilePath, []byte{
638 mfs := &MockFileStore{}
639 mfs.On("Mkdir", "/Files/aaa/testFolder", fs.FileMode(0777)).Return(nil)
640 mfs.On("Stat", "/Files/aaa/testFolder").Return(nil, os.ErrNotExist)
643 wantRes: []Transaction{
645 clientID: &[]byte{0, 1},
648 Type: []byte{0, 0xcd},
649 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
650 ErrorCode: []byte{0, 0, 0, 0},
656 name: "when path is not nested",
667 tranNewFolder, &[]byte{0, 1},
668 NewField(fieldFileName, []byte("testFolder")),
672 mfs := &MockFileStore{}
673 mfs.On("Mkdir", "/Files/testFolder", fs.FileMode(0777)).Return(nil)
674 mfs.On("Stat", "/Files/testFolder").Return(nil, os.ErrNotExist)
677 wantRes: []Transaction{
679 clientID: &[]byte{0, 1},
682 Type: []byte{0, 0xcd},
683 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
684 ErrorCode: []byte{0, 0, 0, 0},
690 name: "when UnmarshalBinary returns an err",
701 tranNewFolder, &[]byte{0, 1},
702 NewField(fieldFileName, []byte("testFolder")),
703 NewField(fieldFilePath, []byte{
709 mfs := &MockFileStore{}
710 mfs.On("Mkdir", "/Files/aaa/testFolder", fs.FileMode(0777)).Return(nil)
711 mfs.On("Stat", "/Files/aaa/testFolder").Return(nil, os.ErrNotExist)
714 wantRes: []Transaction{},
718 name: "fieldFileName does not allow directory traversal",
729 tranNewFolder, &[]byte{0, 1},
730 NewField(fieldFileName, []byte("../../testFolder")),
734 mfs := &MockFileStore{}
735 mfs.On("Mkdir", "/Files/testFolder", fs.FileMode(0777)).Return(nil)
736 mfs.On("Stat", "/Files/testFolder").Return(nil, os.ErrNotExist)
739 wantRes: []Transaction{
741 clientID: &[]byte{0, 1},
744 Type: []byte{0, 0xcd},
745 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
746 ErrorCode: []byte{0, 0, 0, 0},
751 name: "fieldFilePath does not allow directory traversal",
762 tranNewFolder, &[]byte{0, 1},
763 NewField(fieldFileName, []byte("testFolder")),
764 NewField(fieldFilePath, []byte{
776 mfs := &MockFileStore{}
777 mfs.On("Mkdir", "/Files/foo/testFolder", fs.FileMode(0777)).Return(nil)
778 mfs.On("Stat", "/Files/foo/testFolder").Return(nil, os.ErrNotExist)
781 wantRes: []Transaction{
783 clientID: &[]byte{0, 1},
786 Type: []byte{0, 0xcd},
787 ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
788 ErrorCode: []byte{0, 0, 0, 0},
793 for _, tt := range tests {
794 t.Run(tt.name, func(t *testing.T) {
797 gotRes, err := HandleNewFolder(tt.args.cc, tt.args.t)
798 if (err != nil) != tt.wantErr {
799 t.Errorf("HandleNewFolder() error = %v, wantErr %v", err, tt.wantErr)
802 if !tranAssertEqual(t, tt.wantRes, gotRes) {
803 t.Errorf("HandleNewFolder() gotRes = %v, want %v", gotRes, tt.wantRes)
809 func TestHandleUploadFile(t *testing.T) {
817 wantRes []Transaction
821 name: "when request is valid",
825 FileTransfers: map[uint32]*FileTransfer{},
828 Access: func() *[]byte {
829 var bits accessBitmap
830 bits.Set(accessUploadFile)
837 tranUploadFile, &[]byte{0, 1},
838 NewField(fieldFileName, []byte("testFile")),
839 NewField(fieldFilePath, []byte{
847 wantRes: []Transaction{
851 Type: []byte{0, 0xcb},
852 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
853 ErrorCode: []byte{0, 0, 0, 0},
855 NewField(fieldRefNum, []byte{0x52, 0xfd, 0xfc, 0x07}), // rand.Seed(1)
862 name: "when user does not have required access",
866 Access: func() *[]byte {
867 var bits accessBitmap
873 FileTransfers: map[uint32]*FileTransfer{},
877 tranUploadFile, &[]byte{0, 1},
878 NewField(fieldFileName, []byte("testFile")),
879 NewField(fieldFilePath, []byte{
887 wantRes: []Transaction{
891 Type: []byte{0, 0x00},
892 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
893 ErrorCode: []byte{0, 0, 0, 1},
895 NewField(fieldError, []byte("You are not allowed to upload files.")), // rand.Seed(1)
902 for _, tt := range tests {
903 t.Run(tt.name, func(t *testing.T) {
905 gotRes, err := HandleUploadFile(tt.args.cc, tt.args.t)
906 if (err != nil) != tt.wantErr {
907 t.Errorf("HandleUploadFile() error = %v, wantErr %v", err, tt.wantErr)
911 tranAssertEqual(t, tt.wantRes, gotRes)
917 func TestHandleMakeAlias(t *testing.T) {
926 wantRes []Transaction
930 name: "with valid input and required permissions",
932 mfs := &MockFileStore{}
933 path, _ := os.Getwd()
936 path+"/test/config/Files/foo/testFile",
937 path+"/test/config/Files/bar/testFile",
944 Access: func() *[]byte {
945 var bits accessBitmap
946 bits.Set(accessMakeAlias)
953 FileRoot: func() string {
954 path, _ := os.Getwd()
955 return path + "/test/config/Files"
958 Logger: NewTestLogger(),
962 tranMakeFileAlias, &[]byte{0, 1},
963 NewField(fieldFileName, []byte("testFile")),
964 NewField(fieldFilePath, EncodeFilePath(strings.Join([]string{"foo"}, "/"))),
965 NewField(fieldFileNewPath, EncodeFilePath(strings.Join([]string{"bar"}, "/"))),
968 wantRes: []Transaction{
972 Type: []byte{0, 0xd1},
973 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
974 ErrorCode: []byte{0, 0, 0, 0},
975 Fields: []Field(nil),
981 name: "when symlink returns an error",
983 mfs := &MockFileStore{}
984 path, _ := os.Getwd()
987 path+"/test/config/Files/foo/testFile",
988 path+"/test/config/Files/bar/testFile",
989 ).Return(errors.New("ohno"))
995 Access: func() *[]byte {
996 var bits accessBitmap
997 bits.Set(accessMakeAlias)
1004 FileRoot: func() string {
1005 path, _ := os.Getwd()
1006 return path + "/test/config/Files"
1009 Logger: NewTestLogger(),
1013 tranMakeFileAlias, &[]byte{0, 1},
1014 NewField(fieldFileName, []byte("testFile")),
1015 NewField(fieldFilePath, EncodeFilePath(strings.Join([]string{"foo"}, "/"))),
1016 NewField(fieldFileNewPath, EncodeFilePath(strings.Join([]string{"bar"}, "/"))),
1019 wantRes: []Transaction{
1023 Type: []byte{0, 0x00},
1024 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1025 ErrorCode: []byte{0, 0, 0, 1},
1027 NewField(fieldError, []byte("Error creating alias")),
1034 name: "when user does not have required permission",
1039 Access: func() *[]byte {
1040 var bits accessBitmap
1047 FileRoot: func() string {
1048 path, _ := os.Getwd()
1049 return path + "/test/config/Files"
1055 tranMakeFileAlias, &[]byte{0, 1},
1056 NewField(fieldFileName, []byte("testFile")),
1057 NewField(fieldFilePath, []byte{
1063 NewField(fieldFileNewPath, []byte{
1071 wantRes: []Transaction{
1075 Type: []byte{0, 0x00},
1076 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1077 ErrorCode: []byte{0, 0, 0, 1},
1079 NewField(fieldError, []byte("You are not allowed to make aliases.")),
1086 for _, tt := range tests {
1087 t.Run(tt.name, func(t *testing.T) {
1090 gotRes, err := HandleMakeAlias(tt.args.cc, tt.args.t)
1091 if (err != nil) != tt.wantErr {
1092 t.Errorf("HandleMakeAlias(%v, %v)", tt.args.cc, tt.args.t)
1096 tranAssertEqual(t, tt.wantRes, gotRes)
1101 func TestHandleGetUser(t *testing.T) {
1109 wantRes []Transaction
1110 wantErr assert.ErrorAssertionFunc
1113 name: "when account is valid",
1117 Access: func() *[]byte {
1118 var bits accessBitmap
1119 bits.Set(accessOpenUser)
1125 Accounts: map[string]*Account{
1129 Password: "password",
1136 tranGetUser, &[]byte{0, 1},
1137 NewField(fieldUserLogin, []byte("guest")),
1140 wantRes: []Transaction{
1144 Type: []byte{0x01, 0x60},
1145 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1146 ErrorCode: []byte{0, 0, 0, 0},
1148 NewField(fieldUserName, []byte("Guest")),
1149 NewField(fieldUserLogin, negateString([]byte("guest"))),
1150 NewField(fieldUserPassword, []byte("password")),
1151 NewField(fieldUserAccess, []byte{1}),
1155 wantErr: assert.NoError,
1158 name: "when user does not have required permission",
1162 Access: func() *[]byte {
1163 var bits accessBitmap
1169 Accounts: map[string]*Account{},
1173 tranGetUser, &[]byte{0, 1},
1174 NewField(fieldUserLogin, []byte("nonExistentUser")),
1177 wantRes: []Transaction{
1181 Type: []byte{0, 0x00},
1182 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1183 ErrorCode: []byte{0, 0, 0, 1},
1185 NewField(fieldError, []byte("You are not allowed to view accounts.")),
1189 wantErr: assert.NoError,
1192 name: "when account does not exist",
1196 Access: func() *[]byte {
1197 var bits accessBitmap
1198 bits.Set(accessOpenUser)
1204 Accounts: map[string]*Account{},
1208 tranGetUser, &[]byte{0, 1},
1209 NewField(fieldUserLogin, []byte("nonExistentUser")),
1212 wantRes: []Transaction{
1216 Type: []byte{0, 0x00},
1217 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1218 ErrorCode: []byte{0, 0, 0, 1},
1220 NewField(fieldError, []byte("Account does not exist.")),
1224 wantErr: assert.NoError,
1227 for _, tt := range tests {
1228 t.Run(tt.name, func(t *testing.T) {
1229 gotRes, err := HandleGetUser(tt.args.cc, tt.args.t)
1230 if !tt.wantErr(t, err, fmt.Sprintf("HandleGetUser(%v, %v)", tt.args.cc, tt.args.t)) {
1234 tranAssertEqual(t, tt.wantRes, gotRes)
1239 func TestHandleDeleteUser(t *testing.T) {
1248 wantRes []Transaction
1249 wantErr assert.ErrorAssertionFunc
1252 name: "when user exists",
1254 mfs := &MockFileStore{}
1255 mfs.On("Remove", "Users/testuser.yaml").Return(nil)
1261 Access: func() *[]byte {
1262 var bits accessBitmap
1263 bits.Set(accessDeleteUser)
1269 Accounts: map[string]*Account{
1272 Name: "Testy McTest",
1273 Password: "password",
1280 tranDeleteUser, &[]byte{0, 1},
1281 NewField(fieldUserLogin, negateString([]byte("testuser"))),
1284 wantRes: []Transaction{
1288 Type: []byte{0x1, 0x5f},
1289 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1290 ErrorCode: []byte{0, 0, 0, 0},
1291 Fields: []Field(nil),
1294 wantErr: assert.NoError,
1297 name: "when user does not have required permission",
1302 Access: func() *[]byte {
1303 var bits accessBitmap
1309 Accounts: map[string]*Account{},
1313 tranDeleteUser, &[]byte{0, 1},
1314 NewField(fieldUserLogin, negateString([]byte("testuser"))),
1317 wantRes: []Transaction{
1321 Type: []byte{0, 0x00},
1322 ID: []byte{0x9a, 0xcb, 0x04, 0x42},
1323 ErrorCode: []byte{0, 0, 0, 1},
1325 NewField(fieldError, []byte("You are not allowed to delete accounts.")),
1329 wantErr: assert.NoError,
1332 for _, tt := range tests {
1333 t.Run(tt.name, func(t *testing.T) {
1335 gotRes, err := HandleDeleteUser(tt.args.cc, tt.args.t)
1336 if !tt.wantErr(t, err, fmt.Sprintf("HandleDeleteUser(%v, %v)", tt.args.cc, tt.args.t)) {
1340 tranAssertEqual(t, tt.wantRes, gotRes)