package password_test import ( "context" "strings" "testing" "gitflic.ru/akselbant/mtusi2026lab1-fork/internal/pkg/password" ) func TestUnicodeAndSalt(t *testing.T) { ctx := context.Background() secret := strings.Repeat("🔑", 128) first, err := password.Hash(ctx, secret) if err != nil { t.Fatal(err) } second, err := password.Hash(ctx, secret) if err != nil { t.Fatal(err) } if first == second { t.Fatal("password hashes reused salt") } for _, hash := range []string{first, second} { ok, err := password.Verify(ctx, secret, hash) if err != nil || !ok { t.Fatal("128-code-point UTF-8 password rejected") } ok, err = password.Verify(ctx, strings.Repeat("🔑", 127)+"x", hash) if err != nil || ok { t.Fatal("password suffix was ignored") } } }