diff --git a/app/src/test/java/dev/msfjarvis/aps/util/crypto/GpgIdentifierTest.kt b/app/src/test/java/dev/msfjarvis/aps/util/crypto/GpgIdentifierTest.kt index 9f27108c..8c3272ef 100644 --- a/app/src/test/java/dev/msfjarvis/aps/util/crypto/GpgIdentifierTest.kt +++ b/app/src/test/java/dev/msfjarvis/aps/util/crypto/GpgIdentifierTest.kt @@ -12,28 +12,28 @@ import kotlin.test.assertTrue class GpgIdentifierTest { @Test - fun `parses hexadecimal key id without leading 0x`() { + fun parseHexKeyIdWithout0xPrefix() { val identifier = GpgIdentifier.fromString("79E8208280490C77") assertNotNull(identifier) assertTrue { identifier is GpgIdentifier.KeyId } } @Test - fun `parses hexadecimal key id`() { + fun parseHexKeyId() { val identifier = GpgIdentifier.fromString("0x79E8208280490C77") assertNotNull(identifier) assertTrue { identifier is GpgIdentifier.KeyId } } @Test - fun `parses email as user id`() { + fun parseValidEmail() { val identifier = GpgIdentifier.fromString("john.doe@example.org") assertNotNull(identifier) assertTrue { identifier is GpgIdentifier.UserId } } @Test - fun `parses user@host without TLD`() { + fun parseEmailWithoutTLD() { val identifier = GpgIdentifier.fromString("john.doe@example") assertNotNull(identifier) assertTrue { identifier is GpgIdentifier.UserId } diff --git a/build-logic/android-plugins/build.gradle.kts b/build-logic/android-plugins/build.gradle.kts index ac70bec8..1ffce784 100644 --- a/build-logic/android-plugins/build.gradle.kts +++ b/build-logic/android-plugins/build.gradle.kts @@ -17,7 +17,10 @@ afterEvaluate { } tasks.withType().configureEach { - kotlinOptions { jvmTarget = JavaVersion.VERSION_11.toString() } + kotlinOptions { + jvmTarget = JavaVersion.VERSION_11.toString() + freeCompilerArgs = freeCompilerArgs + "-Xsam-conversions=class" + } } } diff --git a/build-logic/automation-plugins/build.gradle.kts b/build-logic/automation-plugins/build.gradle.kts index 8ec63671..83b89079 100644 --- a/build-logic/automation-plugins/build.gradle.kts +++ b/build-logic/automation-plugins/build.gradle.kts @@ -17,7 +17,10 @@ afterEvaluate { } tasks.withType().configureEach { - kotlinOptions { jvmTarget = JavaVersion.VERSION_11.toString() } + kotlinOptions { + jvmTarget = JavaVersion.VERSION_11.toString() + freeCompilerArgs = freeCompilerArgs + "-Xsam-conversions=class" + } } } diff --git a/build-logic/kotlin-plugins/build.gradle.kts b/build-logic/kotlin-plugins/build.gradle.kts index 5fd5ba0c..6d2606ed 100644 --- a/build-logic/kotlin-plugins/build.gradle.kts +++ b/build-logic/kotlin-plugins/build.gradle.kts @@ -17,7 +17,10 @@ afterEvaluate { } tasks.withType().configureEach { - kotlinOptions { jvmTarget = JavaVersion.VERSION_11.toString() } + kotlinOptions { + jvmTarget = JavaVersion.VERSION_11.toString() + freeCompilerArgs = freeCompilerArgs + "-Xsam-conversions=class" + } } } diff --git a/crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/errors/CryptoException.kt b/crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/errors/CryptoException.kt index 0fb75691..aee23710 100644 --- a/crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/errors/CryptoException.kt +++ b/crypto-common/src/main/kotlin/dev/msfjarvis/aps/crypto/errors/CryptoException.kt @@ -22,15 +22,15 @@ public object KeyDeletionFailedException : KeyManagerException("Couldn't delete public object InvalidKeyException : KeyManagerException("Given key cannot be parsed as a known key type") -/** No key matching [keyId] could be found. */ +/** No key matching `keyId` could be found. */ public class KeyNotFoundException(keyId: String) : KeyManagerException("No key found with id: $keyId") -/** Attempting to add another key for [keyId] without requesting a replace. */ +/** Attempting to add another key for `keyId` without requesting a replace. */ public class KeyAlreadyExistsException(keyId: String) : KeyManagerException("Pre-existing key was found for $keyId") -/** Sealed exception types for [CryptoHandler]. */ +/** Sealed exception types for [dev.msfjarvis.aps.crypto.CryptoHandler]. */ public sealed class CryptoHandlerException(message: String? = null, cause: Throwable? = null) : CryptoException(message, cause) diff --git a/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/GpgIdentifierTest.kt b/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/GpgIdentifierTest.kt index 3860873c..aaf20cd8 100644 --- a/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/GpgIdentifierTest.kt +++ b/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/GpgIdentifierTest.kt @@ -12,28 +12,28 @@ import kotlin.test.assertTrue class GpgIdentifierTest { @Test - fun `parses hexadecimal key id without leading 0x`() { + fun parseHexKeyIdWithout0xPrefix() { val identifier = GpgIdentifier.fromString("79E8208280490C77") assertNotNull(identifier) assertTrue { identifier is GpgIdentifier.KeyId } } @Test - fun `parses hexadecimal key id`() { + fun parseHexKeyId() { val identifier = GpgIdentifier.fromString("0x79E8208280490C77") assertNotNull(identifier) assertTrue { identifier is GpgIdentifier.KeyId } } @Test - fun `parses email as user id`() { + fun parseValidEmail() { val identifier = GpgIdentifier.fromString("john.doe@example.org") assertNotNull(identifier) assertTrue { identifier is GpgIdentifier.UserId } } @Test - fun `parses user@host without TLD`() { + fun parseEmailWithoutTLD() { val identifier = GpgIdentifier.fromString("john.doe@example") assertNotNull(identifier) assertTrue { identifier is GpgIdentifier.UserId } diff --git a/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/KeyUtilsTest.kt b/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/KeyUtilsTest.kt index 14ac2263..33597f9f 100644 --- a/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/KeyUtilsTest.kt +++ b/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/KeyUtilsTest.kt @@ -11,7 +11,7 @@ import org.bouncycastle.openpgp.PGPSecretKeyRing class KeyUtilsTest { @Test - fun `parse GPG key with multiple identities`() { + fun parseKeyWithMultipleIdentities() { val key = PGPKey(getArmoredPrivateKeyWithMultipleIdentities()) val keyring = tryParseKeyring(key) assertNotNull(keyring) diff --git a/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/PGPKeyManagerTest.kt b/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/PGPKeyManagerTest.kt index 1439d52d..cf33b53f 100644 --- a/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/PGPKeyManagerTest.kt +++ b/crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/PGPKeyManagerTest.kt @@ -51,7 +51,7 @@ class PGPKeyManagerTest { } @Test - fun testAddingKey() = + fun addKey() = scope.runTest { // Check if the key id returned is correct val keyId = keyManager.getKeyId(keyManager.addKey(key).unwrap()) @@ -66,7 +66,7 @@ class PGPKeyManagerTest { } @Test - fun testAddingKeyWithoutReplaceFlag() = + fun addKeyWithoutReplaceFlag() = scope.runTest { // Check adding the keys twice keyManager.addKey(key, false).unwrap() @@ -76,7 +76,7 @@ class PGPKeyManagerTest { } @Test - fun testAddingKeyWithReplaceFlag() = + fun addKeyWithReplaceFlag() = scope.runTest { // Check adding the keys twice keyManager.addKey(key, true).unwrap() @@ -86,7 +86,7 @@ class PGPKeyManagerTest { } @Test - fun testRemovingKey() = + fun removeKey() = scope.runTest { // Add key using KeyManager keyManager.addKey(key).unwrap() @@ -101,7 +101,7 @@ class PGPKeyManagerTest { } @Test - fun testGetExistingKeyById() = + fun getKeyById() = scope.runTest { // Add key using KeyManager keyManager.addKey(key).unwrap() @@ -116,7 +116,7 @@ class PGPKeyManagerTest { } @Test - fun testGetExistingKeyByFullUserId() = + fun getKeyByFullUserId() = scope.runTest { keyManager.addKey(key).unwrap() @@ -126,7 +126,7 @@ class PGPKeyManagerTest { } @Test - fun testGetExistingKeyByEmailUserId() = + fun getKeyByEmailUserId() = scope.runTest { keyManager.addKey(key).unwrap() @@ -136,7 +136,7 @@ class PGPKeyManagerTest { } @Test - fun testGetNonExistentKey() = + fun getNonExistentKey() = scope.runTest { // Add key using KeyManager keyManager.addKey(key).unwrap() @@ -150,7 +150,7 @@ class PGPKeyManagerTest { } @Test - fun testFindKeysWithoutAdding() = + fun findNonExistentKey() = scope.runTest { // Check returned key val error = keyManager.getKeyById(KeyId(0x08edf7567183ce44)).unwrapError() @@ -159,7 +159,7 @@ class PGPKeyManagerTest { } @Test - fun testGettingAllKeys() = + fun getAllKeys() = scope.runTest { // TODO: Should we check for more than 1 keys? // Check if KeyManager returns no key @@ -175,7 +175,7 @@ class PGPKeyManagerTest { } @Test - fun testGettingMultipleIdentityKeyWithBothUserIDs() { + fun getMultipleIdentityKeyWithAllIdentities() { scope.runTest { val key = PGPKey(getArmoredPrivateKeyWithMultipleIdentities()) keyManager.addKey(key).unwrap() diff --git a/format-common/src/test/kotlin/dev/msfjarvis/aps/data/passfile/PasswordEntryTest.kt b/format-common/src/test/kotlin/dev/msfjarvis/aps/data/passfile/PasswordEntryTest.kt index 201eb611..27fbe0e2 100644 --- a/format-common/src/test/kotlin/dev/msfjarvis/aps/data/passfile/PasswordEntryTest.kt +++ b/format-common/src/test/kotlin/dev/msfjarvis/aps/data/passfile/PasswordEntryTest.kt @@ -34,7 +34,7 @@ class PasswordEntryTest { ) @Test - fun testGetPassword() { + fun getPassword() { assertEquals("fooooo", makeEntry("fooooo\nbla\n").password) assertEquals("fooooo", makeEntry("fooooo\nbla").password) assertEquals("fooooo", makeEntry("fooooo\n").password) @@ -52,7 +52,7 @@ class PasswordEntryTest { } @Test - fun testGetExtraContent() { + fun getExtraContent() { assertEquals("bla\n", makeEntry("fooooo\nbla\n").extraContentString) assertEquals("bla", makeEntry("fooooo\nbla").extraContentString) assertEquals("", makeEntry("fooooo\n").extraContentString) @@ -103,7 +103,7 @@ class PasswordEntryTest { } @Test - fun testGetUsername() { + fun getUsername() { for (field in PasswordEntry.USERNAME_FIELDS) { assertEquals("username", makeEntry("\n$field username").username) assertEquals( @@ -123,7 +123,7 @@ class PasswordEntryTest { } @Test - fun testHasUsername() { + fun hasUsername() { assertNotNull(makeEntry("secret\nextra\nlogin: username\ncontent\n").username) assertNull(makeEntry("secret\nextra\ncontent\n").username) assertNull(makeEntry("secret\nlogin failed\n").username) @@ -132,7 +132,7 @@ class PasswordEntryTest { } @Test - fun testGeneratesOtpFromTotpUri() = runTest { + fun generatesOtpFromTotpUri() = runTest { val entry = makeEntry("secret\nextra\n$TOTP_URI") assertTrue(entry.hasTotp()) entry.totp.test { @@ -149,7 +149,7 @@ class PasswordEntryTest { * blocked https://msfjarvis.dev/aps/issue/1550. */ @Test - fun testGeneratedOtpHasCorrectRemainingTime() = runTest { + fun generatedOtpHasCorrectRemainingTime() = runTest { val entry = makeEntry("secret\nextra\n$TOTP_URI", TestUserClock.withAddedSeconds(5)) assertTrue(entry.hasTotp()) entry.totp.test { @@ -161,7 +161,7 @@ class PasswordEntryTest { } @Test - fun testGeneratesOtpWithOnlyUriInFile() = runTest { + fun generatesOtpWithOnlyUriInFile() = runTest { val entry = makeEntry(TOTP_URI) assertNull(entry.password) entry.totp.test { @@ -173,7 +173,7 @@ class PasswordEntryTest { } @Test - fun testOnlyLooksForUriInFirstLine() { + fun onlyLooksForUriInFirstLine() { val entry = makeEntry("id:\n$TOTP_URI") assertNotNull(entry.password) assertTrue(entry.hasTotp()) diff --git a/format-common/src/test/kotlin/dev/msfjarvis/aps/util/totp/OtpTest.kt b/format-common/src/test/kotlin/dev/msfjarvis/aps/util/totp/OtpTest.kt index 67195361..db74de3e 100644 --- a/format-common/src/test/kotlin/dev/msfjarvis/aps/util/totp/OtpTest.kt +++ b/format-common/src/test/kotlin/dev/msfjarvis/aps/util/totp/OtpTest.kt @@ -24,7 +24,7 @@ class OtpTest { } @Test - fun testOtpGeneration6Digits() { + fun otpGeneration6Digits() { assertEquals( "953550", generateOtp( @@ -46,7 +46,7 @@ class OtpTest { } @Test - fun testOtpGeneration10Digits() { + fun otpGeneration10Digits() { assertEquals( "0740900914", generateOtp( @@ -71,7 +71,7 @@ class OtpTest { } @Test - fun testOtpGenerationIllegalInput() { + fun otpGenerationIllegalInput() { assertNull( generateOtp( counter = 10000, @@ -108,7 +108,7 @@ class OtpTest { } @Test - fun testOtpGenerationUnusualSecrets() { + fun otpGenerationUnusualSecrets() { assertEquals( "127764", generateOtp( @@ -126,7 +126,7 @@ class OtpTest { } @Test - fun testOtpGenerationUnpaddedSecrets() { + fun otpGenerationUnpaddedSecrets() { // Secret was generated with `echo 'string with some padding needed' | base32` // We don't care for the resultant OTP's actual value, we just want both the padded and // unpadded variant to generate the same one. diff --git a/passgen/diceware/src/test/kotlin/dev/msfjarvis/aps/passgen/diceware/DicewarePassphraseGeneratorTest.kt b/passgen/diceware/src/test/kotlin/dev/msfjarvis/aps/passgen/diceware/DicewarePassphraseGeneratorTest.kt index 7f22fdcc..236be708 100644 --- a/passgen/diceware/src/test/kotlin/dev/msfjarvis/aps/passgen/diceware/DicewarePassphraseGeneratorTest.kt +++ b/passgen/diceware/src/test/kotlin/dev/msfjarvis/aps/passgen/diceware/DicewarePassphraseGeneratorTest.kt @@ -15,7 +15,7 @@ class DicewarePassphraseGeneratorTest { private val intGenerator = RandomIntGenerator { it.random(random) } @Test - fun generate_passphrase() { + fun generatePassphrase() { val die = Die(6, intGenerator) val generator = diff --git a/passgen/diceware/src/test/kotlin/dev/msfjarvis/aps/passgen/diceware/DieTest.kt b/passgen/diceware/src/test/kotlin/dev/msfjarvis/aps/passgen/diceware/DieTest.kt index 69a355c5..7f6398f6 100644 --- a/passgen/diceware/src/test/kotlin/dev/msfjarvis/aps/passgen/diceware/DieTest.kt +++ b/passgen/diceware/src/test/kotlin/dev/msfjarvis/aps/passgen/diceware/DieTest.kt @@ -17,19 +17,19 @@ class DieTest { private val intGenerator = RandomIntGenerator { it.random(random) } @Test - fun test_one_roll() { + fun oneRoll() { val die = Die(6, intGenerator) assertEquals(5, die.roll()) } @Test - fun test_multiple_rolls() { + fun multipleRolls() { val die = Die(6, intGenerator) assertEquals(526242, die.rollMultiple(6)) } @Test - fun test_consecutive_rolls() { + fun consecutiveRolls() { val die = Die(6, intGenerator) assertEquals(5, die.roll()) assertEquals(2, die.roll()) @@ -40,7 +40,7 @@ class DieTest { } @Test - fun test_100_sides() { + fun hundredSides() { val die = Die(100, intGenerator) assertEquals(67, die.roll()) }