Icon: []byte{0, 2},
Flags: []byte{0, 3},
UserName: []byte{0, 4},
- Agreed: true,
},
uint16(2): {
ID: &[]byte{0, 2},
Icon: []byte{0, 2},
Flags: []byte{0, 3},
UserName: []byte{0, 4},
- Agreed: true,
},
uint16(3): {
ID: &[]byte{0, 3},
Icon: []byte{0, 2},
Flags: []byte{0, 3},
UserName: []byte{0, 4},
- Agreed: false,
},
},
},
clientID: &[]byte{1, 1},
Flags: 0x00,
IsReply: 0x01,
- Type: []byte{0, 1},
+ Type: []byte{0, 0},
ID: []byte{0, 0, 0, 1},
ErrorCode: []byte{0, 0, 0, 0},
Fields: []Field{
clientID: &[]byte{0, 1},
Flags: 0x00,
IsReply: 0x01,
- Type: []byte{0, 0xce},
+ Type: []byte{0, 0},
ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
ErrorCode: []byte{0, 0, 0, 0},
Fields: []Field{
clientID: &[]byte{0, 1},
Flags: 0x00,
IsReply: 0x01,
- Type: []byte{0, 0xcd},
+ Type: []byte{0, 0},
ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
ErrorCode: []byte{0, 0, 0, 0},
},
clientID: &[]byte{0, 1},
Flags: 0x00,
IsReply: 0x01,
- Type: []byte{0, 0xcd},
+ Type: []byte{0, 0},
ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
ErrorCode: []byte{0, 0, 0, 0},
},
clientID: &[]byte{0, 1},
Flags: 0x00,
IsReply: 0x01,
- Type: []byte{0, 0xcd},
+ Type: []byte{0, 0},
ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
ErrorCode: []byte{0, 0, 0, 0},
},
clientID: &[]byte{0, 1},
Flags: 0x00,
IsReply: 0x01,
- Type: []byte{0, 0xcd},
+ Type: []byte{0, 0},
ID: []byte{0x9a, 0xcb, 0x04, 0x42}, // Random ID from rand.Seed(1)
ErrorCode: []byte{0, 0, 0, 0},
},
{
Flags: 0x00,
IsReply: 0x01,
- Type: []byte{0, 0xcb},
+ Type: []byte{0, 0},
ID: []byte{0x9a, 0xcb, 0x04, 0x42},
ErrorCode: []byte{0, 0, 0, 0},
Fields: []Field{
{
Flags: 0x00,
IsReply: 0x01,
- Type: []byte{0, 0xd1},
+ Type: []byte{0, 0},
ID: []byte{0x9a, 0xcb, 0x04, 0x42},
ErrorCode: []byte{0, 0, 0, 0},
Fields: []Field(nil),
{
Flags: 0x00,
IsReply: 0x01,
- Type: []byte{0x01, 0x60},
+ Type: []byte{0, 0},
ID: []byte{0x9a, 0xcb, 0x04, 0x42},
ErrorCode: []byte{0, 0, 0, 0},
Fields: []Field{
{
Flags: 0x00,
IsReply: 0x01,
- Type: []byte{0x1, 0x5f},
+ Type: []byte{0, 0},
ID: []byte{0x9a, 0xcb, 0x04, 0x42},
ErrorCode: []byte{0, 0, 0, 0},
Fields: []Field(nil),
{
Flags: 0x00,
IsReply: 0x01,
- Type: []byte{0, 0x65},
+ Type: []byte{0, 0},
ID: []byte{0x9a, 0xcb, 0x04, 0x42},
ErrorCode: []byte{0, 0, 0, 0},
Fields: []Field{
{
Flags: 0x00,
IsReply: 0x01,
- Type: []byte{0x01, 0x2f},
+ Type: []byte{0, 0},
ID: []byte{0, 0, 0, 0},
ErrorCode: []byte{0, 0, 0, 0},
Fields: []Field{
{
Flags: 0x00,
IsReply: 0x01,
- Type: []byte{0, 0x2},
+ Type: []byte{0, 0},
ID: []byte{0x9a, 0xcb, 0x04, 0x42},
ErrorCode: []byte{0, 0, 0, 0},
Fields: []Field{
{
Flags: 0x00,
IsReply: 0x01,
- Type: []byte{0, 0x2},
+ Type: []byte{0, 0},
ID: []byte{0x9a, 0xcb, 0x04, 0x42},
ErrorCode: []byte{0, 0, 0, 0},
Fields: []Field{
clientID: &[]byte{0, 1},
Flags: 0x00,
IsReply: 0x01,
- Type: []byte{0x0, 0x6c},
+ Type: []byte{0, 0},
ID: []byte{0, 0, 0, 0},
ErrorCode: []byte{0, 0, 0, 0},
Fields: []Field(nil),
clientID: &[]byte{0, 1},
Flags: 0x00,
IsReply: 0x01,
- Type: []byte{0x0, 0x6c},
+ Type: []byte{0, 0},
ID: []byte{0, 0, 0, 0},
ErrorCode: []byte{0, 0, 0, 0},
Fields: []Field(nil),
clientID: &[]byte{0, 1},
Flags: 0x00,
IsReply: 0x01,
- Type: []byte{0x0, 0x6c},
+ Type: []byte{0, 0},
ID: []byte{0, 0, 0, 0},
ErrorCode: []byte{0, 0, 0, 0},
Fields: []Field(nil),
{
Flags: 0x00,
IsReply: 0x01,
- Type: []byte{0x0, 0xcc},
+ Type: []byte{0, 0},
ID: []byte{0x0, 0x0, 0x0, 0x0},
ErrorCode: []byte{0, 0, 0, 0},
Fields: []Field(nil),
{
Flags: 0x00,
IsReply: 0x01,
- Type: []byte{0, 0xc8},
+ Type: []byte{0, 0},
ID: []byte{0, 0, 0, 0},
ErrorCode: []byte{0, 0, 0, 0},
Fields: []Field{
{
Flags: 0x00,
IsReply: 0x01,
- Type: []byte{0x1, 0x2f},
+ Type: []byte{0, 0},
ID: []byte{0, 0, 0, 0},
ErrorCode: []byte{0, 0, 0, 0},
Fields: []Field{
clientID: &[]byte{0, 1},
Flags: 0x00,
IsReply: 0x01,
- Type: []byte{0, 0x79},
+ Type: []byte{0, 0},
ID: []byte{0, 0, 0, 0},
ErrorCode: []byte{0, 0, 0, 0},
Fields: []Field{},
clientID: &[]byte{0, 1},
Flags: 0x00,
IsReply: 0x01,
- Type: []byte{0x01, 0x7c},
+ Type: []byte{0, 0},
ID: []byte{0, 0, 0, 0},
ErrorCode: []byte{0, 0, 0, 0},
Fields: []Field{},
clientID: &[]byte{0, 1},
Flags: 0x00,
IsReply: 0x01,
- Type: []byte{0x00, 0xd4},
+ Type: []byte{0, 0},
ID: []byte{0, 0, 0, 0},
ErrorCode: []byte{0, 0, 0, 0},
Fields: []Field{
{
Flags: 0x00,
IsReply: 0x01,
- Type: []byte{0, 0x67},
+ Type: []byte{0, 0},
ID: []byte{0, 0, 0, 0},
ErrorCode: []byte{0, 0, 0, 0},
},
clientID: &[]byte{0, 1},
Flags: 0x00,
IsReply: 0x01,
- Type: []byte{0, 0x70},
+ Type: []byte{0, 0},
ID: []byte{0, 0, 0, 0},
ErrorCode: []byte{0, 0, 0, 0},
Fields: []Field{
clientID: &[]byte{0, 1},
Flags: 0x00,
IsReply: 0x01,
- Type: []byte{0, 0x70},
+ Type: []byte{0, 0},
ID: []byte{0, 0, 0, 0},
ErrorCode: []byte{0, 0, 0, 0},
Fields: []Field{
})
}
}
+
+func TestHandleGetNewsArtData(t *testing.T) {
+ type args struct {
+ cc *ClientConn
+ t *Transaction
+ }
+ tests := []struct {
+ name string
+ args args
+ wantRes []Transaction
+ wantErr assert.ErrorAssertionFunc
+ }{
+ {
+ name: "when user does not have required permission",
+ args: args{
+ cc: &ClientConn{
+ Account: &Account{
+ Access: func() accessBitmap {
+ var bits accessBitmap
+ return bits
+ }(),
+ },
+ Server: &Server{
+ Accounts: map[string]*Account{},
+ },
+ },
+ t: NewTransaction(
+ tranGetNewsArtData, &[]byte{0, 1},
+ ),
+ },
+ wantRes: []Transaction{
+ {
+ Flags: 0x00,
+ IsReply: 0x01,
+ Type: []byte{0, 0x00},
+ ID: []byte{0x9a, 0xcb, 0x04, 0x42},
+ ErrorCode: []byte{0, 0, 0, 1},
+ Fields: []Field{
+ NewField(fieldError, []byte("You are not allowed to read news.")),
+ },
+ },
+ },
+ wantErr: assert.NoError,
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ gotRes, err := HandleGetNewsArtData(tt.args.cc, tt.args.t)
+ if !tt.wantErr(t, err, fmt.Sprintf("HandleGetNewsArtData(%v, %v)", tt.args.cc, tt.args.t)) {
+ return
+ }
+ tranAssertEqual(t, tt.wantRes, gotRes)
+ })
+ }
+}