abhishekaypurohit commented on a change in pull request #471: HDDS-2906. Added
Unit Test Cases ofr CRLCodec
URL: https://github.com/apache/hadoop-ozone/pull/471#discussion_r370308383
##########
File path:
hadoop-hdds/common/src/test/java/org/apache/hadoop/hdds/security/x509/certificate/utils/TestCRLCodec.java
##########
@@ -101,11 +122,124 @@ public void testWriteCRL() throws IOException,
OperatorCreationException {
builder.build(contentSignerBuilder.build(privateKey));
CRLCodec crlCodec = new CRLCodec(securityConfig);
- crlCodec.writeCRL(cRLHolder, CRL_FILE_NAME, true);
+ crlCodec.writeCRL(cRLHolder, this.securityConfig.getCrlName(), true);
X509CRLEntryHolder entryHolder =
cRLHolder.getRevokedCertificate(BigInteger.ONE);
assertNotNull(entryHolder);
+
+ // verify file generation
+ File crlFile =
+ Paths.get(crlCodec.getLocation().toString(),
+ this.securityConfig.getCrlName()).toFile();
+ assertTrue(crlFile.exists());
+
+ try (BufferedReader reader = new BufferedReader(new FileReader(crlFile))){
+
+ // Verify contents of the file
+ String header = reader.readLine();
+ assertEquals("-----BEGIN X509 CRL-----", header);
+
+ String footer = null;
+ String line = null;
+ while ((line = reader.readLine()) != null) {
+ footer = line;
+ }
+ assertEquals("-----END X509 CRL-----", footer);
+ }
+ }
+
+ @Test
+ public void testWriteCRLX509() throws IOException,
+ OperatorCreationException, CertificateException, CRLException {
+
+ X500Name issuer = x509CertificateHolder.getIssuer();
+ Date now = new Date();
+ X509v2CRLBuilder builder = new X509v2CRLBuilder(issuer, now);
+ builder.addCRLEntry(x509CertificateHolder.getSerialNumber(), now,
+ CRLReason.cACompromise);
+
+ InputStream inStream = null;
+ byte[] crlBytes = TMP_CRL_ENTRY.getBytes();
+ try {
Review comment:
Done.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]