Skip to content

Commit

Permalink
Don't show key icon for empty passwords (#2962)
Browse files Browse the repository at this point in the history
Task/Issue URL:
https://app.asana.com/0/1202926619870900/1207697076491402/f
Tech Design URL:
https://app.asana.com/0/481882893211075/1207750849382981

**Description**:

There has been an issue around for some time where the autofill key icon
(indicating that there is autofill data for that field) was showing in
the password field despite there being no password stored for a domain.
This was because we were using the existence of any stored data for that
domain as the source of truth for showing the icon in both username and
password fields.

**Steps to test this PR**:
1. Go to More (...) -> autofill
2. Make sure there are no other login for the domain https://fill.dev/
3. Add a login for the domain https://fill.dev/, filling in the username
field but not the password field.
4. Visit https://fill.dev/
5. **Observe there is a key icon in the username field but not the
password**
6. Repeat step 1
7. Find the login added in step 3 and add a password.
8. Refresh the https://fill.dev/ page.
9. **Observe there are key icons in both fields**

**Definition of Done**:

* [ ] Does this PR satisfy our [Definition of
Done](https://app.asana.com/0/1202500774821704/1207634633537039/f)?

---
###### Internal references:
[Pull Request Review
Checklist](https://app.asana.com/0/1202500774821704/1203764234894239/f)
[Software Engineering
Expectations](https://app.asana.com/0/59792373528535/199064865822552)
[Technical Design
Template](https://app.asana.com/0/59792373528535/184709971311943)
[Pull Request
Documentation](https://app.asana.com/0/1202500774821704/1204012835277482/f)
  • Loading branch information
graeme authored Jul 23, 2024
1 parent fedabdb commit 52dfd2e
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13404,7 +13404,7 @@
repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 174.0.1;
version = 175.0.0;
};
};
9FF521422BAA8FF300B9819B /* XCRemoteSwiftPackageReference "lottie-spm" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/BrowserServicesKit",
"state" : {
"revision" : "63195a30b02e05d1b7176c76ebc55c2cff66c9c8",
"version" : "174.0.1"
"revision" : "b2f5a7159088ff5c4fd2eeaa4dcf5c001fc8f7fb",
"version" : "175.0.0"
}
},
{
Expand Down Expand Up @@ -75,7 +75,7 @@
{
"identity" : "lottie-spm",
"kind" : "remoteSourceControl",
"location" : "https://github.com/airbnb/lottie-spm",
"location" : "https://github.com/airbnb/lottie-spm.git",
"state" : {
"revision" : "1d29eccc24cc8b75bff9f6804155112c0ffc9605",
"version" : "4.4.3"
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/DataBrokerProtection/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let package = Package(
targets: ["DataBrokerProtection"])
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "174.0.1"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "175.0.0"),
.package(path: "../SwiftUIExtensions"),
.package(path: "../XPCHelper"),
],
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/NetworkProtectionMac/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ let package = Package(
.library(name: "VPNAppLauncher", targets: ["VPNAppLauncher"]),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "174.0.1"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "175.0.0"),
.package(url: "https://github.com/airbnb/lottie-spm", exact: "4.4.3"),
.package(path: "../AppLauncher"),
.package(path: "../UDSHelper"),
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/SubscriptionUI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let package = Package(
targets: ["SubscriptionUI"]),
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "174.0.1"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "175.0.0"),
.package(path: "../SwiftUIExtensions")
],
targets: [
Expand Down
19 changes: 19 additions & 0 deletions UnitTests/DataExport/MockSecureVault.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ let MockSecureVaultFactory = SecureVaultFactory<MockSecureVault>(
)

final class MockSecureVault<T: AutofillDatabaseProvider>: AutofillSecureVault {

enum MockError: Error {
case noStubSet
}
Expand All @@ -53,6 +54,7 @@ final class MockSecureVault<T: AutofillDatabaseProvider>: AutofillSecureVault {

var storedAccounts: [SecureVaultModels.WebsiteAccount] = []
var storedCredentials: [Int64: SecureVaultModels.WebsiteCredentials] = [:]
var storedCredentialsForDomain: [String: [SecureVaultModels.WebsiteCredentials]] = [:]
var storedNeverPromptWebsites = [SecureVaultModels.NeverPromptWebsites]()
var storedNotes: [SecureVaultModels.Note] = []
var storedIdentities: [SecureVaultModels.Identity] = []
Expand Down Expand Up @@ -90,6 +92,14 @@ final class MockSecureVault<T: AutofillDatabaseProvider>: AutofillSecureVault {
return storedCredentials[accountId]
}

func websiteCredentialsFor(domain: String) throws -> [BrowserServicesKit.SecureVaultModels.WebsiteCredentials] {
return storedCredentialsForDomain[domain] ?? []
}

func websiteCredentialsWithPartialMatchesFor(eTLDplus1: String) throws -> [BrowserServicesKit.SecureVaultModels.WebsiteCredentials] {
return storedCredentialsForDomain[eTLDplus1] ?? []
}

func storeWebsiteCredentials(_ credentials: SecureVaultModels.WebsiteCredentials) throws -> Int64 {
let accountID = Int64(credentials.account.id!)!
storedCredentials[accountID] = credentials
Expand Down Expand Up @@ -302,6 +312,7 @@ class MockDatabaseProvider: AutofillDatabaseProvider {
var _creditCards = [Int64: SecureVaultModels.CreditCard]()
var _forDomain = [String]()
var _credentialsDict = [Int64: SecureVaultModels.WebsiteCredentials]()
var _credentialsForDomain = [String: [SecureVaultModels.WebsiteCredentials]]()
var _note: SecureVaultModels.Note?
var _neverPromptWebsites = [SecureVaultModels.NeverPromptWebsites]()

Expand Down Expand Up @@ -330,6 +341,14 @@ class MockDatabaseProvider: AutofillDatabaseProvider {
return _credentialsDict[accountId]
}

func websiteCredentialsForDomain(_ domain: String) throws -> [BrowserServicesKit.SecureVaultModels.WebsiteCredentials] {
return _credentialsForDomain[domain] ?? []
}

func websiteCredentialsForTopLevelDomain(_ domain: String) throws -> [BrowserServicesKit.SecureVaultModels.WebsiteCredentials] {
return _credentialsForDomain[domain] ?? []
}

func websiteAccountsForDomain(_ domain: String) throws -> [SecureVaultModels.WebsiteAccount] {
self._forDomain.append(domain)
return _accounts
Expand Down

0 comments on commit 52dfd2e

Please sign in to comment.