* fix(events): exclude legacy tourism hub sources in events.go * fix(events): exclude legacy tourism hub sources in admin_management.go * test(events): prevent reintroduction of legacy tourism hub entries * chore: bump Landwelle to v1.5.76 * chore: bump Landwelle to v1.5.76 * docs(events): clarify v1.5.76 external-event hardening and server checks * docs(events): clarify v1.5.76 external-event hardening and server checks * docs(events): clarify v1.5.76 external-event hardening and server checks * docs: release notes for Landwelle v1.5.76 * fix(events): escape ILIKE percent signs inside fmt.Sprintf SQL * test(events): normalize escaped SQL wildcards in fmt.Sprintf queries * ci: compare container version to source instead of hardcoding 1.5.75
60 lines
2.2 KiB
Go
60 lines
2.2 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// Even if legacy destination.one rows were accidentally marked editorial,
|
|
// none may enter public event pages, the homepage rotation or the admin list.
|
|
func TestEveryManualEventSQLFilterRejectsLegacyHubSources(t *testing.T) {
|
|
for _, path := range []string{"events.go", "admin_management.go"} {
|
|
data, err := os.ReadFile(path)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
count := 0
|
|
for index, line := range strings.Split(string(data), "\n") {
|
|
if !strings.Contains(line, "source_type IN ('submission','editorial')") {
|
|
continue
|
|
}
|
|
count++
|
|
// fmt.Sprintf queries escape percent signs as %% in Go source.
|
|
normalized := strings.ReplaceAll(line, "%%", "%")
|
|
if !strings.Contains(normalized, "source_name NOT ILIKE '%destination.one%'") ||
|
|
!strings.Contains(normalized, "source_name NOT ILIKE '%Niedersachsen Hub%'") {
|
|
t.Errorf("%s:%d: legacy hub exclusion missing from event filter", path, index+1)
|
|
}
|
|
}
|
|
if count < 2 {
|
|
t.Errorf("%s: expected event filtering in multiple public/admin queries, found %d", path, count)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestHomepageEventsContinueUsingCuratedPublishedStore(t *testing.T) {
|
|
data, err := os.ReadFile("main.go")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
source := string(data)
|
|
if !strings.Contains(source, "events.ListPublished(r.Context(), \"\")") {
|
|
t.Fatal("homepage no longer selects curated published events")
|
|
}
|
|
if !strings.Contains(source, "selectHomepageCalendarEvents(calendarEvents, 3,") {
|
|
t.Fatal("homepage no longer rotates three published events")
|
|
}
|
|
}
|
|
|
|
func TestFormerHubNavigationCleanupMigrationIsPresent(t *testing.T) {
|
|
data, err := os.ReadFile("migrations/0047_only_manual_events_navigation.sql")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !strings.Contains(string(data), "DELETE FROM navigation_items") ||
|
|
!strings.Contains(string(data), "/niedersachsen-entdecken") {
|
|
t.Fatal("old Niedersachsen hub navigation cleanup migration is missing")
|
|
}
|
|
}
|