Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Make autofill match tests match for all platforms (#1120)
Leendert de Borst69234de51cac
diff --git a/apps/browser-extension/src/entrypoints/contentScript/__tests__/Filter.test.ts b/apps/browser-extension/src/entrypoints/contentScript/__tests__/Filter.test.tsindex 57d451e63..22e0f5d87 100644--- a/apps/browser-extension/src/entrypoints/contentScript/__tests__/Filter.test.ts+++ b/apps/browser-extension/src/entrypoints/contentScript/__tests__/Filter.test.ts@@ -16,7 +16,7 @@ describe('Filter - Credential URL Matching', () => {it('should match exact URL', () => {const matches = filterCredentials(testCredentials,- 'https://www.coolblue.nl',+ 'www.coolblue.nl','');@@ -74,10 +74,9 @@ describe('Filter - Credential URL Matching', () => {// [#6] - Full URL stored matches partial URL searchit('should match full URL with partial URL', () => {- // Test case: stored URL is full, search with partialconst matches = filterCredentials(testCredentials,- 'https://coolblue.nl',+ 'coolblue.nl','');@@ -199,36 +198,24 @@ describe('Filter - Credential URL Matching', () => {expect(complexUrl[0].ServiceName).toBe('Coolblue');});- // [#12] - Priority ordering (exact over partial)- it('should prioritize exact matches over partial matches', () => {- // Add a credential with exact domain match to test priority- const credentialsWithExact = [- ...testCredentials,- createTestCredential(- 'Exact Match',- 'https://test.dumpert.nl',- )- ];-+ // [#12] - Priority ordering+ it('should handle priority ordering', () => {const matches = filterCredentials(- credentialsWithExact,- 'https://test.dumpert.nl',+ testCredentials,+ 'coolblue.nl','');- // Should prioritize exact match but also include partial matches- expect(matches.length).toBeGreaterThanOrEqual(1);- // The exact match should be first due to priority- expect(matches[0].ServiceName).toBe('Exact Match');+ expect(matches).toHaveLength(1);+ expect(matches[0].ServiceName).toBe('Coolblue');});// [#13] - Title-only matchingit('should match title only', () => {const matches = filterCredentials(testCredentials,- 'https://www.newyorktimes.com',- 'The New York Times'+ 'https://nomatch.com',+ 'newyorktimes');expect(matches).toHaveLength(1);@@ -243,7 +230,6 @@ describe('Filter - Credential URL Matching', () => {'');- // Browser extension should find no matches since domains don't matchexpect(matches).toHaveLength(0);});@@ -255,7 +241,6 @@ describe('Filter - Credential URL Matching', () => {'');- // Browser extension should find exact URL match for "Coolblue App"expect(matches).toHaveLength(1);expect(matches[0].ServiceName).toBe('Coolblue App');});@@ -268,20 +253,17 @@ describe('Filter - Credential URL Matching', () => {'');- // Browser extension should find no matches for invalid URLexpect(matches).toHaveLength(0);});// [#17] - Anti-phishing protection- it('should prevent phishing attacks', () => {- // Test that credentials with URLs don't match on text when URL is provided+ it('should handle anti-phishing protection', () => {const matches = filterCredentials(testCredentials,- 'https://secure-bankk.com', // Phishing domain (extra 'k')- 'Bank Account'+ 'https://secure-bankk.com',+ '');- // Should find no matches - Bank Account has URL so won't match on textexpect(matches).toHaveLength(0);});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.ktindex 40bfd66a3..351ab96b2 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@@ -75,7 +75,6 @@ class AutofillTest {// [#5] - Partial URL stored matches full URL search@Testfun testPartialUrlMatchWithFullUrl() {- // Test case: stored URL is "dumpert.nl", search with full URLval matches = CredentialMatcher.filterCredentialsByAppInfo(testCredentials,"https://www.dumpert.nl",@@ -88,7 +87,6 @@ class AutofillTest {// [#6] - Full URL stored matches partial URL search@Testfun testFullUrlMatchWithPartialUrl() {- // Test case: stored URL is full, search with partialval matches = CredentialMatcher.filterCredentialsByAppInfo(testCredentials,"coolblue.nl",@@ -205,57 +203,48 @@ class AutofillTest {assertEquals("Coolblue", complexUrl[0].service.name)}- // [#13] - Title-only matching+ // [#12] - Priority ordering@Test- fun testTitleOnlyMatching() {- // Test service name matching when no URL is available+ fun testPriorityOrdering() {val matches = CredentialMatcher.filterCredentialsByAppInfo(testCredentials,- "newyorktimes",+ "coolblue.nl",)assertEquals(1, matches.size)- assertEquals("Title Only newyorktimes", matches[0].service.name)+ assertEquals("Coolblue", matches[0].service.name)}- // [#14] - Domain name part matching (Android specific)+ // [#13] - Title-only matching@Test- fun testDomainNamePartMatch() {- // Test that unrelated domains don't match (coolblue.be doesn't match coolblue.nl)+ fun testTitleOnlyMatching() {val matches = CredentialMatcher.filterCredentialsByAppInfo(testCredentials,- "https://coolblue.be",+ "newyorktimes",)- // Should find no matches due to anti-phishing protection (Coolblue has URL so won't match on text)- assertTrue(matches.isEmpty())+ assertEquals(1, matches.size)+ assertEquals("Title Only newyorktimes", matches[0].service.name)}- // [#12] - Priority ordering (not applicable to Android)+ // [#14] - Domain name part matching@Test- fun testPriorityOrdering() {- // Android doesn't implement priority ordering like browser extension- // but we include the test for cross-platform consistency+ fun testDomainNamePartMatch() {val matches = CredentialMatcher.filterCredentialsByAppInfo(testCredentials,- "coolblue.nl",+ "https://coolblue.be",)- // Android should find domain match- assertEquals(1, matches.size)- assertEquals("Coolblue", matches[0].service.name)+ assertTrue(matches.isEmpty())}// [#15] - Package name matching@Testfun testPackageNameMatch() {- // Package names should match exact URL.val matches = CredentialMatcher.filterCredentialsByAppInfo(testCredentials,"com.coolblue.app",)-- // Should find exact URL match for "Coolblue App"assertEquals(1, matches.size)assertTrue(matches.any { it.service.name == "Coolblue App" })}@@ -274,13 +263,10 @@ class AutofillTest {// [#17] - Anti-phishing protection@Testfun testAntiPhishingProtection() {- // Test that credentials with URLs don't match on text when URL is providedval matches = CredentialMatcher.filterCredentialsByAppInfo(testCredentials,- "https://secure-bankk.com", // Phishing domain (extra 'k')+ "https://secure-bankk.com",)-- // Should find no matches - Bank Account has URL so won't match on textassertTrue(matches.isEmpty())}diff --git a/apps/mobile-app/ios/VaultUITests/CredentialFilterTests.swift b/apps/mobile-app/ios/VaultUITests/CredentialFilterTests.swiftindex 288e5e909..b15c101fd 100644--- a/apps/mobile-app/ios/VaultUITests/CredentialFilterTests.swift+++ b/apps/mobile-app/ios/VaultUITests/CredentialFilterTests.swift@@ -48,10 +48,8 @@ final class CredentialFilterTests: XCTestCase {XCTAssertTrue(matches.isEmpty)}- // New comprehensive test cases// [#5] - Partial URL stored matches full URL searchfunc testPartialUrlMatchWithFullUrl() {- // Test case: stored URL is "dumpert.nl", search with full URLlet matches = CredentialFilter.filterCredentials(testCredentials, searchText: "https://www.dumpert.nl")XCTAssertEqual(matches.count, 1)@@ -60,7 +58,6 @@ final class CredentialFilterTests: XCTestCase {// [#6] - Full URL stored matches partial URL searchfunc testFullUrlMatchWithPartialUrl() {- // Test case: stored URL is full, search with partiallet matches = CredentialFilter.filterCredentials(testCredentials, searchText: "coolblue.nl")XCTAssertEqual(matches.count, 1)@@ -133,15 +130,6 @@ final class CredentialFilterTests: XCTestCase {XCTAssertTrue(matches.contains { $0.service.name == "Coolblue" })}- // [#13] - Title-only matching- func testTitleOnlyMatching() {- // Test service name matching when no URL is available- let matches = CredentialFilter.filterCredentials(testCredentials, searchText: "newyorktimes")-- XCTAssertEqual(matches.count, 1)- XCTAssertEqual(matches.first?.service.name, "Title Only newyorktimes")- }-// [#12] - Priority orderingfunc testPriorityOrdering() {let matches = CredentialFilter.filterCredentials(testCredentials, searchText: "coolblue.nl")@@ -150,6 +138,14 @@ final class CredentialFilterTests: XCTestCase {XCTAssertEqual(matches.first?.service.name, "Coolblue")}+ // [#13] - Title-only matching+ func testTitleOnlyMatching() {+ let matches = CredentialFilter.filterCredentials(testCredentials, searchText: "newyorktimes")++ XCTAssertEqual(matches.count, 1)+ XCTAssertEqual(matches.first?.service.name, "Title Only newyorktimes")+ }+// [#14] - Domain name part matchingfunc testDomainNamePartMatch() {let matches = CredentialFilter.filterCredentials(testCredentials, searchText: "https://coolblue.be")@@ -174,10 +170,7 @@ final class CredentialFilterTests: XCTestCase {// [#17] - Anti-phishing protectionfunc testAntiPhishingProtection() {- // Test that credentials with URLs don't match on text when a non-matching base URL is provided- let matches = CredentialFilter.filterCredentials(testCredentials, searchText: "https://secure-bankk.com") // Phishing domain (extra 'k')-- // Should find no matches - Bank Account has URL so won't match on text+ let matches = CredentialFilter.filterCredentials(testCredentials, searchText: "https://secure-bankk.com")XCTAssertTrue(matches.isEmpty)}