1.7.0: Mitmachen im Squad ohne Konto
Der Squad-Reiter braucht kein Konto mehr: Spielername eingeben, der PC
bekommt einen Schluessel (Token ohne Ablauf), die Akten werden fuer alle
sichtbar. E-Mail und Passwort sind optional ("Konto sichern") und machen
die Charaktere reset- und mehr-PC-fest. Ohne gesichertes Konto bietet das
Menue kein Abmelden, weil das den Schluessel loeschte.
Server: Aktionen mitmachen und konto_sichern, Konten ohne E-Mail
(Datenbank-Stand 2, eingespielt von DB::migrieren() bei der ersten
Anfrage), Loeschen ohne Passwort fuer reine Schluessel-Konten, Verwaltung
zeigt sie als "nur Schluessel". Deinstallationsfrage nennt den Schluessel.
Tests: Server 108, Zwei-PC 34, Oberflaeche 24 - auch gegen das Paket.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
c175e42546
commit
a5da53d373
14 changed files with 491 additions and 121 deletions
|
|
@ -262,6 +262,16 @@ def ablauf(s):
|
|||
code, html, _ = s.roh(urllib.parse.urlparse(erster_link).path + "?" + urllib.parse.urlparse(erster_link).query)
|
||||
pruefe("erster Link damit ungültig", "ungültig" in html.decode())
|
||||
|
||||
import sqlite3
|
||||
datenbank = sqlite3.connect(s.ordner / "sva-privat" / "test.sqlite")
|
||||
datenbank.execute("UPDATE sm_meta SET wert = '1' WHERE schluessel = 'schema'")
|
||||
datenbank.commit()
|
||||
(s.daten / "schema-2.ok").unlink()
|
||||
s.api("status")
|
||||
stand = datenbank.execute("SELECT wert FROM sm_meta WHERE schluessel = 'schema'").fetchone()[0]
|
||||
pruefe("Datenbank-Update läuft bei der ersten Anfrage", stand == "2" and (s.daten / "schema-2.ok").exists(), stand)
|
||||
datenbank.close()
|
||||
|
||||
print("Schnittstelle allgemein")
|
||||
code, antwort = s.api("status")
|
||||
pruefe("status", code == 200 and antwort.get("api") == 1, antwort)
|
||||
|
|
@ -442,6 +452,52 @@ def ablauf(s):
|
|||
alice = antwort.get("token")
|
||||
pruefe("Anmeldung mit neuem Passwort", bool(alice), antwort)
|
||||
|
||||
print("Mitmachen ohne Konto")
|
||||
code, antwort = s.api("mitmachen", spielername="x")
|
||||
pruefe("Spielername zu kurz", antwort.get("fehler") == "benutzername_ungueltig", antwort)
|
||||
code, antwort = s.api("mitmachen", spielername="Kiwi", geraet="PC-Kiwi")
|
||||
kiwi, kiwi_nutzer = antwort.get("token"), antwort.get("nutzer", {})
|
||||
pruefe("mitgemacht: Schlüssel ohne E-Mail",
|
||||
kiwi and kiwi_nutzer.get("gesichert") is False and kiwi_nutzer.get("email") is None, antwort)
|
||||
code, antwort = s.api("mitmachen", spielername="kiwi")
|
||||
pruefe("Spielername doppelt (Groß/klein egal)", antwort.get("fehler") == "benutzername_vergeben", antwort)
|
||||
code, antwort = s.api("mitmachen", spielername="Alice")
|
||||
pruefe("Name eines E-Mail-Kontos ist auch vergeben", antwort.get("fehler") == "benutzername_vergeben", antwort)
|
||||
kiwi_akte = "f" * 32
|
||||
code, antwort = s.api("charakter_speichern", token=kiwi, lokale_id=kiwi_akte,
|
||||
daten=akte(kiwi_akte, "Kiwi-1", "Tane"))
|
||||
pruefe("mit Schlüssel Akte speichern", code == 200, antwort)
|
||||
code, antwort = s.api("charaktere_alle", token=alice)
|
||||
pruefe("andere sehen den Charakter mit Spielernamen",
|
||||
any(c["callsign"] == "Kiwi-1" and c["spieler"] == "Kiwi" for c in antwort.get("charaktere", [])), antwort)
|
||||
code, antwort = s.api("anmelden", login="Kiwi", passwort="irgendwas123")
|
||||
pruefe("ohne gesichertes Konto keine Passwort-Anmeldung", antwort.get("fehler") == "anmeldung_falsch", antwort)
|
||||
code, antwort = s.api("konto_sichern", token=kiwi, email="alice@example.org", passwort="kiwipasswort1")
|
||||
pruefe("Sichern mit vergebener E-Mail abgewiesen", antwort.get("fehler") == "email_vergeben", antwort)
|
||||
code, antwort = s.api("konto_sichern", token=kiwi, email="Kiwi@Example.org", passwort="kiwipasswort1")
|
||||
pruefe("Konto gesichert, noch unbestätigt",
|
||||
antwort.get("nutzer", {}).get("gesichert") is True and antwort["nutzer"]["bestaetigt"] is False, antwort)
|
||||
code, antwort = s.api("konto_sichern", token=kiwi, email="kiwi2@example.org", passwort="kiwipasswort1")
|
||||
pruefe("zweimal sichern geht nicht", antwort.get("fehler") == "schon_gesichert", antwort)
|
||||
code, antwort = s.api("ich", token=kiwi)
|
||||
pruefe("Schlüssel gilt nach dem Sichern weiter", code == 200, antwort)
|
||||
teile = urllib.parse.urlparse(s.link_aus_mail("kiwi@example.org"))
|
||||
s.roh(teile.path + "?" + teile.query)
|
||||
code, antwort = s.api("anmelden", login="kiwi@example.org", passwort="kiwipasswort1")
|
||||
zweiter_pc = antwort.get("token")
|
||||
pruefe("zweiter PC: Anmeldung mit E-Mail, gleiches Konto",
|
||||
zweiter_pc and antwort["nutzer"]["id"] == kiwi_nutzer.get("id"), antwort)
|
||||
code, antwort = s.api("charaktere_eigene", token=zweiter_pc)
|
||||
pruefe("zweiter PC sieht die Akte", [c["lokale_id"] for c in antwort.get("charaktere", [])] == [kiwi_akte], antwort)
|
||||
code, antwort = s.api("mitmachen", spielername="Einweg")
|
||||
einweg = antwort.get("token")
|
||||
code, antwort = s.api("konto_loeschen", token=einweg, passwort="")
|
||||
pruefe("Konto nur mit Schlüssel ohne Passwort löschbar", code == 200, antwort)
|
||||
code, antwort = s.api("ich", token=einweg)
|
||||
pruefe("Schlüssel danach ungültig", code == 401, antwort)
|
||||
code, antwort = s.api("mitmachen", spielername="Stumm")
|
||||
pruefe("weiteres Mitmachen", bool(antwort.get("token")), antwort)
|
||||
|
||||
print("Verwaltung")
|
||||
jar = http.cookiejar.CookieJar()
|
||||
oeffner = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(jar))
|
||||
|
|
@ -465,7 +521,7 @@ def ablauf(s):
|
|||
code, html, _ = s.roh("/verwaltung/", {"aktion": "anmelden", "email": "info@tyrveil.com",
|
||||
"passwort": "adminpasswort99", "csrf": csrf(html)}, oeffner=oeffner)
|
||||
pruefe("Admin angemeldet, Übersicht", code == 200 and "Offene Einladungen" in html.decode(), html[-300:])
|
||||
for seite, erwartet in (("nutzer", "alice@example.org"), ("charaktere", "Nordlicht"), ("squads", "Squads"),
|
||||
for seite, erwartet in (("nutzer", "nur Schlüssel"), ("charaktere", "Nordlicht"), ("squads", "Squads"),
|
||||
(f"charakter&id={nordlicht['id']}", "ROHDATEN")):
|
||||
code, html, _ = s.roh(f"/verwaltung/?seite={seite}", oeffner=oeffner)
|
||||
pruefe(f"Seite {seite.split('&')[0]}", code == 200 and erwartet in html.decode(), code)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue