aboutsummaryrefslogtreecommitdiff
path: root/internal/game/login_offowner_regression_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/game/login_offowner_regression_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/game/login_offowner_regression_test.go')
-rw-r--r--internal/game/login_offowner_regression_test.go43
1 files changed, 7 insertions, 36 deletions
diff --git a/internal/game/login_offowner_regression_test.go b/internal/game/login_offowner_regression_test.go
index fa8324c..4826c4c 100644
--- a/internal/game/login_offowner_regression_test.go
+++ b/internal/game/login_offowner_regression_test.go
@@ -6,8 +6,6 @@ package game
// transition on the owner. The observable login behavior is unchanged.
import (
- "crypto/sha256"
- "encoding/base64"
"strings"
"testing"
"time"
@@ -29,26 +27,13 @@ func waitForOutput(t *testing.T, conn *chanConn, substr string) {
}
}
-// TestLoginThroughServerEntryUsesOffOwnerPathAndUpgradesLegacyHash drives
-// the real server entry point (HandleSessionOnOwner) through: legacy-hash
-// account creation, a WRONG password attempt, and a correct login that
-// rehashes the legacy SHA-256 hash to Argon2id durably.
-func TestLoginThroughServerEntryUsesOffOwnerPathAndUpgradesLegacyHash(t *testing.T) {
+// TestLoginThroughServerEntryUsesOffOwnerPath drives the real server entry
+// point (HandleSessionOnOwner) through a WRONG password attempt and a correct
+// login, exercising the off-owner verification path.
+func TestLoginThroughServerEntryUsesOffOwnerPath(t *testing.T) {
h := newHarness(t)
h.seedAccount("alice")
h.seedCharacter("alice", "alice")
- acc, err := h.g.AccountStore.LoadAccount("alice")
- if err != nil {
- t.Fatal(err)
- }
- // Downgrade to a legacy salted SHA-256 hash so the login exercises the
- // transparent rehash.
- salt := []byte("0123456789abcdef")
- sum := sha256.Sum256(append(append([]byte{}, salt...), []byte("pw")...))
- acc.PasswordHash = "sha256:" + base64.RawStdEncoding.EncodeToString(salt) + ":" + strings.ToLower(sha256HashHex(sum))
- if err := h.g.AccountStore.SaveAccount(acc); err != nil {
- t.Fatal(err)
- }
conn := newChanConn()
sess := &net.Session{Conn: conn}
@@ -67,15 +52,12 @@ func TestLoginThroughServerEntryUsesOffOwnerPathAndUpgradesLegacyHash(t *testing
if sess.Account == nil || sess.Account.Name != "alice" || len(sess.Account.Characters) != 1 {
t.Fatalf("login did not complete: %+v", sess.Account)
}
- upgraded, err := h.g.AccountStore.LoadAccount("alice")
+ loaded, err := h.g.AccountStore.LoadAccount("alice")
if err != nil {
t.Fatal(err)
}
- if !strings.HasPrefix(upgraded.PasswordHash, "argon2id:") {
- t.Errorf("legacy hash not upgraded on login: %s", upgraded.PasswordHash[:12])
- }
- if !player.CheckPassword("pw", upgraded.PasswordHash) {
- t.Error("upgraded hash no longer verifies the password")
+ if !player.CheckPassword("pw", loaded.PasswordHash) {
+ t.Error("stored hash no longer verifies the password")
}
}
@@ -111,14 +93,3 @@ func TestNewAccountThroughServerEntryHashesOffOwner(t *testing.T) {
t.Error("created hash does not verify the password")
}
}
-
-// sha256HashHex formats like hex.EncodeToString for the legacy hash check.
-func sha256HashHex(sum [32]byte) string {
- const hexdigits = "0123456789abcdef"
- out := make([]byte, 64)
- for i, b := range sum {
- out[i*2] = hexdigits[b>>4]
- out[i*2+1] = hexdigits[b&0x0f]
- }
- return string(out)
-}