mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-17 14:37:02 +00:00
userdb: Add a method to remove users
This patch adds a method to userdb to remove users. It will not be used by chasquid, but by the command-line tool.
This commit is contained in:
@@ -256,5 +256,30 @@ func TestReload(t *testing.T) {
|
||||
if len(db.db.Users) != 2 {
|
||||
t.Errorf("expected 2 users, got %d", len(db.db.Users))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestRemoveUser(t *testing.T) {
|
||||
fname := mustCreateDB(t, "")
|
||||
defer removeIfSuccessful(t, fname)
|
||||
db := mustLoad(t, fname)
|
||||
|
||||
if ok := db.RemoveUser("unknown"); ok {
|
||||
t.Errorf("removal of unknown user succeeded")
|
||||
}
|
||||
|
||||
if err := db.AddUser("user", "passwd"); err != nil {
|
||||
t.Fatalf("error adding user: %v", err)
|
||||
}
|
||||
|
||||
if ok := db.RemoveUser("unknown"); ok {
|
||||
t.Errorf("removal of unknown user succeeded")
|
||||
}
|
||||
|
||||
if ok := db.RemoveUser("user"); !ok {
|
||||
t.Errorf("removal of existing user failed")
|
||||
}
|
||||
|
||||
if ok := db.RemoveUser("user"); ok {
|
||||
t.Errorf("removal of unknown user succeeded")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user