mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-23 03:17:58 +01:00
Add tests for PGPKeyRingExtensions
This commit is contained in:
parent
c89c47c491
commit
c2abc89d5e
1 changed files with 72 additions and 0 deletions
|
@ -0,0 +1,72 @@
|
|||
// SPDX-FileCopyrightText: 2024 Paul Schaub <vanitasvitae@fsfe.org>
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package org.pgpainless.bouncycastle.extensions
|
||||
|
||||
import org.junit.jupiter.api.Assertions.assertDoesNotThrow
|
||||
import org.junit.jupiter.api.Assertions.assertFalse
|
||||
import org.junit.jupiter.api.Assertions.assertNotNull
|
||||
import org.junit.jupiter.api.Assertions.assertTrue
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.assertThrows
|
||||
import org.pgpainless.key.TestKeys
|
||||
|
||||
class PGPKeyRingExtensionsTest {
|
||||
|
||||
@Test
|
||||
fun `public key ring has public key`() {
|
||||
val key = TestKeys.getJulietPublicKeyRing()
|
||||
assertTrue(key.hasPublicKey(TestKeys.JULIET_KEY_ID))
|
||||
assertTrue(key.hasPublicKey(TestKeys.JULIET_FINGERPRINT))
|
||||
|
||||
assertFalse(key.hasPublicKey(TestKeys.ROMEO_KEY_ID))
|
||||
assertFalse(key.hasPublicKey(TestKeys.ROMEO_FINGERPRINT))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `secret key ring has public key`() {
|
||||
val key = TestKeys.getJulietSecretKeyRing()
|
||||
assertTrue(key.hasPublicKey(TestKeys.JULIET_KEY_ID))
|
||||
assertTrue(key.hasPublicKey(TestKeys.JULIET_FINGERPRINT))
|
||||
|
||||
assertFalse(key.hasPublicKey(TestKeys.ROMEO_KEY_ID))
|
||||
assertFalse(key.hasPublicKey(TestKeys.ROMEO_FINGERPRINT))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test requirePublicKey on secret key ring`() {
|
||||
val key = TestKeys.getJulietSecretKeyRing()
|
||||
assertNotNull(assertDoesNotThrow {
|
||||
key.requirePublicKey(TestKeys.JULIET_KEY_ID)
|
||||
})
|
||||
assertNotNull(assertDoesNotThrow {
|
||||
key.requirePublicKey(TestKeys.JULIET_FINGERPRINT)
|
||||
})
|
||||
|
||||
assertThrows<NoSuchElementException> {
|
||||
key.requirePublicKey(TestKeys.ROMEO_KEY_ID)
|
||||
}
|
||||
assertThrows<NoSuchElementException> {
|
||||
key.requirePublicKey(TestKeys.ROMEO_FINGERPRINT)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test requirePublicKey on public key ring`() {
|
||||
val key = TestKeys.getJulietPublicKeyRing()
|
||||
assertNotNull(assertDoesNotThrow {
|
||||
key.requirePublicKey(TestKeys.JULIET_KEY_ID)
|
||||
})
|
||||
assertNotNull(assertDoesNotThrow {
|
||||
key.requirePublicKey(TestKeys.JULIET_FINGERPRINT)
|
||||
})
|
||||
|
||||
assertThrows<NoSuchElementException> {
|
||||
key.requirePublicKey(TestKeys.ROMEO_KEY_ID)
|
||||
}
|
||||
assertThrows<NoSuchElementException> {
|
||||
key.requirePublicKey(TestKeys.ROMEO_FINGERPRINT)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue