Files
Aether/backend/internal/auth/password_test.go
T
HoneyandClaude Opus 5 31a027c93a feat(aether): initial commit – self-hosted Cloud, Phasen 1–7
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>
2026-08-24 09:25:36 +02:00

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)")
}
}