1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-09-09 18:29:39 +02:00

Add test for PolicyAdapter properly adapting NotationRegistry implementations

This commit is contained in:
Paul Schaub 2025-06-16 11:21:31 +02:00
parent aa1f99fe39
commit 9617b35703
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -0,0 +1,37 @@
// SPDX-FileCopyrightText: 2025 Paul Schaub <vanitasvitae@fsfe.org>
//
// SPDX-License-Identifier: Apache-2.0
package org.bouncycastle;
import org.bouncycastle.openpgp.api.OpenPGPPolicy;
import org.junit.jupiter.api.Test;
import org.pgpainless.PGPainless;
import org.pgpainless.bouncycastle.PolicyAdapter;
import org.pgpainless.policy.Policy;
import org.pgpainless.util.NotationRegistry;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class PolicyAdapterTest {
@Test
public void testNotationRegistryAdaption() {
NotationRegistry pgpainlessNotationReg = new NotationRegistry();
pgpainlessNotationReg.addKnownNotation("foo");
Policy policy = PGPainless.getInstance().getAlgorithmPolicy()
.copy()
.withNotationRegistry(pgpainlessNotationReg)
.build();
PolicyAdapter adapter = new PolicyAdapter(policy);
OpenPGPPolicy.OpenPGPNotationRegistry bcNotationReg = adapter.getNotationRegistry();
assertTrue(bcNotationReg.isNotationKnown("foo"));
assertFalse(bcNotationReg.isNotationKnown("bar"));
bcNotationReg.addKnownNotation("bar");
assertTrue(pgpainlessNotationReg.isKnownNotation("bar"));
}
}