Выпуск WDTT Plus v17

This commit is contained in:
Ivan4537 committed 2026-09-04 19:38:52 +03:00
1 parent 4be5f36c88
commit abf0a0f130
33 files changed
+763 -262

No files matched your search

+39
View File
@@ -163,6 +163,45 @@ func TestInitDBPreservesStoredDNSWithoutExplicitOverride(t *testing.T) {
}
}
func TestBotRuntimeCredentialsComeFromProtectedDatabaseAfterUpdate(t *testing.T) {
oldDB, oldDBFile := db, dbFile
t.Cleanup(func() {
db, dbFile = oldDB, oldDBFile
})
dir := t.TempDir()
stored := testDatabase("owner-secret", 0)
stored.BotToken = "stored-bot-token"
stored.AdminID = "123456"
if err := persistDatabaseFile(filepath.Join(dir, "passwords.json"), stored); err != nil {
t.Fatal(err)
}
// Version 16+ starts without secret command-line flags. The already stored
// values must still activate the internal bot after the service restarts.
if err := initDB(dir, "", "", "", ""); err != nil {
t.Fatalf("restart with stored bot credentials failed: %v", err)
}
token, adminID := botRuntimeCredentials()
if token != "stored-bot-token" || adminID != "123456" {
t.Fatalf("stored bot credentials were not selected: token=%t admin=%q", token != "", adminID)
}
}
func TestBotRuntimeCredentialsUseExplicitFirstInstallValues(t *testing.T) {
oldDB, oldDBFile := db, dbFile
t.Cleanup(func() {
db, dbFile = oldDB, oldDBFile
})
dir := t.TempDir()
if err := initDB(dir, "owner-secret", "654321", "first-install-token", ""); err != nil {
t.Fatalf("first install failed: %v", err)
}
token, adminID := botRuntimeCredentials()
if token != "first-install-token" || adminID != "654321" {
t.Fatalf("first-install bot credentials were not selected: token=%t admin=%q", token != "", adminID)
}
}
func TestInitDBValidatesExplicitDNSOverride(t *testing.T) {
oldDB, oldDBFile := db, dbFile
t.Cleanup(func() {