Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : Immo-Ka Admin iOS9// File : ImmoKaAdminUITests/PasskeyObservationTests.swift10// Description : observation du flux de clé d'accès sur simulateur, contre11// la production (lecture d'un défi de connexion seulement,12// aucune écriture) : toucher « Se connecter avec une clé13// d'accès », attendre la feuille du système, noter ce qui14// s'affiche, puis refermer. Aucune clé n'existe sur le15// simulateur : le test ne peut pas aller plus loin. Ce qu'il16// observe est joint au résultat.17// Module : ImmoKaAdminUITests18// Repository : https://git.spboucher.ai/immo-ka-admin-ios19// Project Website : https://www.immo-ka.com20// Created : 2026-11-3021// Last Modified : 2026-11-3022//23// =============================================================================24// AUTHOR & PROFESSIONAL AFFILIATION25// =============================================================================26//27// Author : Simon-Pierre Boucher28// Position : Professor of Finance29// Institution : Université du Québec en Outaouais (UQO)30// Department : Département des sciences administratives31// Organization : SP Boucher32//33// Website : https://spboucher.ai34// Git : https://git.spboucher.ai35//36// =============================================================================37// OFFICIAL CONTACT DIRECTORY38// =============================================================================39//40// General : info@spboucher.ai41// Professional : contact@spboucher.ai42// Direct : simon@spboucher.ai43// Research : research@spboucher.ai44// Development : dev@spboucher.ai45// Support : support@spboucher.ai46// Security/Admin : admin@spboucher.ai47// Notifications : notifications@spboucher.ai48//49// Preferred Contact: support@spboucher.ai50//51// =============================================================================52// COPYRIGHT & INTELLECTUAL PROPERTY53// =============================================================================54//55// Copyright (c) 202656// Simon-Pierre Boucher57//58// All rights reserved where applicable.59//60// This file is governed by the applicable project license,61// copyright notices, institutional agreements and relevant law.62//63// Unless expressly authorized by the applicable license or64// rights holder, copying, redistribution, sublicensing,65// publication and commercial exploitation are not permitted.66//67// Existing third-party rights and notices remain unaffected.68//69// =============================================================================70// CONFIDENTIALITY & SECURITY71// =============================================================================72//73// Classification : Public74// Distribution : Public repository; use is governed by the project license75// Security Contact : admin@spboucher.ai76//77// Access to this source does not independently grant permission78// to redistribute or disclose confidential materials.79//80// Do not embed credentials, private keys, access tokens,81// certificates or confidential personal information.82//83// =============================================================================84// LICENSE & MAINTENANCE85// =============================================================================86//87// License : None specified (no license file in this repository)88// Maintainer : Simon-Pierre Boucher89// Technical Contact: dev@spboucher.ai90//91// =============================================================================92// END OF SP BOUCHER SOURCE HEADER93// =============================================================================9495import XCTest9697final class PasskeyObservationTests: XCTestCase {98 func testPasskeyRequestReachesSystemSheet() {99 let app = XCUIApplication()100 app.launchArguments = ["-AppleLanguages", "(fr-CA)", "-appearance", "light"]101 app.launch()102 let button = app.buttons["login.passkey"]103 XCTAssertTrue(button.waitForExistence(timeout: 20))104 button.tap()105 sleep(8)106 let shot = XCTAttachment(screenshot: XCUIScreen.main.screenshot())107 shot.name = "cle-acces-apres-toucher"; shot.lifetime = .keepAlways108 add(shot)109 // ce que montrent l'app et le système à cet instant110 let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")111 var seen: [String] = []112 for host in [app, springboard] {113 // libellés lus dans l'arbre d'accessibilité, en une seule photographie par processus114 let tree = host.debugDescription115 for m in try! NSRegularExpression(pattern: "label: '([^']+)'").matches(in: tree, range: NSRange(tree.startIndex..., in: tree)) {116 if let r = Range(m.range(at: 1), in: tree) { let l = String(tree[r]); if !seen.contains(l) { seen.append(l) } }117 }118 }119 let note = XCTAttachment(string: seen.joined(separator: "\n"))120 note.name = "cle-acces-textes-visibles"; note.lifetime = .keepAlways121 add(note)122 print("OBSERVATION-CLE-ACCES: " + seen.joined(separator: " | "))123 let appError = app.descendants(matching: .any).matching(identifier: "error.banner").firstMatch124 // iOS, en français, appelle une clé d'accès « clé d'identification »125 let systemSheet = seen.contains { let t = $0.lowercased(); return t.contains("clé d’identification") || t.contains("clé d'identification") || t.contains("passkey") || t.contains("bluetooth") || t.contains("code qr") }126 XCTAssertTrue(systemSheet || appError.exists, "après le toucher, iOS présente sa feuille de clé d'accès, ou l'app affiche l'erreur rendue par iOS")127 // refermer la feuille si elle est là, puis lire le message de l'app128 for label in ["Retour", "Fermer", "Annuler", "Close", "Cancel"] {129 for host in [app, springboard] {130 let b = host.buttons[label].firstMatch131 if b.exists, b.isHittable { b.tap(); sleep(2) }132 }133 }134 sleep(2)135 let after = XCTAttachment(screenshot: XCUIScreen.main.screenshot())136 after.name = "cle-acces-apres-fermeture"; after.lifetime = .keepAlways137 add(after)138 if appError.exists { print("OBSERVATION-CLE-ACCES-MESSAGE: " + appError.label) }139 XCTAssertTrue(app.buttons["login.passkey"].waitForExistence(timeout: 10), "l'app revient à l'écran de connexion, utilisable")140 }141}142