From 1725425658435b686569c6c66d560ea62d53f6f3 Mon Sep 17 00:00:00 2001 From: davotoula Date: Sun, 13 Sep 2026 09:12:48 +0200 Subject: [PATCH] test(commons): make the vault strict-lookup test pass off macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `strict lookup keeps the strict contract for aliases outside the vault` drove the miss through the macSecurityLookup seam, which getPrivateKeyOrThrow only consults when isMacOs(). On Linux and Windows the strict path is javakeyring, which cannot tell a miss from a denial and deliberately throws, so the test's assertNull failed there — red on the Android job and the Linux/Windows desktop builds of main. Branch on the host like SecureKeyStorageOrThrowTest does: off macOS assert the miss throws SecureStorageException with the PasswordAccessException in its cause chain (coroutine stack-trace recovery may wrap it); on macOS keep the null-on-miss / throw-on-ambiguous assertions. Verified with os.name forced to Linux and natively on macOS (29/29 SecureKeyStorage* tests). --- .../keystorage/SecureKeyStorageVaultTest.kt | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/keystorage/SecureKeyStorageVaultTest.kt b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/keystorage/SecureKeyStorageVaultTest.kt index 54a0b62984..2f759c25a0 100644 --- a/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/keystorage/SecureKeyStorageVaultTest.kt +++ b/commons/src/jvmTest/kotlin/com/vitorpamplona/amethyst/commons/keystorage/SecureKeyStorageVaultTest.kt @@ -417,8 +417,21 @@ class SecureKeyStorageVaultTest { } storage.enableConsolidatedVault(listOf("account-metadata-key")) - // An alias the vault never covered still falls through to the strict probe: - // a confirmed miss is null, an ambiguous answer still throws. + // An alias the vault never covered still falls through to the strict probe. + // Off macOS that probe is javakeyring, which cannot tell a miss from a denial, + // so the strict contract there is to throw on any miss. + if (!System.getProperty("os.name").orEmpty().startsWith("Mac")) { + try { + storage.getPrivateKeyOrThrow("npub1neverseen") + throw AssertionError("Expected SecureStorageException for a non-mac keyring miss") + } catch (e: SecureStorageException) { + // Walk the chain: coroutine stack-trace recovery may wrap the original. + assertTrue(generateSequence(e) { it.cause }.any { it is PasswordAccessException }) + } + return@runBlocking + } + + // On macOS a confirmed miss is null, an ambiguous answer still throws. wireMacProbe(storage, backend) assertNull(storage.getPrivateKeyOrThrow("npub1neverseen"))