Go-Backend (chi, pgx, golang-migrate) + React/TS-Frontend als PWA. Enthalten: Auth inkl. OIDC, Dateien mit Versionen und Papierkorb, Freigaben (Links + intern), WebDAV, Gruppenordner, Admin/Theming, Volltextsuche mit OCR, eigener PDF-Betrachter und WOPI-Office (Collabora/OnlyOffice). Nicht im Repo: deploy/.env (Sitzungsschlüssel, DB- und Admin-Passwort) sowie alle Daten- und Build-Verzeichnisse – siehe .gitignore. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
40 lines
822 B
Go
40 lines
822 B
Go
package auth
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestHashAndVerify(t *testing.T) {
|
|
hash, err := HashPassword("correct-horse-battery-staple")
|
|
if err != nil {
|
|
t.Fatalf("HashPassword: %v", err)
|
|
}
|
|
if hash == "" {
|
|
t.Fatal("expected non-empty hash")
|
|
}
|
|
|
|
ok, err := VerifyPassword("correct-horse-battery-staple", hash)
|
|
if err != nil {
|
|
t.Fatalf("VerifyPassword: %v", err)
|
|
}
|
|
if !ok {
|
|
t.Error("expected password to match")
|
|
}
|
|
|
|
ok, err = VerifyPassword("wrong-password", hash)
|
|
if err != nil {
|
|
t.Fatalf("VerifyPassword wrong: %v", err)
|
|
}
|
|
if ok {
|
|
t.Error("expected wrong password to not match")
|
|
}
|
|
}
|
|
|
|
func TestHashUniqueness(t *testing.T) {
|
|
h1, _ := HashPassword("same-password")
|
|
h2, _ := HashPassword("same-password")
|
|
if h1 == h2 {
|
|
t.Error("two hashes of the same password should differ (different salts)")
|
|
}
|
|
}
|