mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-25 12:27:58 +01:00
Improve image attribute test
This commit is contained in:
parent
0d3fb446a8
commit
05c203177e
1 changed files with 12 additions and 6 deletions
|
@ -4,8 +4,11 @@
|
||||||
|
|
||||||
package org.pgpainless.key.generation
|
package org.pgpainless.key.generation
|
||||||
|
|
||||||
|
import java.io.InputStream
|
||||||
import org.bouncycastle.bcpg.attr.ImageAttribute
|
import org.bouncycastle.bcpg.attr.ImageAttribute
|
||||||
import org.bouncycastle.openpgp.PGPUserAttributeSubpacketVectorGenerator
|
import org.bouncycastle.openpgp.PGPUserAttributeSubpacketVectorGenerator
|
||||||
|
import org.bouncycastle.util.io.Streams
|
||||||
|
import org.junit.jupiter.api.Assertions.assertArrayEquals
|
||||||
import org.junit.jupiter.api.Assertions.assertTrue
|
import org.junit.jupiter.api.Assertions.assertTrue
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.junit.jupiter.api.assertThrows
|
import org.junit.jupiter.api.assertThrows
|
||||||
|
@ -20,7 +23,6 @@ import org.pgpainless.key.generation.type.xdh.XDHSpec
|
||||||
import org.pgpainless.key.protection.SecretKeyRingProtector
|
import org.pgpainless.key.protection.SecretKeyRingProtector
|
||||||
import org.pgpainless.policy.Policy
|
import org.pgpainless.policy.Policy
|
||||||
import org.pgpainless.util.DateUtil
|
import org.pgpainless.util.DateUtil
|
||||||
import java.io.InputStream
|
|
||||||
|
|
||||||
class GenerateOpenPgpKeyTest {
|
class GenerateOpenPgpKeyTest {
|
||||||
|
|
||||||
|
@ -83,12 +85,16 @@ class GenerateOpenPgpKeyTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testKeyGenerationWithJPEGAttribute() {
|
fun testKeyGenerationWithJPEGAttribute() {
|
||||||
val key = GenerateOpenPgpKey(Policy.getInstance())
|
val key =
|
||||||
|
GenerateOpenPgpKey(Policy.getInstance())
|
||||||
.buildV4Key(KeyType.EDDSA(EdDSACurve._Ed25519))
|
.buildV4Key(KeyType.EDDSA(EdDSACurve._Ed25519))
|
||||||
.addJpegImage(requireResource("suzanne.jpg"))
|
.addJpegImage(requireResource("suzanne.jpg"))
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
assertTrue(key.publicKey.userAttributes.hasNext())
|
assertTrue(key.publicKey.userAttributes.hasNext())
|
||||||
|
assertArrayEquals(
|
||||||
|
Streams.readAll(requireResource("suzanne.jpg")),
|
||||||
|
key.publicKey.userAttributes.next().imageAttribute.imageData)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun requireResource(resourceName: String): InputStream {
|
private fun requireResource(resourceName: String): InputStream {
|
||||||
|
|
Loading…
Reference in a new issue