auth: Registrierung, Login, Logout, per-user Sessions (Backend)
This commit is contained in:
parent
c7b4acea02
commit
0ef39cffd6
12 changed files with 703 additions and 40 deletions
|
|
@ -36,9 +36,21 @@ func TestLoadJSON(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestValidateRequiresToken(t *testing.T) {
|
||||
t.Setenv("BYTECLAW_AUTH_TOKEN", "")
|
||||
func TestValidateShortToken(t *testing.T) {
|
||||
t.Setenv("BYTECLAW_AUTH_TOKEN", "short")
|
||||
if _, err := Load(""); err == nil {
|
||||
t.Fatal("expected error without token")
|
||||
t.Fatal("expected error for short token")
|
||||
}
|
||||
t.Setenv("BYTECLAW_AUTH_TOKEN", "")
|
||||
c, err := Load("")
|
||||
if err != nil {
|
||||
t.Fatalf("token is optional now: %v", err)
|
||||
}
|
||||
if !c.RegistrationAllowed() {
|
||||
t.Fatal("registration must default to true")
|
||||
}
|
||||
t.Setenv("BYTECLAW_ALLOW_REGISTRATION", "false")
|
||||
if c, _ = Load(""); c.RegistrationAllowed() {
|
||||
t.Fatal("env must disable registration")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue