forked from Velocidex/velociraptor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset_user_test.go
36 lines (29 loc) · 1.01 KB
/
set_user_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package users_test
import (
"www.velocidex.com/golang/velociraptor/users"
"www.velocidex.com/golang/velociraptor/vtesting/assert"
)
func (self *UserManagerTestSuite) TestSetUserPassword() {
self.makeUsers()
// Can a user update their password?
err := users.SetUserPassword(
self.Ctx, "UserO1", "UserO1", "MyPassword", "")
assert.NoError(self.T(), err)
// Verify the password
ok, err := users.VerifyPassword(
self.Ctx, "UserO1", "UserO1", "MyPassword")
assert.NoError(self.T(), err)
assert.True(self.T(), ok)
// Can a user update an admin's password?
err = users.SetUserPassword(
self.Ctx, "UserO1", "AdminO1", "MyPassword", "")
assert.Error(self.T(), err, "PermissionDenied")
// Can an admin update a user's password?
err = users.SetUserPassword(
self.Ctx, "AdminO1", "UserO1", "MyPassword", "")
assert.NoError(self.T(), err)
// Can a user set current org to a different org?
err = users.SetUserPassword(
self.Ctx, "UserO1", "UserO1", "", "O2")
assert.Error(self.T(), err, "PermissionDenied")
}