aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2022-06-24 13:39:48 -0700
committerJeff Halter <868228+jhalter@users.noreply.github.com>2022-06-24 13:39:48 -0700
commit60ec6281e7a98cb268cf9a8ec7945069fe195cde (patch)
tree85dc59c95f60800dd44d6593b75bb5329baef2c8
parent926c7f5505456a0900e9c49f6c08efebe9a53505 (diff)
Backfill test for tranHandleListUsers
-rw-r--r--hotline/transaction_handlers_test.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/hotline/transaction_handlers_test.go b/hotline/transaction_handlers_test.go
index e379f09..06782a1 100644
--- a/hotline/transaction_handlers_test.go
+++ b/hotline/transaction_handlers_test.go
@@ -1690,6 +1690,52 @@ func TestHandleListUsers(t *testing.T) {
},
wantErr: assert.NoError,
},
+ {
+ name: "when user has required permission",
+ args: args{
+ cc: &ClientConn{
+ Account: &Account{
+ Access: func() *[]byte {
+ var bits accessBitmap
+ bits.Set(accessOpenUser)
+ access := bits[:]
+ return &access
+ }(),
+ },
+ Server: &Server{
+ Accounts: map[string]*Account{
+ "guest": {
+ Name: "guest",
+ Login: "guest",
+ Password: "zz",
+ Access: &[]byte{255, 255, 255, 255, 255, 255, 255, 255},
+ },
+ },
+ },
+ },
+ t: NewTransaction(
+ tranGetClientInfoText, &[]byte{0, 1},
+ NewField(fieldUserID, []byte{0, 1}),
+ ),
+ },
+ wantRes: []Transaction{
+ {
+ Flags: 0x00,
+ IsReply: 0x01,
+ Type: []byte{0x01, 0x2f},
+ ID: []byte{0, 0, 0, 0},
+ ErrorCode: []byte{0, 0, 0, 0},
+ Fields: []Field{
+ NewField(fieldData, []byte{
+ 0x00, 0x04, 0x00, 0x66, 0x00, 0x05, 0x67, 0x75, 0x65, 0x73, 0x74, 0x00, 0x69, 0x00, 0x05, 0x98,
+ 0x8a, 0x9a, 0x8c, 0x8b, 0x00, 0x6e, 0x00, 0x08, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0x00, 0x6a, 0x00, 0x01, 0x78,
+ }),
+ },
+ },
+ },
+ wantErr: assert.NoError,
+ },
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {