diff --git a/apps/browser-extension/src/entrypoints/contentScript/__tests__/Filter.test.ts b/apps/browser-extension/src/entrypoints/contentScript/__tests__/Filter.test.ts index 767f0a79e..312a0ed43 100644 --- a/apps/browser-extension/src/entrypoints/contentScript/__tests__/Filter.test.ts +++ b/apps/browser-extension/src/entrypoints/contentScript/__tests__/Filter.test.ts @@ -292,7 +292,31 @@ describe('Filter - Credential URL Matching', () => { expect(matches[0].ServiceName).toBe('Reddit'); }); - // [#20] - Test multi-part TLDs like .com.au don't match incorrectly + /** + * [#20] - Test reversed domain (Android package name) doesn't match on TLD + * Note: Android package name filtering is not applicable to browser extensions. + * This test is included for consistency with Android and iOS test suites but is skipped. + */ + it.skip('should not match credentials based on TLD when filtering reversed domains', () => { + /** + * Android package name detection is not implemented in browser extensions + * since they only deal with web URLs, not Android app contexts. + */ + }); + + /** + * [#21] - Test Android package names are properly detected and handled + * Note: Android package name filtering is not applicable to browser extensions. + * This test is included for consistency with Android and iOS test suites but is skipped. + */ + it.skip('should properly handle Android package names in filtering', () => { + /** + * Android package name detection is not implemented in browser extensions + * since they only deal with web URLs, not Android app contexts. + */ + }); + + // [#22] - Test multi-part TLDs like .com.au don't match incorrectly it('should handle multi-part TLDs correctly without false matches', () => { // Create test data with different .com.au domains const australianCredentials = [ diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/autofill/utils/CredentialMatcher.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/autofill/utils/CredentialMatcher.kt index eeb212b5d..3a61aaad4 100644 --- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/autofill/utils/CredentialMatcher.kt +++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/autofill/utils/CredentialMatcher.kt @@ -10,7 +10,7 @@ object CredentialMatcher { /** * Common top-level domains (TLDs) that should be excluded from matching. - * This prevents false matches when dealing with reversed domain names (Android package names). + * This prevents false matches when dealing with reversed domain names (App package names). */ private val commonTlds = setOf( // Generic TLDs @@ -28,12 +28,12 @@ object CredentialMatcher { ) /** - * Check if a string is likely an Android package name (reversed domain). - * Android package names start with TLD followed by dot (e.g., "com.example", "nl.app"). + * Check if a string is likely an App package name (reversed domain). + * App package names start with TLD followed by dot (e.g., "com.example", "nl.app"). * @param text The text to check - * @return True if it looks like an Android package name + * @return True if it looks like an App package name */ - private fun isAndroidPackageName(text: String): Boolean { + private fun isAppPackageName(text: String): Boolean { if (!text.contains(".")) { return false } @@ -64,10 +64,10 @@ object CredentialMatcher { // Check if it starts with a protocol val hasProtocol = domain.startsWith("http://") || domain.startsWith("https://") - // If no protocol and starts with TLD + dot, it's likely an Android package name + // If no protocol and starts with TLD + dot, it's likely an App package name // Return empty string to indicate that domain extraction has failed for this string as // this is most likely not a real domain that the caller expects - if (!hasProtocol && isAndroidPackageName(domain)) { + if (!hasProtocol && isAppPackageName(domain)) { return "" } @@ -250,9 +250,9 @@ object CredentialMatcher { val searchDomain = extractDomain(searchText) - // Try to parse as Android package name first. - if (isAndroidPackageName(searchText)) { - // Is most likely android package name, do a simple exact match search on URL field + // Try to parse as App package name first. + if (isAppPackageName(searchText)) { + // Is most likely app package name, do a simple exact match search on URL field credentials.forEach { credential -> val serviceUrl = credential.service.url if (!serviceUrl.isNullOrEmpty()) { @@ -263,7 +263,7 @@ object CredentialMatcher { } } - // If android package name results in matches, return them immediately. + // If app package name results in matches, return them immediately. if (matches.isNotEmpty()) { return matches.toList() } diff --git a/apps/mobile-app/android/app/src/test/java/net/aliasvault/app/nativevaultmanager/AutofillTest.kt b/apps/mobile-app/android/app/src/test/java/net/aliasvault/app/nativevaultmanager/AutofillTest.kt index cb72a7eb7..6e363b982 100644 --- a/apps/mobile-app/android/app/src/test/java/net/aliasvault/app/nativevaultmanager/AutofillTest.kt +++ b/apps/mobile-app/android/app/src/test/java/net/aliasvault/app/nativevaultmanager/AutofillTest.kt @@ -295,7 +295,7 @@ class AutofillTest { assertEquals("Reddit", matches[0].service.name) } - // [#20] - Test reversed domain (Android package name) doesn't match on TLD + // [#20] - Test reversed domain (App package name) doesn't match on TLD @Test fun testReversedDomainTldCheck() { // Test that dumpert.nl credential doesn't match nl.marktplaats.android package @@ -315,9 +315,9 @@ class AutofillTest { assertEquals("Marktplaats.nl", matches[0].service.name) } - // [#21] - Test Android package names are properly detected and handled + // [#21] - Test App package names are properly detected and handled @Test - fun testAndroidPackageNameDetection() { + fun testAppPackageNameDetection() { val packageCredentials = listOf( createTestCredential("Google App", "com.google.android.googlequicksearchbox", "user@google.com"), createTestCredential("Facebook", "com.facebook.katana", "user@facebook.com"), diff --git a/apps/mobile-app/ios/VaultUITests/CredentialFilterTests.swift b/apps/mobile-app/ios/VaultUITests/CredentialFilterTests.swift index d15d6dd24..c19d99618 100644 --- a/apps/mobile-app/ios/VaultUITests/CredentialFilterTests.swift +++ b/apps/mobile-app/ios/VaultUITests/CredentialFilterTests.swift @@ -215,6 +215,32 @@ final class CredentialFilterTests: XCTestCase { XCTAssertEqual(ukMatches.first?.service.name, "UK Site") } + /** + * [#20] - Test reversed domain (Android package name) doesn't match on TLD + * Note: Android package name filtering is not applicable to iOS autofill in the same way. + * This test is included for consistency with Android test suite but is skipped. + */ + func testReversedDomainTldCheck() throws { + /** + * Android package name detection is implemented in Android-specific autofill code. + * iOS uses a different autofill mechanism and doesn't require the same TLD filtering. + */ + throw XCTSkip("Android package name filtering not applicable to iOS autofill") + } + + /** + * [#21] - Test Android package names are properly detected and handled + * Note: Android package name filtering is not applicable to iOS autofill in the same way. + * This test is included for consistency with Android test suite but is skipped. + */ + func testAppPackageNameDetection() throws { + /** + * Android package name detection is implemented in Android-specific autofill code. + * iOS uses a different autofill mechanism and doesn't require the same TLD filtering. + */ + throw XCTSkip("Android package name filtering not applicable to iOS autofill") + } + // MARK: - Shared Test Data /**