apple_kit

Apple-native services for Radroots iOS and macOS apps
git clone https://radroots.dev/git/apple_kit.git
Log | Files | Refs | README

RadrootsUserPresenceTests.swift (1150B)


      1 import Foundation
      2 import Testing
      3 import RadrootsKit
      4 
      5 @Test func userPresenceRequestNormalizesReason() throws {
      6     let request = try RadrootsUserPresenceRequest(
      7         policy: .deviceOwnerAuthenticationWithBiometrics,
      8         reason: "  Unlock local Nostr identity  "
      9     )
     10 
     11     #expect(request.policy == .deviceOwnerAuthenticationWithBiometrics)
     12     #expect(request.reason == "Unlock local Nostr identity")
     13 }
     14 
     15 @Test func userPresenceRequestRejectsBlankReason() {
     16     #expect(throws: RadrootsUserPresenceError.self) {
     17         _ = try RadrootsUserPresenceRequest(reason: " \n ")
     18     }
     19 }
     20 
     21 @Test func userPresenceStatusCanRepresentUnavailableDevices() {
     22     #expect(RadrootsUserPresenceStatus.unavailable.support == .none)
     23     #expect(RadrootsUserPresenceStatus.unavailable.biometryKind == .none)
     24     #expect(!RadrootsUserPresenceStatus.unavailable.canEvaluateDeviceCredential)
     25     #expect(!RadrootsUserPresenceStatus.unavailable.canEvaluateBiometrics)
     26 }
     27 
     28 @Test func userPresenceErrorsExposeLocalizedMessages() {
     29     let error = RadrootsUserPresenceError.permissionDenied("presence denied")
     30 
     31     #expect(error.errorDescription == "presence denied")
     32 }