mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-08-29 13:27:46 +00:00
Expand tests for multiple identity keys (#1743)
This commit is contained in:
parent
82e3ba6ce5
commit
f08ad35d2e
3
.github/workflows/pull_request.yml
vendored
3
.github/workflows/pull_request.yml
vendored
@ -6,6 +6,9 @@ concurrency:
|
|||||||
group: ${{ github.head_ref }}
|
group: ${{ github.head_ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
env:
|
||||||
|
SENTRY_DSN: 'https://public_key@example.com/project_id'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check-codestyle:
|
check-codestyle:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -11,11 +11,7 @@ val INVOKED_FROM_IDE_PROPERTY = "android.injected.invoked.from.ide"
|
|||||||
android {
|
android {
|
||||||
androidComponents {
|
androidComponents {
|
||||||
onVariants(selector().withFlavor(FlavorDimensions.FREE to ProductFlavors.NON_FREE)) { variant ->
|
onVariants(selector().withFlavor(FlavorDimensions.FREE to ProductFlavors.NON_FREE)) { variant ->
|
||||||
val sentryDsn =
|
val sentryDsn = project.providers.environmentVariable(SENTRY_DSN_PROPERTY)
|
||||||
project
|
|
||||||
.providers
|
|
||||||
.environmentVariable(SENTRY_DSN_PROPERTY)
|
|
||||||
.orElse("https://public_key@example.com/project_id")
|
|
||||||
if (sentryDsn.isPresent) {
|
if (sentryDsn.isPresent) {
|
||||||
variant.manifestPlaceholders.put("sentryDsn", sentryDsn.get())
|
variant.manifestPlaceholders.put("sentryDsn", sentryDsn.get())
|
||||||
} else if (project.providers.gradleProperty(INVOKED_FROM_IDE_PROPERTY).orNull != "true") {
|
} else if (project.providers.gradleProperty(INVOKED_FROM_IDE_PROPERTY).orNull != "true") {
|
||||||
|
@ -4,6 +4,7 @@ import dev.msfjarvis.aps.crypto.KeyUtils.tryGetId
|
|||||||
import dev.msfjarvis.aps.crypto.KeyUtils.tryParseKeyring
|
import dev.msfjarvis.aps.crypto.KeyUtils.tryParseKeyring
|
||||||
import dev.msfjarvis.aps.crypto.TestUtils.getArmoredPrivateKeyWithMultipleIdentities
|
import dev.msfjarvis.aps.crypto.TestUtils.getArmoredPrivateKeyWithMultipleIdentities
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
|
import kotlin.test.assertEquals
|
||||||
import kotlin.test.assertIs
|
import kotlin.test.assertIs
|
||||||
import kotlin.test.assertNotNull
|
import kotlin.test.assertNotNull
|
||||||
import org.bouncycastle.openpgp.PGPSecretKeyRing
|
import org.bouncycastle.openpgp.PGPSecretKeyRing
|
||||||
@ -18,5 +19,6 @@ class KeyUtilsTest {
|
|||||||
val keyId = tryGetId(key)
|
val keyId = tryGetId(key)
|
||||||
assertNotNull(keyId)
|
assertNotNull(keyId)
|
||||||
assertIs<GpgIdentifier.KeyId>(keyId)
|
assertIs<GpgIdentifier.KeyId>(keyId)
|
||||||
|
assertEquals("b950ae2813841585", keyId.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,12 @@ import com.github.michaelbull.result.unwrap
|
|||||||
import com.github.michaelbull.result.unwrapError
|
import com.github.michaelbull.result.unwrapError
|
||||||
import dev.msfjarvis.aps.crypto.GpgIdentifier.KeyId
|
import dev.msfjarvis.aps.crypto.GpgIdentifier.KeyId
|
||||||
import dev.msfjarvis.aps.crypto.GpgIdentifier.UserId
|
import dev.msfjarvis.aps.crypto.GpgIdentifier.UserId
|
||||||
|
import dev.msfjarvis.aps.crypto.TestUtils.getArmoredPrivateKeyWithMultipleIdentities
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import kotlin.test.AfterTest
|
import kotlin.test.AfterTest
|
||||||
import kotlin.test.BeforeTest
|
import kotlin.test.BeforeTest
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
|
import kotlin.test.assertContentEquals
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
import kotlin.test.assertIs
|
import kotlin.test.assertIs
|
||||||
import kotlin.test.assertNotNull
|
import kotlin.test.assertNotNull
|
||||||
@ -168,4 +170,17 @@ class PGPKeyManagerTest {
|
|||||||
val singleKeyList = keyManager.getAllKeys().unwrap()
|
val singleKeyList = keyManager.getAllKeys().unwrap()
|
||||||
assertEquals(1, singleKeyList.size)
|
assertEquals(1, singleKeyList.size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testGettingMultipleIdentityKeyWithBothUserIDs() {
|
||||||
|
scope.runTest {
|
||||||
|
val key = PGPKey(getArmoredPrivateKeyWithMultipleIdentities())
|
||||||
|
keyManager.addKey(key).unwrap()
|
||||||
|
|
||||||
|
val johnKey = keyManager.getKeyById(UserId("john@doe.org")).unwrap()
|
||||||
|
val janeKey = keyManager.getKeyById(UserId("jane@doe.org")).unwrap()
|
||||||
|
|
||||||
|
assertContentEquals(johnKey.contents, janeKey.contents)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user