Skip to content
Closed
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
15 changes: 15 additions & 0 deletions mobile/android/android-components/.buildconfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,13 @@ projects:
- components:support-test
- components:support-utils
- components:tooling-lint
components:concept-passwords-file:
description: An abstract definition of a component for importing passwords from
a file.
path: components/concept/passwords-file
publish: true
upstream_dependencies:
- components:tooling-lint
components:concept-push:
description: An abstract definition of a push service component.
path: components/concept/push
Expand Down Expand Up @@ -2033,6 +2040,14 @@ projects:
- components:support-utils
- components:tooling-lint
- components:ui-icons
components:lib-passwords-file:
description: A concrete implementation of concept-passwords-file that imports
passwords from CSV files.
path: components/lib/passwords-file
publish: true
upstream_dependencies:
- components:concept-passwords-file
- components:tooling-lint
components:lib-publicsuffixlist:
description: A library for reading and using the public suffix list.
path: components/lib/publicsuffixlist
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

plugins {
alias(libs.plugins.dependency.analysis)
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
namespace = 'mozilla.components.concept.passwords.file'
}

dependencies {
testImplementation libs.androidx.test.junit
testImplementation libs.kotlinx.coroutines.test
testImplementation libs.robolectric
}

apply from: '../../../common-config.gradle'
apply from: '../../../publish.gradle'
ext.configurePublish(config.componentsGroupId, project.name, project.ext.description)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.13.2" type="baseline" client="gradle" dependencies="false" name="AGP (8.13.2)" variant="all" version="8.13.2">

</issues>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<manifest />
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package mozilla.components.concept.passwords.file

import android.net.Uri

/**
* An interface for importing passwords from a file.
*/
fun interface PasswordsFileImporter {
/**
* The result of a passwords file import.
*
* @property count The number of passwords imported.
*/
data class ImportResult(val count: Int)

/**
* Imports passwords from the file at the given [uri].
*
* @param uri The URI of the file to import passwords from.
* @return A [Result] containing [ImportResult] on success or an exception on failure.
*/
suspend fun importPasswordsFromUri(uri: Uri): Result<ImportResult>

companion object {
/**
* Creates a [PasswordsFileImporter] that always returns a successful [Result].
*
* @param result The [ImportResult] to return on every import.
*/
fun alwaysSuccess(
result: ImportResult = ImportResult(count = 0),
): PasswordsFileImporter = PasswordsFileImporter { Result.success(result) }

/**
* Creates a [PasswordsFileImporter] that always returns a failed [Result].
*
* @param exception The [Exception] to return on every import.
*/
fun alwaysFailure(
exception: Exception = IllegalStateException("Import failed"),
): PasswordsFileImporter = PasswordsFileImporter { Result.failure(exception) }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

android {
namespace = 'mozilla.components.lib.passwords.file'
}

dependencies {
api project(':components:concept-passwords-file')
implementation libs.kotlinx.coroutines

testImplementation platform(libs.junit.bom)
testImplementation libs.junit4
testImplementation libs.kotlinx.coroutines.test
testImplementation libs.robolectric
}

apply from: '../../../common-config.gradle'
apply from: '../../../publish.gradle'
ext.configurePublish(config.componentsGroupId, project.name, project.ext.description)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.13.2" type="baseline" client="gradle" dependencies="false" name="AGP (8.13.2)" variant="all" version="8.13.2">

</issues>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<manifest />
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package mozilla.components.lib.passwords.file

import android.net.Uri
import mozilla.components.concept.passwords.file.PasswordsFileImporter
import mozilla.components.concept.passwords.file.PasswordsFileImporter.ImportResult

/**
* A [PasswordsFileImporter] for CSV password files.
*
* This is a stub implementation. CSV parsing and storage insertion will be added in a follow-up.
*/
class CsvPasswordsFileImporter : PasswordsFileImporter {
override suspend fun importPasswordsFromUri(uri: Uri): Result<ImportResult> =
Result.success(ImportResult(count = 0))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package mozilla.components.lib.passwords.file

import android.net.Uri
import kotlinx.coroutines.test.runTest
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner

@RunWith(RobolectricTestRunner::class)
class CsvPasswordsFileImporterTest {

@Test
fun `importPasswordsFromUri returns success with zero count`() = runTest {
val importer = CsvPasswordsFileImporter()

val result = importer.importPasswordsFromUri(Uri.EMPTY)

assertTrue(result.isSuccess)
assertEquals(0, result.getOrThrow().count)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sdk=35
2 changes: 2 additions & 0 deletions taskcluster/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ treeherder:
'concept-fetch': 'concept-fetch'
'concept-llm': 'concept-llm'
'concept-menu': 'concept-menu'
'concept-passwords-file': 'concept-passwords-file'
'concept-push': 'concept-push'
'concept-storage': 'concept-storage'
'concept-storage-bookmarks': 'concept-storage-bookmarks'
Expand Down Expand Up @@ -310,6 +311,7 @@ treeherder:
'lib-llm-gemininano': 'lib-llm-gemininano'
'lib-llm-mlpa': 'lib-llm-mlpa'
'lib-integrity-googleplay': 'lib-integrity-googleplay'
'lib-passwords-file': 'lib-passwords-file'
'lib-shake': 'lib-shake'
'lib-publicsuffixlist': 'lib-publicsuffixlist'
'lib-push-firebase': 'lib-push-firebase'
Expand Down