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:
parent
8d00ecf3fc
commit
fdcdf6270f
1 changed files with 37 additions and 0 deletions
|
@ -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"));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue