aboutsummaryrefslogtreecommitdiff
path: root/app/src/androidTest/java/dev
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/androidTest/java/dev')
-rw-r--r--app/src/androidTest/java/dev/msfjarvis/aps/data/password/PasswordEntryAndroidTest.kt175
-rw-r--r--app/src/androidTest/java/dev/msfjarvis/aps/util/settings/MigrationsTest.kt173
-rw-r--r--app/src/androidTest/java/dev/msfjarvis/aps/util/totp/UriTotpFinderTest.kt68
-rw-r--r--app/src/androidTest/java/dev/msfjarvis/aps/util/viewmodel/StrictDomainRegexTest.kt72
4 files changed, 253 insertions, 235 deletions
diff --git a/app/src/androidTest/java/dev/msfjarvis/aps/data/password/PasswordEntryAndroidTest.kt b/app/src/androidTest/java/dev/msfjarvis/aps/data/password/PasswordEntryAndroidTest.kt
index 80f178cc..97f3539c 100644
--- a/app/src/androidTest/java/dev/msfjarvis/aps/data/password/PasswordEntryAndroidTest.kt
+++ b/app/src/androidTest/java/dev/msfjarvis/aps/data/password/PasswordEntryAndroidTest.kt
@@ -18,98 +18,105 @@ import org.junit.Test
class PasswordEntryAndroidTest {
- private fun makeEntry(content: String) = PasswordEntry(content, UriTotpFinder())
+ private fun makeEntry(content: String) = PasswordEntry(content, UriTotpFinder())
- @Test fun testGetPassword() {
- assertEquals("fooooo", makeEntry("fooooo\nbla\n").password)
- assertEquals("fooooo", makeEntry("fooooo\nbla").password)
- assertEquals("fooooo", makeEntry("fooooo\n").password)
- assertEquals("fooooo", makeEntry("fooooo").password)
- assertEquals("", makeEntry("\nblubb\n").password)
- assertEquals("", makeEntry("\nblubb").password)
- assertEquals("", makeEntry("\n").password)
- assertEquals("", makeEntry("").password)
- }
+ @Test
+ fun testGetPassword() {
+ assertEquals("fooooo", makeEntry("fooooo\nbla\n").password)
+ assertEquals("fooooo", makeEntry("fooooo\nbla").password)
+ assertEquals("fooooo", makeEntry("fooooo\n").password)
+ assertEquals("fooooo", makeEntry("fooooo").password)
+ assertEquals("", makeEntry("\nblubb\n").password)
+ assertEquals("", makeEntry("\nblubb").password)
+ assertEquals("", makeEntry("\n").password)
+ assertEquals("", makeEntry("").password)
+ }
- @Test fun testGetExtraContent() {
- assertEquals("bla\n", makeEntry("fooooo\nbla\n").extraContent)
- assertEquals("bla", makeEntry("fooooo\nbla").extraContent)
- assertEquals("", makeEntry("fooooo\n").extraContent)
- assertEquals("", makeEntry("fooooo").extraContent)
- assertEquals("blubb\n", makeEntry("\nblubb\n").extraContent)
- assertEquals("blubb", makeEntry("\nblubb").extraContent)
- assertEquals("", makeEntry("\n").extraContent)
- assertEquals("", makeEntry("").extraContent)
- }
+ @Test
+ fun testGetExtraContent() {
+ assertEquals("bla\n", makeEntry("fooooo\nbla\n").extraContent)
+ assertEquals("bla", makeEntry("fooooo\nbla").extraContent)
+ assertEquals("", makeEntry("fooooo\n").extraContent)
+ assertEquals("", makeEntry("fooooo").extraContent)
+ assertEquals("blubb\n", makeEntry("\nblubb\n").extraContent)
+ assertEquals("blubb", makeEntry("\nblubb").extraContent)
+ assertEquals("", makeEntry("\n").extraContent)
+ assertEquals("", makeEntry("").extraContent)
+ }
- @Test fun testGetUsername() {
- for (field in PasswordEntry.USERNAME_FIELDS) {
- assertEquals("username", makeEntry("\n$field username").username)
- assertEquals("username", makeEntry("\n${field.toUpperCase()} username").username)
- }
- assertEquals(
- "username",
- makeEntry("secret\nextra\nlogin: username\ncontent\n").username)
- assertEquals(
- "username",
- makeEntry("\nextra\nusername: username\ncontent\n").username)
- assertEquals(
- "username", makeEntry("\nUSERNaMe: username\ncontent\n").username)
- assertEquals("username", makeEntry("\nlogin: username").username)
- assertEquals("foo@example.com", makeEntry("\nemail: foo@example.com").username)
- assertEquals("username", makeEntry("\nidentity: username\nlogin: another_username").username)
- assertEquals("username", makeEntry("\nLOGiN:username").username)
- assertNull(makeEntry("secret\nextra\ncontent\n").username)
+ @Test
+ fun testGetUsername() {
+ for (field in PasswordEntry.USERNAME_FIELDS) {
+ assertEquals("username", makeEntry("\n$field username").username)
+ assertEquals("username", makeEntry("\n${field.toUpperCase()} username").username)
}
+ assertEquals("username", makeEntry("secret\nextra\nlogin: username\ncontent\n").username)
+ assertEquals("username", makeEntry("\nextra\nusername: username\ncontent\n").username)
+ assertEquals("username", makeEntry("\nUSERNaMe: username\ncontent\n").username)
+ assertEquals("username", makeEntry("\nlogin: username").username)
+ assertEquals("foo@example.com", makeEntry("\nemail: foo@example.com").username)
+ assertEquals("username", makeEntry("\nidentity: username\nlogin: another_username").username)
+ assertEquals("username", makeEntry("\nLOGiN:username").username)
+ assertNull(makeEntry("secret\nextra\ncontent\n").username)
+ }
- @Test fun testHasUsername() {
- assertTrue(makeEntry("secret\nextra\nlogin: username\ncontent\n").hasUsername())
- assertFalse(makeEntry("secret\nextra\ncontent\n").hasUsername())
- assertFalse(makeEntry("secret\nlogin failed\n").hasUsername())
- assertFalse(makeEntry("\n").hasUsername())
- assertFalse(makeEntry("").hasUsername())
- }
+ @Test
+ fun testHasUsername() {
+ assertTrue(makeEntry("secret\nextra\nlogin: username\ncontent\n").hasUsername())
+ assertFalse(makeEntry("secret\nextra\ncontent\n").hasUsername())
+ assertFalse(makeEntry("secret\nlogin failed\n").hasUsername())
+ assertFalse(makeEntry("\n").hasUsername())
+ assertFalse(makeEntry("").hasUsername())
+ }
- @Test fun testGeneratesOtpFromTotpUri() {
- val entry = makeEntry("secret\nextra\n$TOTP_URI")
- assertTrue(entry.hasTotp())
- val code = Otp.calculateCode(
- entry.totpSecret!!,
- // The hardcoded date value allows this test to stay reproducible.
- Date(8640000).time / (1000 * entry.totpPeriod),
- entry.totpAlgorithm,
- entry.digits
- ).get()
- assertNotNull(code) { "Generated OTP cannot be null" }
- assertEquals(entry.digits.toInt(), code.length)
- assertEquals("545293", code)
- }
+ @Test
+ fun testGeneratesOtpFromTotpUri() {
+ val entry = makeEntry("secret\nextra\n$TOTP_URI")
+ assertTrue(entry.hasTotp())
+ val code =
+ Otp.calculateCode(
+ entry.totpSecret!!,
+ // The hardcoded date value allows this test to stay reproducible.
+ Date(8640000).time / (1000 * entry.totpPeriod),
+ entry.totpAlgorithm,
+ entry.digits
+ )
+ .get()
+ assertNotNull(code) { "Generated OTP cannot be null" }
+ assertEquals(entry.digits.toInt(), code.length)
+ assertEquals("545293", code)
+ }
- @Test fun testGeneratesOtpWithOnlyUriInFile() {
- val entry = makeEntry(TOTP_URI)
- assertTrue(entry.password.isEmpty())
- assertTrue(entry.hasTotp())
- val code = Otp.calculateCode(
- entry.totpSecret!!,
- // The hardcoded date value allows this test to stay reproducible.
- Date(8640000).time / (1000 * entry.totpPeriod),
- entry.totpAlgorithm,
- entry.digits
- ).get()
- assertNotNull(code) { "Generated OTP cannot be null" }
- assertEquals(entry.digits.toInt(), code.length)
- assertEquals("545293", code)
- }
+ @Test
+ fun testGeneratesOtpWithOnlyUriInFile() {
+ val entry = makeEntry(TOTP_URI)
+ assertTrue(entry.password.isEmpty())
+ assertTrue(entry.hasTotp())
+ val code =
+ Otp.calculateCode(
+ entry.totpSecret!!,
+ // The hardcoded date value allows this test to stay reproducible.
+ Date(8640000).time / (1000 * entry.totpPeriod),
+ entry.totpAlgorithm,
+ entry.digits
+ )
+ .get()
+ assertNotNull(code) { "Generated OTP cannot be null" }
+ assertEquals(entry.digits.toInt(), code.length)
+ assertEquals("545293", code)
+ }
- @Test fun testOnlyLooksForUriInFirstLine() {
- val entry = makeEntry("id:\n$TOTP_URI")
- assertTrue(entry.password.isNotEmpty())
- assertTrue(entry.hasTotp())
- assertFalse(entry.hasUsername())
- }
+ @Test
+ fun testOnlyLooksForUriInFirstLine() {
+ val entry = makeEntry("id:\n$TOTP_URI")
+ assertTrue(entry.password.isNotEmpty())
+ assertTrue(entry.hasTotp())
+ assertFalse(entry.hasUsername())
+ }
- companion object {
+ companion object {
- const val TOTP_URI = "otpauth://totp/ACME%20Co:john@example.com?secret=HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ&issuer=ACME%20Co&algorithm=SHA1&digits=6&period=30"
- }
+ const val TOTP_URI =
+ "otpauth://totp/ACME%20Co:john@example.com?secret=HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ&issuer=ACME%20Co&algorithm=SHA1&digits=6&period=30"
+ }
}
diff --git a/app/src/androidTest/java/dev/msfjarvis/aps/util/settings/MigrationsTest.kt b/app/src/androidTest/java/dev/msfjarvis/aps/util/settings/MigrationsTest.kt
index cac5d80d..83a6afde 100644
--- a/app/src/androidTest/java/dev/msfjarvis/aps/util/settings/MigrationsTest.kt
+++ b/app/src/androidTest/java/dev/msfjarvis/aps/util/settings/MigrationsTest.kt
@@ -19,102 +19,103 @@ import org.junit.Test
class MigrationsTest {
- private fun checkOldKeysAreRemoved(context: Context) = with(context.sharedPrefs) {
- assertNull(getString(PreferenceKeys.GIT_REMOTE_PORT))
- assertNull(getString(PreferenceKeys.GIT_REMOTE_USERNAME))
- assertNull(getString(PreferenceKeys.GIT_REMOTE_SERVER))
- assertNull(getString(PreferenceKeys.GIT_REMOTE_LOCATION))
- assertNull(getString(PreferenceKeys.GIT_REMOTE_PROTOCOL))
+ private fun checkOldKeysAreRemoved(context: Context) =
+ with(context.sharedPrefs) {
+ assertNull(getString(PreferenceKeys.GIT_REMOTE_PORT))
+ assertNull(getString(PreferenceKeys.GIT_REMOTE_USERNAME))
+ assertNull(getString(PreferenceKeys.GIT_REMOTE_SERVER))
+ assertNull(getString(PreferenceKeys.GIT_REMOTE_LOCATION))
+ assertNull(getString(PreferenceKeys.GIT_REMOTE_PROTOCOL))
}
- @Test
- fun verifySshWithCustomPortMigration() {
- val context = Application.instance.applicationContext
- context.sharedPrefs.edit {
- clear()
- putString(PreferenceKeys.GIT_REMOTE_PORT, "2200")
- putString(PreferenceKeys.GIT_REMOTE_USERNAME, "msfjarvis")
- putString(PreferenceKeys.GIT_REMOTE_LOCATION, "/mnt/disk3/pass-repo")
- putString(PreferenceKeys.GIT_REMOTE_SERVER, "192.168.0.102")
- putString(PreferenceKeys.GIT_REMOTE_PROTOCOL, Protocol.Ssh.pref)
- putString(PreferenceKeys.GIT_REMOTE_AUTH, AuthMode.Password.pref)
- }
- runMigrations(context)
- checkOldKeysAreRemoved(context)
- assertEquals(
- context.sharedPrefs.getString(PreferenceKeys.GIT_REMOTE_URL),
- "ssh://msfjarvis@192.168.0.102:2200/mnt/disk3/pass-repo"
- )
+ @Test
+ fun verifySshWithCustomPortMigration() {
+ val context = Application.instance.applicationContext
+ context.sharedPrefs.edit {
+ clear()
+ putString(PreferenceKeys.GIT_REMOTE_PORT, "2200")
+ putString(PreferenceKeys.GIT_REMOTE_USERNAME, "msfjarvis")
+ putString(PreferenceKeys.GIT_REMOTE_LOCATION, "/mnt/disk3/pass-repo")
+ putString(PreferenceKeys.GIT_REMOTE_SERVER, "192.168.0.102")
+ putString(PreferenceKeys.GIT_REMOTE_PROTOCOL, Protocol.Ssh.pref)
+ putString(PreferenceKeys.GIT_REMOTE_AUTH, AuthMode.Password.pref)
}
+ runMigrations(context)
+ checkOldKeysAreRemoved(context)
+ assertEquals(
+ context.sharedPrefs.getString(PreferenceKeys.GIT_REMOTE_URL),
+ "ssh://msfjarvis@192.168.0.102:2200/mnt/disk3/pass-repo"
+ )
+ }
- @Test
- fun verifySshWithDefaultPortMigration() {
- val context = Application.instance.applicationContext
- context.sharedPrefs.edit {
- clear()
- putString(PreferenceKeys.GIT_REMOTE_USERNAME, "msfjarvis")
- putString(PreferenceKeys.GIT_REMOTE_LOCATION, "/mnt/disk3/pass-repo")
- putString(PreferenceKeys.GIT_REMOTE_SERVER, "192.168.0.102")
- putString(PreferenceKeys.GIT_REMOTE_PROTOCOL, Protocol.Ssh.pref)
- putString(PreferenceKeys.GIT_REMOTE_AUTH, AuthMode.SshKey.pref)
- }
- runMigrations(context)
- checkOldKeysAreRemoved(context)
- assertEquals(
- context.sharedPrefs.getString(PreferenceKeys.GIT_REMOTE_URL),
- "msfjarvis@192.168.0.102:/mnt/disk3/pass-repo"
- )
+ @Test
+ fun verifySshWithDefaultPortMigration() {
+ val context = Application.instance.applicationContext
+ context.sharedPrefs.edit {
+ clear()
+ putString(PreferenceKeys.GIT_REMOTE_USERNAME, "msfjarvis")
+ putString(PreferenceKeys.GIT_REMOTE_LOCATION, "/mnt/disk3/pass-repo")
+ putString(PreferenceKeys.GIT_REMOTE_SERVER, "192.168.0.102")
+ putString(PreferenceKeys.GIT_REMOTE_PROTOCOL, Protocol.Ssh.pref)
+ putString(PreferenceKeys.GIT_REMOTE_AUTH, AuthMode.SshKey.pref)
}
+ runMigrations(context)
+ checkOldKeysAreRemoved(context)
+ assertEquals(
+ context.sharedPrefs.getString(PreferenceKeys.GIT_REMOTE_URL),
+ "msfjarvis@192.168.0.102:/mnt/disk3/pass-repo"
+ )
+ }
- @Test
- fun verifyHttpsWithGitHubMigration() {
- val context = Application.instance.applicationContext
- context.sharedPrefs.edit {
- clear()
- putString(PreferenceKeys.GIT_REMOTE_USERNAME, "msfjarvis")
- putString(PreferenceKeys.GIT_REMOTE_LOCATION, "Android-Password-Store/pass-test")
- putString(PreferenceKeys.GIT_REMOTE_SERVER, "github.com")
- putString(PreferenceKeys.GIT_REMOTE_PROTOCOL, Protocol.Https.pref)
- putString(PreferenceKeys.GIT_REMOTE_AUTH, AuthMode.None.pref)
- }
- runMigrations(context)
- checkOldKeysAreRemoved(context)
- assertEquals(
- context.sharedPrefs.getString(PreferenceKeys.GIT_REMOTE_URL),
- "https://github.com/Android-Password-Store/pass-test"
- )
+ @Test
+ fun verifyHttpsWithGitHubMigration() {
+ val context = Application.instance.applicationContext
+ context.sharedPrefs.edit {
+ clear()
+ putString(PreferenceKeys.GIT_REMOTE_USERNAME, "msfjarvis")
+ putString(PreferenceKeys.GIT_REMOTE_LOCATION, "Android-Password-Store/pass-test")
+ putString(PreferenceKeys.GIT_REMOTE_SERVER, "github.com")
+ putString(PreferenceKeys.GIT_REMOTE_PROTOCOL, Protocol.Https.pref)
+ putString(PreferenceKeys.GIT_REMOTE_AUTH, AuthMode.None.pref)
}
+ runMigrations(context)
+ checkOldKeysAreRemoved(context)
+ assertEquals(
+ context.sharedPrefs.getString(PreferenceKeys.GIT_REMOTE_URL),
+ "https://github.com/Android-Password-Store/pass-test"
+ )
+ }
- @Test
- fun verifyHiddenFoldersMigrationIfDisabled() {
- val context = Application.instance.applicationContext
- context.sharedPrefs.edit { clear() }
- runMigrations(context)
- assertEquals(true, context.sharedPrefs.getBoolean(PreferenceKeys.SHOW_HIDDEN_FOLDERS, true))
- assertEquals(false, context.sharedPrefs.getBoolean(PreferenceKeys.SHOW_HIDDEN_CONTENTS, false))
- }
+ @Test
+ fun verifyHiddenFoldersMigrationIfDisabled() {
+ val context = Application.instance.applicationContext
+ context.sharedPrefs.edit { clear() }
+ runMigrations(context)
+ assertEquals(true, context.sharedPrefs.getBoolean(PreferenceKeys.SHOW_HIDDEN_FOLDERS, true))
+ assertEquals(false, context.sharedPrefs.getBoolean(PreferenceKeys.SHOW_HIDDEN_CONTENTS, false))
+ }
- @Test
- fun verifyHiddenFoldersMigrationIfEnabled() {
- val context = Application.instance.applicationContext
- context.sharedPrefs.edit {
- clear()
- putBoolean(PreferenceKeys.SHOW_HIDDEN_FOLDERS, true)
- }
- runMigrations(context)
- assertEquals(false, context.sharedPrefs.getBoolean(PreferenceKeys.SHOW_HIDDEN_FOLDERS, false))
- assertEquals(true, context.sharedPrefs.getBoolean(PreferenceKeys.SHOW_HIDDEN_CONTENTS, false))
+ @Test
+ fun verifyHiddenFoldersMigrationIfEnabled() {
+ val context = Application.instance.applicationContext
+ context.sharedPrefs.edit {
+ clear()
+ putBoolean(PreferenceKeys.SHOW_HIDDEN_FOLDERS, true)
}
+ runMigrations(context)
+ assertEquals(false, context.sharedPrefs.getBoolean(PreferenceKeys.SHOW_HIDDEN_FOLDERS, false))
+ assertEquals(true, context.sharedPrefs.getBoolean(PreferenceKeys.SHOW_HIDDEN_CONTENTS, false))
+ }
- @Test
- fun verifyClearClipboardHistoryMigration() {
- val context = Application.instance.applicationContext
- context.sharedPrefs.edit {
- clear()
- putBoolean(PreferenceKeys.CLEAR_CLIPBOARD_20X, true)
- }
- runMigrations(context)
- assertEquals(true, context.sharedPrefs.getBoolean(PreferenceKeys.CLEAR_CLIPBOARD_HISTORY, false))
- assertFalse(context.sharedPrefs.contains(PreferenceKeys.CLEAR_CLIPBOARD_20X))
+ @Test
+ fun verifyClearClipboardHistoryMigration() {
+ val context = Application.instance.applicationContext
+ context.sharedPrefs.edit {
+ clear()
+ putBoolean(PreferenceKeys.CLEAR_CLIPBOARD_20X, true)
}
+ runMigrations(context)
+ assertEquals(true, context.sharedPrefs.getBoolean(PreferenceKeys.CLEAR_CLIPBOARD_HISTORY, false))
+ assertFalse(context.sharedPrefs.contains(PreferenceKeys.CLEAR_CLIPBOARD_20X))
+ }
}
diff --git a/app/src/androidTest/java/dev/msfjarvis/aps/util/totp/UriTotpFinderTest.kt b/app/src/androidTest/java/dev/msfjarvis/aps/util/totp/UriTotpFinderTest.kt
index 4ecc31d2..b89cf0ef 100644
--- a/app/src/androidTest/java/dev/msfjarvis/aps/util/totp/UriTotpFinderTest.kt
+++ b/app/src/androidTest/java/dev/msfjarvis/aps/util/totp/UriTotpFinderTest.kt
@@ -10,36 +10,40 @@ import org.junit.Test
class UriTotpFinderTest {
- private val totpFinder = UriTotpFinder()
-
- @Test
- fun findSecret() {
- assertEquals("HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ", totpFinder.findSecret(TOTP_URI))
- assertEquals("HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ", totpFinder.findSecret("name\npassword\ntotp: HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ"))
- assertEquals("HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ", totpFinder.findSecret(PASS_FILE_CONTENT))
- }
-
- @Test
- fun findDigits() {
- assertEquals("12", totpFinder.findDigits(TOTP_URI))
- assertEquals("12", totpFinder.findDigits(PASS_FILE_CONTENT))
- }
-
- @Test
- fun findPeriod() {
- assertEquals(25, totpFinder.findPeriod(TOTP_URI))
- assertEquals(25, totpFinder.findPeriod(PASS_FILE_CONTENT))
- }
-
- @Test
- fun findAlgorithm() {
- assertEquals("SHA256", totpFinder.findAlgorithm(TOTP_URI))
- assertEquals("SHA256", totpFinder.findAlgorithm(PASS_FILE_CONTENT))
- }
-
- companion object {
-
- const val TOTP_URI = "otpauth://totp/ACME%20Co:john@example.com?secret=HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ&issuer=ACME%20Co&algorithm=SHA256&digits=12&period=25"
- const val PASS_FILE_CONTENT = "password\n$TOTP_URI"
- }
+ private val totpFinder = UriTotpFinder()
+
+ @Test
+ fun findSecret() {
+ assertEquals("HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ", totpFinder.findSecret(TOTP_URI))
+ assertEquals(
+ "HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ",
+ totpFinder.findSecret("name\npassword\ntotp: HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ")
+ )
+ assertEquals("HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ", totpFinder.findSecret(PASS_FILE_CONTENT))
+ }
+
+ @Test
+ fun findDigits() {
+ assertEquals("12", totpFinder.findDigits(TOTP_URI))
+ assertEquals("12", totpFinder.findDigits(PASS_FILE_CONTENT))
+ }
+
+ @Test
+ fun findPeriod() {
+ assertEquals(25, totpFinder.findPeriod(TOTP_URI))
+ assertEquals(25, totpFinder.findPeriod(PASS_FILE_CONTENT))
+ }
+
+ @Test
+ fun findAlgorithm() {
+ assertEquals("SHA256", totpFinder.findAlgorithm(TOTP_URI))
+ assertEquals("SHA256", totpFinder.findAlgorithm(PASS_FILE_CONTENT))
+ }
+
+ companion object {
+
+ const val TOTP_URI =
+ "otpauth://totp/ACME%20Co:john@example.com?secret=HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ&issuer=ACME%20Co&algorithm=SHA256&digits=12&period=25"
+ const val PASS_FILE_CONTENT = "password\n$TOTP_URI"
+ }
}
diff --git a/app/src/androidTest/java/dev/msfjarvis/aps/util/viewmodel/StrictDomainRegexTest.kt b/app/src/androidTest/java/dev/msfjarvis/aps/util/viewmodel/StrictDomainRegexTest.kt
index fc76deef..575c5aa7 100644
--- a/app/src/androidTest/java/dev/msfjarvis/aps/util/viewmodel/StrictDomainRegexTest.kt
+++ b/app/src/androidTest/java/dev/msfjarvis/aps/util/viewmodel/StrictDomainRegexTest.kt
@@ -10,40 +10,46 @@ import kotlin.test.assertTrue
import org.junit.Test
private infix fun String.matchedForDomain(domain: String) =
- SearchableRepositoryViewModel.generateStrictDomainRegex(domain)?.containsMatchIn(this) == true
+ SearchableRepositoryViewModel.generateStrictDomainRegex(domain)?.containsMatchIn(this) == true
class StrictDomainRegexTest {
- @Test fun acceptsLiteralDomain() {
- assertTrue("work/example.org/john.doe@example.org.gpg" matchedForDomain "example.org")
- assertTrue("example.org/john.doe@example.org.gpg" matchedForDomain "example.org")
- assertTrue("example.org.gpg" matchedForDomain "example.org")
- }
-
- @Test fun acceptsSubdomains() {
- assertTrue("work/www.example.org/john.doe@example.org.gpg" matchedForDomain "example.org")
- assertTrue("www2.example.org/john.doe@example.org.gpg" matchedForDomain "example.org")
- assertTrue("www.login.example.org.gpg" matchedForDomain "example.org")
- }
-
- @Test fun rejectsPhishingAttempts() {
- assertFalse("example.org.gpg" matchedForDomain "xample.org")
- assertFalse("login.example.org.gpg" matchedForDomain "xample.org")
- assertFalse("example.org/john.doe@exmple.org.gpg" matchedForDomain "xample.org")
- assertFalse("example.org.gpg" matchedForDomain "e/xample.org")
- }
-
- @Test fun rejectNonGpgComponentMatches() {
- assertFalse("work/example.org" matchedForDomain "example.org")
- }
-
- @Test fun rejectsEmailAddresses() {
- assertFalse("work/notexample.org/john.doe@example.org.gpg" matchedForDomain "example.org")
- assertFalse("work/notexample.org/john.doe@www.example.org.gpg" matchedForDomain "example.org")
- assertFalse("work/john.doe@www.example.org/foo.org" matchedForDomain "example.org")
- }
-
- @Test fun rejectsPathSeparators() {
- assertNull(SearchableRepositoryViewModel.generateStrictDomainRegex("ex/ample.org"))
- }
+ @Test
+ fun acceptsLiteralDomain() {
+ assertTrue("work/example.org/john.doe@example.org.gpg" matchedForDomain "example.org")
+ assertTrue("example.org/john.doe@example.org.gpg" matchedForDomain "example.org")
+ assertTrue("example.org.gpg" matchedForDomain "example.org")
+ }
+
+ @Test
+ fun acceptsSubdomains() {
+ assertTrue("work/www.example.org/john.doe@example.org.gpg" matchedForDomain "example.org")
+ assertTrue("www2.example.org/john.doe@example.org.gpg" matchedForDomain "example.org")
+ assertTrue("www.login.example.org.gpg" matchedForDomain "example.org")
+ }
+
+ @Test
+ fun rejectsPhishingAttempts() {
+ assertFalse("example.org.gpg" matchedForDomain "xample.org")
+ assertFalse("login.example.org.gpg" matchedForDomain "xample.org")
+ assertFalse("example.org/john.doe@exmple.org.gpg" matchedForDomain "xample.org")
+ assertFalse("example.org.gpg" matchedForDomain "e/xample.org")
+ }
+
+ @Test
+ fun rejectNonGpgComponentMatches() {
+ assertFalse("work/example.org" matchedForDomain "example.org")
+ }
+
+ @Test
+ fun rejectsEmailAddresses() {
+ assertFalse("work/notexample.org/john.doe@example.org.gpg" matchedForDomain "example.org")
+ assertFalse("work/notexample.org/john.doe@www.example.org.gpg" matchedForDomain "example.org")
+ assertFalse("work/john.doe@www.example.org/foo.org" matchedForDomain "example.org")
+ }
+
+ @Test
+ fun rejectsPathSeparators() {
+ assertNull(SearchableRepositoryViewModel.generateStrictDomainRegex("ex/ample.org"))
+ }
}