Files
bbs/internal/store/ymsg_test.go
T
Claude 0342ad6414 Add a Yahoo! Messenger server (YMSG 9 to 16)
Yahoo! Messenger clients sign in with BBS names and passwords on port
5050. The buddy list is the friends list and the ignore list the shared
blocked list; IMs are private messages to and from every route, kept for
one away and delivered at sign-in; Yahoo chat rooms are the BBS's chat
rooms and conferences are rooms of their own.

- internal/ymsg: the pager (VERIFY, AUTH/AUTHRESP, LIST and LIST_15,
  LOGON/LOGOFF/ISAWAY/ISBACK/STATUS_15 presence, MESSAGE, typing,
  ADDBUDDY/REMBUDDY/GROUPRENAME/CHGRP_15, IGNORECONTACT, chat rooms,
  conferences) and the web half (capacity, pwtoken_get/pwtoken_login for
  the YMSG 16 login over HTTPS with TLS 1.0 for XP, the room list)
- store: ymsg_keys (the challenge login's two digests, kept like AIM's
  and MSN's), MD5Crypt and Yahoo's base 64
- bbs: PublicRooms, for the room browser
- [ymsg] config section, docs/wiki/Yahoo-Messenger.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRRfVskEUYFs9gMFCLD
2026-11-09 05:21:26 +00:00

48 lines
1.3 KiB
Go

package store
import (
"path/filepath"
"testing"
)
// TestYMSGKeys: the digests' forms, kept only when asked, stale once the
// password changes.
func TestYMSGKeys(t *testing.T) {
// openssl passwd -1 -salt _2S43d5f password
if got := MD5Crypt("password", "_2S43d5f"); got != "$1$_2S43d5f$Cb/MEl/9lyqcT5fwKLPnX0" {
t.Errorf("md5crypt: %s", got)
}
if got := Y64([]byte{0xfb, 0xff, 0x01}); got != "._8B" {
t.Errorf("y64: %s", got)
}
if got := Y64([]byte{0xff}); got != "_w--" {
t.Errorf("y64 padding: %s", got)
}
BcryptCost = 4
s, err := Open(filepath.Join(t.TempDir(), "bbs.db"))
if err != nil {
t.Fatal(err)
}
defer s.Close()
u, _ := s.CreateUser("alice", "password1", "", false)
if _, ok, _ := s.YMSGKeys(u.ID); ok {
t.Fatal("kept without SetKeepYMSG")
}
s.SetKeepYMSG(true)
if _, err := s.CheckPassword("alice", "password1"); err != nil {
t.Fatal(err)
}
k, ok, err := s.YMSGKeys(u.ID)
if err != nil || !ok || k != YMSGDigests("password1") {
t.Fatalf("keys %+v %v %v", k, ok, err)
}
s.db.Exec(`UPDATE users SET password = ? WHERE id = ?`, "x", u.ID)
if _, ok, _ := s.YMSGKeys(u.ID); ok {
t.Error("stale digests used")
}
s.SetPassword(u.ID, "password2")
if k, ok, _ := s.YMSGKeys(u.ID); !ok || k != YMSGDigests("password2") {
t.Errorf("after set: %+v %v", k, ok)
}
}