1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00

auth: Implement an Authenticator type

This patch implements an Authenticator type, which connections use to
do authentication and user existence checks.

It simplifies the abstractions (the server doesn't need to know about
userdb, or keep track of domain-userdb maps), and lays the foundation
for other types of authentication backends which will come in later
patches.
This commit is contained in:
Alberto Bertogli
2018-01-29 21:55:34 +00:00
parent 08e6f57d2e
commit d4992ef8c5
6 changed files with 368 additions and 73 deletions

View File

@@ -129,7 +129,7 @@ func TestWrite(t *testing.T) {
db = mustLoad(t, fname)
for _, name := range []string{"user1", "ñoño"} {
if !db.HasUser(name) {
if !db.Exists(name) {
t.Errorf("user %q not in database", name)
}
if db.db.Users[name].GetScheme() == nil {
@@ -294,12 +294,12 @@ func TestRemoveUser(t *testing.T) {
}
}
func TestHasUser(t *testing.T) {
func TestExists(t *testing.T) {
fname := mustCreateDB(t, "")
defer removeIfSuccessful(t, fname)
db := mustLoad(t, fname)
if db.HasUser("unknown") {
if db.Exists("unknown") {
t.Errorf("unknown user exists")
}
@@ -307,15 +307,15 @@ func TestHasUser(t *testing.T) {
t.Fatalf("error adding user: %v", err)
}
if db.HasUser("unknown") {
if db.Exists("unknown") {
t.Errorf("unknown user exists")
}
if !db.HasUser("user") {
if !db.Exists("user") {
t.Errorf("known user does not exist")
}
if !db.HasUser("user") {
if !db.Exists("user") {
t.Errorf("known user does not exist")
}
}