diff options
Diffstat (limited to 'autofill-parser')
-rw-r--r-- | autofill-parser/build.gradle.kts | 7 | ||||
-rw-r--r-- | autofill-parser/src/main/assets/publicsuffixes | bin | 205216 -> 109555 bytes | |||
-rw-r--r-- | autofill-parser/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListLoader.kt | 7 | ||||
-rw-r--r-- | autofill-parser/src/test/kotlin/mozilla/components/lib/publicsuffixlist/PublicSuffixListLoaderTest.kt | 18 |
4 files changed, 29 insertions, 3 deletions
diff --git a/autofill-parser/build.gradle.kts b/autofill-parser/build.gradle.kts index f22081f3..be71acf0 100644 --- a/autofill-parser/build.gradle.kts +++ b/autofill-parser/build.gradle.kts @@ -8,9 +8,13 @@ plugins { id("com.vanniktech.maven.publish") kotlin("android") `aps-plugin` + `psl-plugin` } -android { defaultConfig { consumerProguardFiles("consumer-rules.pro") } } +android { + defaultConfig { consumerProguardFiles("consumer-rules.pro") } + sourceSets { getByName("test") { resources.srcDir("src/main/assets") } } +} dependencies { implementation(libs.androidx.annotation) @@ -18,4 +22,5 @@ dependencies { implementation(libs.kotlin.coroutines.android) implementation(libs.kotlin.coroutines.core) implementation(libs.thirdparty.timberkt) + testImplementation(libs.bundles.testDependencies) } diff --git a/autofill-parser/src/main/assets/publicsuffixes b/autofill-parser/src/main/assets/publicsuffixes Binary files differindex c12128bd..39d8a034 100644 --- a/autofill-parser/src/main/assets/publicsuffixes +++ b/autofill-parser/src/main/assets/publicsuffixes diff --git a/autofill-parser/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListLoader.kt b/autofill-parser/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListLoader.kt index 5f3fc296..8491030d 100644 --- a/autofill-parser/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListLoader.kt +++ b/autofill-parser/src/main/java/mozilla/components/lib/publicsuffixlist/PublicSuffixListLoader.kt @@ -16,8 +16,8 @@ private const val PUBLIC_SUFFIX_LIST_FILE = "publicsuffixes" internal object PublicSuffixListLoader { - fun load(context: Context): PublicSuffixListData = - context.assets.open(PUBLIC_SUFFIX_LIST_FILE).buffered().use { stream -> + fun load(inputStream: BufferedInputStream): PublicSuffixListData = + inputStream.use { stream -> val publicSuffixSize = stream.readInt() val publicSuffixBytes = stream.readFully(publicSuffixSize) @@ -26,6 +26,9 @@ internal object PublicSuffixListLoader { PublicSuffixListData(publicSuffixBytes, exceptionBytes) } + + fun load(context: Context): PublicSuffixListData = + load(context.assets.open(PUBLIC_SUFFIX_LIST_FILE).buffered()) } @Suppress("MagicNumber") diff --git a/autofill-parser/src/test/kotlin/mozilla/components/lib/publicsuffixlist/PublicSuffixListLoaderTest.kt b/autofill-parser/src/test/kotlin/mozilla/components/lib/publicsuffixlist/PublicSuffixListLoaderTest.kt new file mode 100644 index 00000000..a4b7d4eb --- /dev/null +++ b/autofill-parser/src/test/kotlin/mozilla/components/lib/publicsuffixlist/PublicSuffixListLoaderTest.kt @@ -0,0 +1,18 @@ +/* + * Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved. + * SPDX-License-Identifier: GPL-3.0-only + */ + +package mozilla.components.lib.publicsuffixlist + +import org.junit.Test + +internal class PublicSuffixListLoaderTest { + @Test + fun testLoadingBundledPublicSuffixList() { + requireNotNull(javaClass.classLoader).getResourceAsStream("publicsuffixes").buffered().use { + stream -> + PublicSuffixListLoader.load(stream) + } + } +} |