Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

### Logins
* `run_maintenance()` now optionally deletes undecryptable logins (https://bugzilla.mozilla.org/show_bug.cgi?id=2007416)
* Exposes `add_many()` through kotlin (https://bugzilla.mozilla.org/show_bug.cgi?id=2039737)

[Full Changelog](In progress)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ class DatabaseLoginsStorage(dbPath: String, keyManager: KeyManager) : AutoClosea
return store.add(entry)
}

/**
* Adds multiple logins.
*
* @return a list of inserted logins.
*/
@Throws(LoginsApiException::class)
fun addMany(entries: List<LoginEntry>): List<BulkResultEntry> {
return store.addMany(entries)
}

@Throws(LoginsApiException::class)
fun update(id: String, entry: LoginEntry): Login {
return store.update(id, entry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,44 @@ class DatabaseLoginsStorageTest {
finishAndClose(store)
}

@Test
fun testAddMany() {
val store = getTestStore()
val loginsToAdd = listOf(
LoginEntry(
origin = "https://www.example.org",
httpRealm = "",
formActionOrigin = "https://www.example.org/login",
usernameField = "users_name",
passwordField = "users_password",
Comment on lines +106 to +107
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this always going to be users_name and users_password ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just copied the fake data that already existed in test. I'm not sure exactly what these fields are used for.

password = "MyVeryCoolPassword",
username = "Foobar2001",
),
LoginEntry(
origin = "https://www.example.org",
httpRealm = "",
formActionOrigin = "https://www.example.org/login",
usernameField = "users_name",
passwordField = "users_password",
password = "MyVeryCoolPassword",
username = "Foobar2002",
),
LoginEntry(
origin = "https://www.example.org",
httpRealm = "",
formActionOrigin = "https://www.example.org/login",
usernameField = "users_name",
passwordField = "users_password",
password = "MyVeryCoolPassword",
username = "Foobar2003",
),
)

assertEquals(store.list().size, 2)
store.addMany(loginsToAdd)
assertEquals(store.list().size, 5)
}

@Test
fun testDelete() {
val store = getTestStore()
Expand Down