summaryrefslogtreecommitdiffstats
path: root/app/src/test/java
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-04 17:37:46 +0100
committerDanilo M. <danix@danix.xyz>2026-11-04 17:37:46 +0100
commit104c07f0bcc37d87ddc371d06827ff93ee3fe504 (patch)
treeba24087c7e778872ba403a3e1744e2ce6e44195e /app/src/test/java
parent35b2c6ab50a7b8e141f88f9ae88570ec43e6fa7b (diff)
downloadHardenedPass-104c07f0bcc37d87ddc371d06827ff93ee3fe504.tar.gz
HardenedPass-104c07f0bcc37d87ddc371d06827ff93ee3fe504.zip
refactor(app): fold BasePGPActivity into the autofill decryption
AutofillDecryptActivity was its last subclass: it now sets FLAG_SECURE and injects the settings, crypto repository and dispatchers itself. The path and clipboard helpers move to CryptoExtensions.kt as top-level functions (a test pins the path helpers), and the FILE_PATH extra key moves, unchanged, to LaunchActivity. An invalid or short .gpg-id ID is reported with a toast: the snackbar never showed in the autofill decryption, which closes its window at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'app/src/test/java')
-rw-r--r--app/src/test/java/app/passwordstore/ui/crypto/CryptoExtensionsTest.kt27
1 files changed, 27 insertions, 0 deletions
diff --git a/app/src/test/java/app/passwordstore/ui/crypto/CryptoExtensionsTest.kt b/app/src/test/java/app/passwordstore/ui/crypto/CryptoExtensionsTest.kt
new file mode 100644
index 00000000..fee6bf72
--- /dev/null
+++ b/app/src/test/java/app/passwordstore/ui/crypto/CryptoExtensionsTest.kt
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+ * SPDX-License-Identifier: GPL-3.0-only
+ */
+
+package app.passwordstore.ui.crypto
+
+import kotlin.test.Test
+import kotlin.test.assertEquals
+
+/** Pins the path helpers' behavior across their move out of BasePGPActivity. */
+class CryptoExtensionsTest {
+
+ @Test
+ fun parentPathIsRelativeToTheStore() {
+ assertEquals("/social/", getParentPath("/store/social/facebook.gpg", "/store"))
+ assertEquals("/", getParentPath("/store/example.org.gpg", "/store"))
+ }
+
+ @Test
+ fun longNameJoinsFolderAndName() {
+ // StoreActions passes absolute folders, PasswordItem its path relative to the store.
+ assertEquals("work/x", getLongName("/store/work", "/store", "x"))
+ assertEquals("social/facebook", getLongName("/social/", "/store", "facebook"))
+ assertEquals("x", getLongName("/store", "/store", "x"))
+ }
+}