Files
buzz/mobile/ios/BuzzPushKit/Tests/BuzzPushKitTests/BuzzAgeSignalPayloadTests.swift
Tom Brow 779af8886c fix(mobile): fail open when age checks are unavailable (#7714)
Age-check errors previously blocked Buzz startup. Normal app startup now
proceeds immediately; only a valid under-18 response from the current
launch request can restrict access.

Age check enforcement remains disabled at compile time by default.
Builds can opt in with `--dart-define=BUZZ_AGE_GATING_ENABLED=true`.

---------

Signed-off-by: Tom Brow <tomb@block.xyz>
2026-09-17 16:44:08 -07:00

29 lines
1.1 KiB
Swift

import Foundation
import Testing
@testable import BuzzPushKit
struct BuzzAgeSignalPayloadTests {
@Test func `Apple under 18 gate produces a restricted inclusive age`() {
let payload = BuzzAgeSignalPayload.sharing(exclusiveUpperBound: 18)
#expect(payload["status"] as? String == "signal")
#expect(payload["ageUpper"] as? Int == 17)
}
@Test func `Apple unbounded adult range stays unbounded`() {
let payload = BuzzAgeSignalPayload.sharing(exclusiveUpperBound: nil)
#expect(payload["status"] as? String == "signal")
#expect(payload["ageUpper"] is NSNull)
}
@Test(arguments: [Int.min, -1, 0, 1, 17, 19, Int.max])
func unexpectedAppleBoundsAreNotRestrictionEvidence(upper: Int) {
let payload = BuzzAgeSignalPayload.sharing(exclusiveUpperBound: upper)
#expect(payload["ageUpper"] is NSNull)
}
@Test(arguments: [Int.min, -1, 18, 19, Int.max])
func contradictoryAppleRangeIsNotRestrictionEvidence(lower: Int) {
let payload = BuzzAgeSignalPayload.sharing(exclusiveUpperBound: 18, lowerBound: lower)
#expect(payload["ageUpper"] is NSNull)
}
}