hub 0.164.0 (unreleased): bind mail true when no box exists (W3), tries left on a wrong try (W4), use the newer mail hint (W5)
gates / gates (push) Failing after 14m55s
gates / gates (push) Failing after 14m55s
This commit is contained in:
1 parent
3c620f8d2e
commit
f90e22293a
7 files changed
+74
-8
No files matched your search
@@ -0,0 +1,41 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"gitea.dooplex.hu/admin/felhom-hub/internal/store"
|
||||
)
|
||||
|
||||
// W4 (rehearsal word table, night 2026-10-21): a wrong try says how many tries are left before the link locks — the
|
||||
// fifth locks it and only support can open it. The count is the same for a wrong code and a wrong passphrase, so the
|
||||
// no-oracle rule (TestSelfBind_B_NoOracle) holds.
|
||||
// RED-PROOF: with AttemptsLeft not set on the failure render the „Még N" sentence is missing → fails at attempt 1.
|
||||
func TestW4_AWrongTrySaysHowManyTriesAreLeft(t *testing.T) {
|
||||
s, st := newTestServer(t)
|
||||
selfBindSetup(t, st, "acme", testCode)
|
||||
token := mintLink(t, st, "acme", selfBindTTL)
|
||||
for i := 1; i < store.SelfBindMaxAttempts; i++ {
|
||||
body := bindPOST(t, s, token, "ZZZ999", "definitely wrong words indeed").Body.String()
|
||||
want := fmt.Sprintf("Még %d próbálkozásod van", store.SelfBindMaxAttempts-i)
|
||||
if !strings.Contains(body, want) {
|
||||
t.Fatalf("attempt %d: the page must say %q", i, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// W5: on a used or expired link the page says to use the newer mail before „Új linket kérek" (a new link kills the
|
||||
// one the household may be about to use — TestSelfBind_C4_SingleActive).
|
||||
func TestW5_AnOldLinkPointsToTheNewerMail(t *testing.T) {
|
||||
s, st := newTestServer(t)
|
||||
selfBindSetup(t, st, "acme", testCode)
|
||||
token := mintLink(t, st, "acme", -1) // already expired
|
||||
body := bindGET(t, s, token).Body.String()
|
||||
if !strings.Contains(body, "újabb leveled") || !strings.Contains(body, "Új linket kérek") {
|
||||
t.Fatalf("an expired link must point to the newer mail above the button: %q", body)
|
||||
}
|
||||
if strings.Index(body, "újabb leveled") > strings.Index(body, "Új linket kérek") {
|
||||
t.Fatal("the newer-mail hint must come BEFORE the button")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user