- wantErr: assert.NoError,
- },
- {
- name: "when user has required access",
- args: args{
- cc: &ClientConn{
- Account: &Account{
- Access: func() accessBitmap {
- var bits accessBitmap
- bits.Set(accessNewsReadArt)
- return bits
- }(),
- },
- Server: &Server{
- ThreadedNews: &ThreadedNews{
- Categories: map[string]NewsCategoryListData15{
- "Example Category": {
- Type: [2]byte{0, 2},
- Name: "",
- Articles: map[uint32]*NewsArtData{
- uint32(1): {
- Title: "testTitle",
- Poster: "testPoster",
- Data: "testBody",
- },
- },
- SubCats: nil,
- GUID: [16]byte{},
- AddSN: [4]byte{},
- DeleteSN: [4]byte{},
- },
- },
- },
-
- //Accounts: map[string]*Account{
- // "guest": {
- // Name: "guest",
- // Login: "guest",
- // Password: "zz",
- // Access: accessBitmap{255, 255, 255, 255, 255, 255, 255, 255},
- // },
- //},
- },
- },
- t: NewTransaction(
- TranGetNewsArtNameList,
- &[]byte{0, 1},
- // 00000000 00 01 00 00 10 45 78 61 6d 70 6c 65 20 43 61 74 |.....Example Cat|
- // 00000010 65 67 6f 72 79 |egory|
- NewField(FieldNewsPath, []byte{
- 0x00, 0x01, 0x00, 0x00, 0x10, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x43, 0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79,
- }),
- ),
- },
- wantRes: []Transaction{
- {
- Flags: 0x00,
- IsReply: 0x01,
- Type: []byte{0, 0},
- ErrorCode: []byte{0, 0, 0, 0},
- Fields: []Field{
- NewField(FieldNewsArtListData, []byte{
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
- 0x09, 0x74, 0x65, 0x73, 0x74, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x0a, 0x74, 0x65, 0x73, 0x74, 0x50,
- 0x6f, 0x73, 0x74, 0x65, 0x72, 0x0a, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e,
- 0x00, 0x08,
- },
- ),
- },
- },
- },
- wantErr: assert.NoError,