diff options
| author | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2022-07-04 12:41:48 -0700 |
|---|---|---|
| committer | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2022-07-04 12:41:48 -0700 |
| commit | ecb1fcd941a85162b9a799e59bb3b6b0bc1a5580 (patch) | |
| tree | 700acaee778e57bfa7f2c01c2011c339c4f2985a /hotline/transaction_handlers_test.go | |
| parent | e17f2303e8c1fb940b7550af2b02b6eb35d58f96 (diff) | |
Prevent account from creating new account with greater permission
Diffstat (limited to 'hotline/transaction_handlers_test.go')
| -rw-r--r-- | hotline/transaction_handlers_test.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/hotline/transaction_handlers_test.go b/hotline/transaction_handlers_test.go index fd66fea..bc40254 100644 --- a/hotline/transaction_handlers_test.go +++ b/hotline/transaction_handlers_test.go @@ -1613,6 +1613,48 @@ func TestHandleNewUser(t *testing.T) { }, wantErr: assert.NoError, }, + { + name: "when user attempts to create account with greater access", + args: args{ + cc: &ClientConn{ + Account: &Account{ + Access: func() accessBitmap { + var bits accessBitmap + bits.Set(accessCreateUser) + return bits + }(), + }, + Server: &Server{ + Accounts: map[string]*Account{}, + }, + }, + t: NewTransaction( + tranNewUser, &[]byte{0, 1}, + NewField(fieldUserLogin, []byte("userB")), + NewField( + fieldUserAccess, + func() []byte { + var bits accessBitmap + bits.Set(accessDisconUser) + return bits[:] + }(), + ), + ), + }, + 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("Cannot create account with more access than yourself.")), + }, + }, + }, + wantErr: assert.NoError, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { |