Cockatrice/tests
BruebachL ad0fd2d4b0
[CrashReporting] Sentry send path with consent gating (#7522)
* [CrashReporting] Real send path with consent gating (DSN still placeholder)

require_user_consent + give/revoke around the Ask dialog, message event
with in-memory crash-log.txt bytes attachment, before_send scrubs
message/logentry/breadcrumbs/data of cockatrice:// secrets. Failure box
offers Save (shows path) / Discard (revokes + rejects) / Cancel (back
to dialog); reject() override so X/Escape cannot bypass revocation;
silent AlwaysSend path falls back to a local file. Empty DSN keeps the
previous mock behavior byte-identical.

Tests: 528/528 ctest green, format clean, code + UI gates PASS.

* [CrashReporting] Attach crash log and user note to the pending crash event

The redacted log used to ride a separate message event from the native
crash (minidump + stack), forcing manual correlation in Sentry. Fold it
into the pending crash envelope(s) instead by appending well-formed
attachment items before consent releases them: sentry-native replays
cached envelopes byte-for-byte (raw read, raw serialize in 0.17.3), so
the appended crash-log.txt and user-note.txt items upload with the very
event that already carries the dump and stack.

Covers both storage locations: Ask mode's consent-held files in
<database>/cache and AlwaysSend's transport-dumped files in
<database>/<run>.run, which must be attached before sentry_init replays
them. When no pending crash event exists (unclean exit without a native
crash) the standalone message event remains as fallback, now also
carrying the optional note.

The dialog gains an optional free-text field ('Here's what I was
doing...') that travels as user-note.txt; the mock JSON records it too.

* [CrashReporting] Send PROJECT_VERSION as the Sentry release

main() reported VERSION_STRING (PROJECT_VERSION_FRIENDLY) as the Sentry
release — that carries a build date, so every build of the same version
landed in its own release, and it never matched the installer, which
reports CPACK/PROJECT_VERSION. Bake COCKATRICE_SENTRY_RELEASE=
PROJECT_VERSION instead: date-free, identical between client and
installer, and derived from the git tag on tag builds, so events,
symbol uploads and the installer log all group under one release.

* [CrashReporting] Friendlier crash dialog copy

Reword the report dialog along a single friendly arc: headline ('Oops,
we crashed — and now we need your help to make Cockatrice better!'),
why helping is easy, exactly what gets collected (crash dump with stack
trace, app version, OS info, redacted log excerpt), the value of each
report ('better and less crashy for everyone'), and the consent choice
('Send and remember makes this automatic without interruption in the
future'). The checkbox itself stays direction-neutral ('Remember my
choice') because it also persists a 'Don't send' decision.

* [CrashReporting] Log where crash reports go and warn when they cannot

The client resolved COCKATRICE_SENTRY_DSN (environment over the baked-in
value) without ever saying which one won, and sentry-native refuses to build
a request for a DSN it considers invalid without reporting anything, so a
tester pointing the client at a scratch project had nothing to go on when a
crash never appeared.

Say which DSN source won, and log the destination (host and project id, never
the key) once the SDK is armed. Warn instead of staying quiet when no DSN is
configured at all, when a DSN is malformed - disabling reporting rather than
silently falling back to the project baked into the build, which is the rule
the installer already follows in cmake/CrashReporting.cmake - and when the
build was compiled without Sentry support. A deliberate Never-send stays at
info level: that is a choice, not a misconfiguration.

Also warn when a pending crash envelope was captured for a different
destination than the session that will upload it. sentry-native posts every
envelope with the DSN held in the transport state of the session doing the
sending, and envelopes restored from disk are raw, so the "dsn" header of a
cached envelope is never read: a crash captured for one project can be
uploaded to another with nothing in the log to show it.

Tests cover the DSN shape check (same unanchored pattern the build matches, so
a DSN this build accepted is never rejected here), destination description
without the key, and the mismatch detection, which stays quiet for a different
key on the same project, unreadable files, and headers without a dsn.

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
2026-10-19 14:57:03 +02:00
..
card_zone_algorithms [Tests] Register each test case with CTest instead of each test binary (#7399) 2026-10-11 14:50:09 +02:00
carddatabase [CardDB] Reload after the first run enables all sets without freezing startup (#7470) 2026-10-13 06:29:16 +02:00
deck_list_model [Tests] Register each test case with CTest instead of each test binary (#7399) 2026-10-11 14:50:09 +02:00
deck_list_zones [Tests] Register each test case with CTest instead of each test binary (#7399) 2026-10-11 14:50:09 +02:00
loading_from_clipboard Support tab-separated deck imports (#4222) (#7267) 2026-10-11 21:19:10 +02:00
movecard_tests [Tests] Register each test case with CTest instead of each test binary (#7399) 2026-10-11 14:50:09 +02:00
oracle [CI] Publish a gcovr line-coverage report from the test run (#7404) 2026-10-11 15:05:28 +02:00
picture_loader_benchmark [Tests] Register each test case with CTest instead of each test binary (#7399) 2026-10-11 14:50:09 +02:00
settings [CrashReporting] Mock crash-report dialog and reporting preference (#7521) 2026-10-19 14:57:03 +02:00
theme_migration [Tests] Register each test case with CTest instead of each test binary (#7399) 2026-10-11 14:50:09 +02:00
card_update_progress_test.cpp [Client] Improve card database update visibility (#7458) 2026-10-09 11:07:48 +02:00
clamped_arithmetic_test.cpp [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
CMakeLists.txt [CrashReporting] Mock crash-report dialog and reporting preference (#7521) 2026-10-19 14:57:03 +02:00
crash_reporter_test.cpp [CrashReporting] Sentry send path with consent gating (#7522) 2026-10-19 14:57:03 +02:00
deck_hash_performance_test.cpp [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
expression_test.cpp [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
forwarded_address_test.cpp [Server] Parse the rightmost address from forwarded header lists (#7586) 2026-10-18 16:53:55 -04:00
lag_monitor_test.cpp [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
latency_tracker_test.cpp [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
loader_local_matching_test.cpp [Tests] Scope loader matcher settings to the process to fix parallel-run flakes (#7504) 2026-10-15 12:21:40 +02:00
metrics_registry_test.cpp [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
password_hash_test.cpp [Security] Add challenge-response auth with scrypt verifiers and stop storing plaintext passwords (#7193) 2026-10-16 22:52:26 +02:00
playmat_resolver_test.cpp [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
rate_limiter_test.cpp [Server] Inform client of login/registration rate limit timeout (#7468) 2026-10-16 05:47:43 +02:00
report_categories_test.cpp [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
server_card_counter_test.cpp [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
server_counter_test.cpp [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
server_developer_role_test.cpp [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
server_dump_zone_test.cpp [Server] Resolve a zone dump request to an in-range index span (#7401) 2026-10-13 11:23:13 +02:00
server_game_join_test.cpp [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
server_moderator_role_test.cpp [Report] Add report reopen action for closed reports (#7442) 2026-10-11 15:28:45 +02:00
server_rate_limiter_test.cpp [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
server_room_channels_test.cpp [Servatrice] Log room channel messages in audit log (#7479) 2026-10-16 22:46:39 +02:00
single_instance_manager_test.cpp [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
test_age_formatting.cpp [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
translation_loader_test.cpp [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00
translation_loader_test.ts [Translations] Load Qt's own translations and build ours with the binary (#7384) 2026-10-03 15:04:30 +02:00
trusted_sources_test.cpp [Servatrice] Match trusted_sources by address, not substring (#7582) 2026-10-18 16:50:04 -04:00
user_data_backup_test.cpp [Installer][Client] Back up user data before old uninstallers can delete it (#7503) 2026-10-16 22:05:42 +02:00
warning_categories_test.cpp [Tooling] Apply include-what-you-use across the tree (#7396) 2026-10-08 11:13:50 +02:00