|
3 | 3 | #include "sentry_envelope.h" |
4 | 4 | #include "sentry_options.h" |
5 | 5 | #include "sentry_path.h" |
6 | | -#include "sentry_string.h" |
| 6 | +#include "sentry_retry.h" |
7 | 7 | #include "sentry_testsupport.h" |
8 | 8 | #include "sentry_uuid.h" |
9 | 9 | #include "sentry_value.h" |
@@ -310,6 +310,83 @@ SENTRY_TEST(cache_max_items_with_retry) |
310 | 310 | sentry_close(); |
311 | 311 | } |
312 | 312 |
|
| 313 | +SENTRY_TEST(cache_consent_revoked) |
| 314 | +{ |
| 315 | +#if defined(SENTRY_PLATFORM_NX) || defined(SENTRY_PLATFORM_PS) |
| 316 | + SKIP_TEST(); |
| 317 | +#endif |
| 318 | + SENTRY_TEST_OPTIONS_NEW(options); |
| 319 | + sentry_options_set_dsn(options, "https://foo@sentry.invalid/42"); |
| 320 | + sentry_options_set_cache_keep(options, true); |
| 321 | + sentry_options_set_require_user_consent(options, true); |
| 322 | + sentry_init(options); |
| 323 | + sentry_user_consent_revoke(); |
| 324 | + |
| 325 | + sentry_path_t *cache_path |
| 326 | + = sentry__path_join_str(options->database_path, "cache"); |
| 327 | + TEST_ASSERT(!!cache_path); |
| 328 | + sentry__path_remove_all(cache_path); |
| 329 | + |
| 330 | + sentry_capture_event( |
| 331 | + sentry_value_new_message_event(SENTRY_LEVEL_INFO, "test", "revoked")); |
| 332 | + |
| 333 | + int count = 0; |
| 334 | + bool is_retry_format = false; |
| 335 | + sentry_pathiter_t *iter = sentry__path_iter_directory(cache_path); |
| 336 | + const sentry_path_t *entry; |
| 337 | + while (iter && (entry = sentry__pathiter_next(iter)) != NULL) { |
| 338 | + if (sentry__path_ends_with(entry, ".envelope")) { |
| 339 | + count++; |
| 340 | + uint64_t ts; |
| 341 | + int attempt; |
| 342 | + const char *uuid; |
| 343 | + is_retry_format = sentry__parse_cache_filename( |
| 344 | + sentry__path_filename(entry), &ts, &attempt, &uuid); |
| 345 | + } |
| 346 | + } |
| 347 | + sentry__pathiter_free(iter); |
| 348 | + TEST_CHECK_INT_EQUAL(count, 1); |
| 349 | + TEST_CHECK(is_retry_format); |
| 350 | + |
| 351 | + sentry__path_free(cache_path); |
| 352 | + sentry_close(); |
| 353 | +} |
| 354 | + |
| 355 | +SENTRY_TEST(cache_consent_revoked_nocache) |
| 356 | +{ |
| 357 | +#if defined(SENTRY_PLATFORM_NX) || defined(SENTRY_PLATFORM_PS) |
| 358 | + SKIP_TEST(); |
| 359 | +#endif |
| 360 | + SENTRY_TEST_OPTIONS_NEW(options); |
| 361 | + sentry_options_set_dsn(options, "https://foo@sentry.invalid/42"); |
| 362 | + sentry_options_set_cache_keep(options, false); |
| 363 | + sentry_options_set_require_user_consent(options, true); |
| 364 | + sentry_init(options); |
| 365 | + sentry_user_consent_revoke(); |
| 366 | + |
| 367 | + sentry_path_t *cache_path |
| 368 | + = sentry__path_join_str(options->database_path, "cache"); |
| 369 | + TEST_ASSERT(!!cache_path); |
| 370 | + sentry__path_remove_all(cache_path); |
| 371 | + |
| 372 | + sentry_capture_event( |
| 373 | + sentry_value_new_message_event(SENTRY_LEVEL_INFO, "test", "revoked")); |
| 374 | + |
| 375 | + int count = 0; |
| 376 | + sentry_pathiter_t *iter = sentry__path_iter_directory(cache_path); |
| 377 | + const sentry_path_t *entry; |
| 378 | + while (iter && (entry = sentry__pathiter_next(iter)) != NULL) { |
| 379 | + if (sentry__path_ends_with(entry, ".envelope")) { |
| 380 | + count++; |
| 381 | + } |
| 382 | + } |
| 383 | + sentry__pathiter_free(iter); |
| 384 | + TEST_CHECK_INT_EQUAL(count, 0); |
| 385 | + |
| 386 | + sentry__path_free(cache_path); |
| 387 | + sentry_close(); |
| 388 | +} |
| 389 | + |
313 | 390 | SENTRY_TEST(cache_max_size_and_age) |
314 | 391 | { |
315 | 392 | #if defined(SENTRY_PLATFORM_NX) || defined(SENTRY_PLATFORM_PS) |
|
0 commit comments