Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffret-b committed Mar 5, 2021
2 parents f807832 + 6f7d06b commit b0a8f67
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,11 @@
<artifactId>bcpkix-jdk15on</artifactId>
<version>1.68</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.11.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
14 changes: 8 additions & 6 deletions src/test/java/jenkins/bouncycastle/EncodingDecodingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

package jenkins.bouncycastle;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.contentOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
Expand Down Expand Up @@ -122,7 +124,7 @@ public void testReadOnlyPrivateKeyPEM() throws Exception {
pemEncOnlyPrivate.write(onlyPrivate);
assertTrue(Arrays.equals(pemEncOnlyPrivate.toPrivateKey().getEncoded(),
pemEnc.toPrivateKey().getEncoded()));
assertEquals(FileUtils.readFileToString(PRIVATE_KEY_PEM), FileUtils.readFileToString(onlyPrivate));
assertThat(contentOf(onlyPrivate)).isEqualToNormalizingNewlines(contentOf(PRIVATE_KEY_PEM));
}

@Test
Expand Down Expand Up @@ -186,7 +188,7 @@ public void testWritePublicKeyPEM() throws Exception {
PEMEncodable pemEnc = PEMEncodable.read(PUBLIC_KEY_PEM);
pemEnc.write(pemFileNew);

assertEquals(FileUtils.readFileToString(PUBLIC_KEY_PEM), FileUtils.readFileToString(pemFileNew));
assertThat(contentOf(pemFileNew)).isEqualToNormalizingNewlines(contentOf(PUBLIC_KEY_PEM));
}

@Test
Expand All @@ -196,7 +198,7 @@ public void testWritePrivateKeyPEM() throws Exception {
PEMEncodable pemEnc = PEMEncodable.read(PRIVATE_KEY_PEM);
pemEnc.write(pemFileNew);

assertEquals(FileUtils.readFileToString(PRIVATE_KEY_PEM), FileUtils.readFileToString(pemFileNew));
assertThat(contentOf(pemFileNew)).isEqualToNormalizingNewlines(contentOf(PRIVATE_KEY_PEM));
}

@Test
Expand All @@ -206,7 +208,7 @@ public void testWriteCertificatePEM() throws Exception {
PEMEncodable pemEnc = PEMEncodable.read(CERTIFICATE_PW_PEM);
pemEnc.write(pemFileNew);

assertEquals(FileUtils.readFileToString(CERTIFICATE_PW_PEM), FileUtils.readFileToString(pemFileNew));
assertThat(contentOf(pemFileNew)).isEqualToNormalizingNewlines(contentOf(CERTIFICATE_PW_PEM));
}

@Test
Expand All @@ -216,7 +218,7 @@ public void testCreationFromObjectPublicKeyPEM() throws Exception {
PEMEncodable pemEnc = PEMEncodable.read(PUBLIC_KEY_PEM);
PEMEncodable.create(pemEnc.toPublicKey()).write(pemFileNew);

assertEquals(FileUtils.readFileToString(PUBLIC_KEY_PEM), FileUtils.readFileToString(pemFileNew));
assertThat(contentOf(pemFileNew)).isEqualToNormalizingNewlines(contentOf(PUBLIC_KEY_PEM));
}

@Test
Expand All @@ -226,7 +228,7 @@ public void testCreationFromObjectPrivateKeyPEM() throws Exception {
PEMEncodable pemEnc = PEMEncodable.read(PRIVATE_KEY_PEM);
PEMEncodable.create(pemEnc.toKeyPair()).write(pemFileNew);

assertEquals(FileUtils.readFileToString(PRIVATE_KEY_PEM), FileUtils.readFileToString(pemFileNew));
assertThat(contentOf(pemFileNew)).isEqualToNormalizingNewlines(contentOf(PRIVATE_KEY_PEM));
}


Expand Down

0 comments on commit b0a8f67

Please sign in to comment.