aboutsummaryrefslogtreecommitdiff
path: root/internal/player/password_test.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-09-19 03:15:59 -0400
committerhistoria <[not public]>2026-09-19 03:15:59 -0400
commit0e60567a7a0addb9421769ee7be7853bfa8788cb (patch)
tree7645112db0e4eae95b8a83c1e4f9aab38bede655 /internal/player/password_test.go
parentcc33072eced3d5460512c09c42ec4531c807d7af (diff)
downloadthehouseoficarus-0e60567a7a0addb9421769ee7be7853bfa8788cb.tar.gz
refactor: simplifcation, change how rooms are stored in player yaml, remove legacy code
Diffstat (limited to 'internal/player/password_test.go')
-rw-r--r--internal/player/password_test.go34
1 files changed, 8 insertions, 26 deletions
diff --git a/internal/player/password_test.go b/internal/player/password_test.go
index 82b580b..2a7d596 100644
--- a/internal/player/password_test.go
+++ b/internal/player/password_test.go
@@ -1,9 +1,6 @@
package player
import (
- "crypto/sha256"
- "encoding/base64"
- "fmt"
"strings"
"testing"
)
@@ -29,30 +26,15 @@ func TestHashPasswordUsesArgon2idAndVerifies(t *testing.T) {
}
}
-func TestCheckPasswordVerifiesLegacySHA256(t *testing.T) {
- salt := make([]byte, 16)
- for i := range salt {
- salt[i] = byte(i)
- }
- sum := sha256.Sum256(append(salt, []byte("legacy pw")...))
- legacy := fmt.Sprintf("sha256:%s:%x", base64.RawStdEncoding.EncodeToString(salt), sum)
-
- if !CheckPassword("legacy pw", legacy) {
- t.Fatal("correct legacy password rejected")
- }
- if CheckPassword("wrong", legacy) {
- t.Fatal("wrong legacy password accepted")
- }
- if !NeedsRehash(legacy) {
- t.Fatal("legacy hash not flagged for rehash")
- }
- if NeedsRehash("argon2id:1:65536:2:c2FsdA:x") {
- t.Fatal("argon2id hash flagged for rehash")
- }
-}
-
func TestCheckPasswordRejectsGarbage(t *testing.T) {
- for _, stored := range []string{"", "plain", "argon2id:1:2:3:no-salt:zz", "unknown:v1:salt:deadbeef"} {
+ for _, stored := range []string{
+ "",
+ "plain",
+ "argon2id:1:2:3:no-salt:zz",
+ "unknown:v1:salt:deadbeef",
+ // Legacy single-pass SHA-256 hashes are no longer accepted.
+ "sha256:AAAAAAAAAAAAAAAAAAAAAA:0011223344556677889900112233445566778899001122334455667788990011",
+ } {
if CheckPassword("anything", stored) {
t.Fatalf("garbage hash accepted: %q", stored)
}