aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2022-02-22 14:33:03 +0530
committerGitHub <noreply@github.com>2022-02-22 14:33:03 +0530
commitf08ad35d2e26b3f222cca4f973a865bdd815eeb3 (patch)
tree48c6d6bab17309de5ec4a8429799a59ddf1ce659
parent82e3ba6ce5bf770ea5b81fa5debdf7472e916cfd (diff)
Expand tests for multiple identity keys (#1743)
-rw-r--r--.github/workflows/pull_request.yml3
-rw-r--r--build-logic/android-plugins/src/main/kotlin/com.github.android-password-store.sentry.gradle.kts6
-rw-r--r--crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/KeyUtilsTest.kt2
-rw-r--r--crypto-pgpainless/src/test/kotlin/dev/msfjarvis/aps/crypto/PGPKeyManagerTest.kt15
4 files changed, 21 insertions, 5 deletions
diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml
index bad91e27..a7841ac4 100644
--- a/.github/workflows/pull_request.yml
+++ b/.github/workflows/pull_request.yml
@@ -6,6 +6,9 @@ concurrency:
group: ${{ github.head_ref }}
cancel-in-progress: true
+env:
+ SENTRY_DSN: 'https://public_key@example.com/project_id'
+
jobs:
check-codestyle:
runs-on: ubuntu-latest
diff --git a/build-logic/android-plugins/src/main/kotlin/com.github.android-password-store.sentry.gradle.kts b/build-logic/android-plugins/src/main/kotlin/com.github.android-password-store.sentry.gradle.kts
index 3648ccf0..4c22e8c8 100644
--- a/build-logic/android-plugins/src/main/kotlin/com.github.android-password-store.sentry.gradle.kts
+++ b/build-logic/android-plugins/src/main/kotlin/com.github.android-password-store.sentry.gradle.kts
@@ -11,11 +11,7 @@ val INVOKED_FROM_IDE_PROPERTY = "android.injected.invoked.from.ide"
android {
androidComponents {
onVariants(selector().withFlavor(FlavorDimensions.FREE to ProductFlavors.NON_FREE)) { variant ->
- val sentryDsn =
- project
- .providers
- .environmentVariable(SENTRY_DSN_PROPERTY)
- .orElse("https://public_key@example.com/project_id")
+ val sentryDsn = project.providers.environmentVariable(SENTRY_DSN_PROPERTY)
if (sentryDsn.isPresent) {
variant.manifestPlaceholders.put("sentryDsn", sentryDsn.get())
} else if (project.providers.gradleProperty(INVOKED_FROM_IDE_PROPERTY).orNull != "true") {
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 80c14254..14ac2263 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
@@ -4,6 +4,7 @@ import dev.msfjarvis.aps.crypto.KeyUtils.tryGetId
import dev.msfjarvis.aps.crypto.KeyUtils.tryParseKeyring
import dev.msfjarvis.aps.crypto.TestUtils.getArmoredPrivateKeyWithMultipleIdentities
import kotlin.test.Test
+import kotlin.test.assertEquals
import kotlin.test.assertIs
import kotlin.test.assertNotNull
import org.bouncycastle.openpgp.PGPSecretKeyRing
@@ -18,5 +19,6 @@ class KeyUtilsTest {
val keyId = tryGetId(key)
assertNotNull(keyId)
assertIs<GpgIdentifier.KeyId>(keyId)
+ assertEquals("b950ae2813841585", keyId.toString())
}
}
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 24b27ef8..650f3d89 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
@@ -4,10 +4,12 @@ import com.github.michaelbull.result.unwrap
import com.github.michaelbull.result.unwrapError
import dev.msfjarvis.aps.crypto.GpgIdentifier.KeyId
import dev.msfjarvis.aps.crypto.GpgIdentifier.UserId
+import dev.msfjarvis.aps.crypto.TestUtils.getArmoredPrivateKeyWithMultipleIdentities
import java.io.File
import kotlin.test.AfterTest
import kotlin.test.BeforeTest
import kotlin.test.Test
+import kotlin.test.assertContentEquals
import kotlin.test.assertEquals
import kotlin.test.assertIs
import kotlin.test.assertNotNull
@@ -168,4 +170,17 @@ class PGPKeyManagerTest {
val singleKeyList = keyManager.getAllKeys().unwrap()
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)
+ }
+ }
}