Skip to content

Add iOS unit tests for RNSentryIsPathUnderAllowedRoots #6062

@antonis

Description

@antonis

Follow-up from review of #6045.

The Android allowlist validator (RNSentryModuleImpl.isAllowedUri) ships in #6045 with 17 unit tests in RNSentryUriValidationTest. The equivalent iOS function — RNSentryIsPathUnderAllowedRoots in packages/core/ios/RNSentry.mm — has no unit tests in that PR.

The RNSentryCocoaTester workspace exists and is wired into native-tests.yml, so the infrastructure is already in place. What's needed:

  1. Expose the file-scope static BOOL RNSentryIsPathUnderAllowedRoots(NSString *) to tests via a thin Obj-C class-method wrapper on RNSentry, declared in RNSentry+Test.h (matches the existing +captureReplayWithReturnValue pattern).
  2. Add RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryUriValidationTests.m covering:
    • empty path → NO
    • path containing .. component → NO
    • path under NSTemporaryDirectory() → YES
    • path under caches dir → YES
    • path under documents dir → YES
    • path under Library/ (e.g., Library/Cookies) → NO
    • absolute path outside sandbox (/etc/passwd) → NO
    • symlink inside tmp pointing outside the sandbox → NO (uses NSFileManager createSymbolicLinkAtURL in setUp/tearDown)
  3. Wire the new file into RNSentryCocoaTester.xcodeproj (Xcode UI or xcodeproj ruby gem).

Mirrors the Android coverage so both platforms have parity.

Metadata

Metadata

Assignees

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions