From ce486b1140978f39bcbb4ba07aa5a787dfdbbbd0 Mon Sep 17 00:00:00 2001 From: Luciano Balmaceda Date: Fri, 3 Nov 2017 10:13:58 -0300 Subject: [PATCH] ensure bc provider is being used --- .../ECDSABouncyCastleProviderTests.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/src/test/java/com/auth0/jwt/algorithms/ECDSABouncyCastleProviderTests.java b/lib/src/test/java/com/auth0/jwt/algorithms/ECDSABouncyCastleProviderTests.java index 0e38e64f..4af1c4ec 100644 --- a/lib/src/test/java/com/auth0/jwt/algorithms/ECDSABouncyCastleProviderTests.java +++ b/lib/src/test/java/com/auth0/jwt/algorithms/ECDSABouncyCastleProviderTests.java @@ -6,8 +6,8 @@ import com.auth0.jwt.interfaces.ECDSAKeyProvider; import org.apache.commons.codec.binary.Base64; import org.bouncycastle.jce.provider.BouncyCastleProvider; -import org.junit.After; -import org.junit.Before; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -46,7 +46,7 @@ public class ECDSABouncyCastleProviderTests { @Rule public ExpectedException exception = ExpectedException.none(); - private final BouncyCastleProvider bcProvider = new BouncyCastleProvider(); + private static final Provider bcProvider = new BouncyCastleProvider(); //JOSE Signatures obtained using Node 'jwa' lib: https://github.com/brianloveswords/node-jwa //DER Signatures obtained from source JOSE signature using 'ecdsa-sig-formatter' lib: https://github.com/Brightspace/node-ecdsa-sig-formatter @@ -54,17 +54,21 @@ public class ECDSABouncyCastleProviderTests { //These tests add and use the BouncyCastle SecurityProvider to handle ECDSA algorithms - @Before - public void setUp() throws Exception { + @BeforeClass + public static void setUp() throws Exception { //Set BC as the preferred bcProvider Security.insertProviderAt(bcProvider, 1); } - @After - public void tearDown() throws Exception { + @AfterClass + public static void tearDown() throws Exception { Security.removeProvider(bcProvider.getName()); } + @Test + public void shouldPreferBouncyCastleProvider() throws Exception { + assertThat(Security.getProviders()[0], is(equalTo(bcProvider))); + } // Verify