aboutsummaryrefslogtreecommitdiff
path: root/hotline/transaction_handlers_test.go
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2022-06-25 21:46:08 -0700
committerGitHub <noreply@github.com>2022-06-25 21:46:08 -0700
commit1632959187e9c7d8946126914af99270fc14d40a (patch)
tree2c5e3316c800ad49248bf4d6b31bcb86f0993913 /hotline/transaction_handlers_test.go
parent889a8f76762b2cb924e74a6b18f1283afcceaa93 (diff)
parent1f34616efc9fa4b028892d4edb04af9da5b50a1a (diff)
Merge pull request #47 from jhalter/implement_access_send_priv_msg
Implement "Can Send Messages" permission
Diffstat (limited to 'hotline/transaction_handlers_test.go')
-rw-r--r--hotline/transaction_handlers_test.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/hotline/transaction_handlers_test.go b/hotline/transaction_handlers_test.go
index f43d45f..c504bbe 100644
--- a/hotline/transaction_handlers_test.go
+++ b/hotline/transaction_handlers_test.go
@@ -2288,9 +2288,48 @@ func TestHandleSendInstantMsg(t *testing.T) {
wantErr assert.ErrorAssertionFunc
}{
{
+ name: "without required permission",
+ args: args{
+ cc: &ClientConn{
+ Account: &Account{
+ Access: func() *[]byte {
+ var bits accessBitmap
+ access := bits[:]
+ return &access
+ }(),
+ },
+ },
+ t: NewTransaction(
+ tranDelNewsArt,
+ &[]byte{0, 0},
+ ),
+ },
+ wantRes: []Transaction{
+ {
+ Flags: 0x00,
+ IsReply: 0x01,
+ Type: []byte{0, 0x00},
+ ID: []byte{0, 0, 0, 0},
+ ErrorCode: []byte{0, 0, 0, 1},
+ Fields: []Field{
+ NewField(fieldError, []byte("You are not allowed to send private messages.")),
+ },
+ },
+ },
+ wantErr: assert.NoError,
+ },
+ {
name: "when client 1 sends a message to client 2",
args: args{
cc: &ClientConn{
+ Account: &Account{
+ Access: func() *[]byte {
+ var bits accessBitmap
+ bits.Set(accessSendPrivMsg)
+ access := bits[:]
+ return &access
+ }(),
+ },
ID: &[]byte{0, 1},
UserName: []byte("User1"),
Server: &Server{
@@ -2333,6 +2372,14 @@ func TestHandleSendInstantMsg(t *testing.T) {
name: "when client 2 has autoreply enabled",
args: args{
cc: &ClientConn{
+ Account: &Account{
+ Access: func() *[]byte {
+ var bits accessBitmap
+ bits.Set(accessSendPrivMsg)
+ access := bits[:]
+ return &access
+ }(),
+ },
ID: &[]byte{0, 1},
UserName: []byte("User1"),
Server: &Server{