77
88package org .elasticsearch .xpack .security .cli ;
99
10+ import joptsimple .OptionSet ;
11+
1012import com .google .common .jimfs .Configuration ;
1113import com .google .common .jimfs .Jimfs ;
12- import joptsimple . OptionSet ;
14+
1315import org .bouncycastle .asn1 .DERIA5String ;
1416import org .bouncycastle .asn1 .DEROctetString ;
1517import org .bouncycastle .asn1 .DLSequence ;
2325import org .bouncycastle .pkcs .jcajce .JcaPKCS10CertificationRequest ;
2426import org .bouncycastle .util .io .pem .PemObject ;
2527import org .bouncycastle .util .io .pem .PemReader ;
26- import org .elasticsearch .bootstrap .JavaVersion ;
2728import org .elasticsearch .cli .MockTerminal ;
2829import org .elasticsearch .common .CheckedBiFunction ;
2930import org .elasticsearch .common .CheckedFunction ;
3940import org .junit .Before ;
4041import org .junit .BeforeClass ;
4142
42- import javax .security .auth .x500 .X500Principal ;
4343import java .io .ByteArrayInputStream ;
4444import java .io .IOException ;
4545import java .io .InputStream ;
8181import java .util .function .Function ;
8282import java .util .stream .Collectors ;
8383import java .util .stream .Stream ;
84+ import javax .security .auth .x500 .X500Principal ;
8485
8586import static java .util .Collections .singletonMap ;
8687import static org .elasticsearch .test .FileMatchers .isDirectory ;
@@ -116,10 +117,13 @@ public static void muteInFips() {
116117 assumeFalse ("Can't run in a FIPS JVM" , inFipsJvm ());
117118 }
118119
119- public void testGenerateSingleCertificateSigningRequest () throws Exception {
120+ @ BeforeClass
121+ public static void muteOnBrokenJdk () {
120122 assumeFalse ("JDK bug JDK-8266279, https://github.com/elastic/elasticsearch/issues/72359" ,
121- JavaVersion .current ().compareTo (JavaVersion .parse ("8" )) == 0 );
123+ "1.8.0_292" .equals (System .getProperty ("java.version" )));
124+ }
122125
126+ public void testGenerateSingleCertificateSigningRequest () throws Exception {
123127 final Path outFile = testRoot .resolve ("csr.zip" ).toAbsolutePath ();
124128
125129 final List <String > hostNames = randomHostNames ();
@@ -220,8 +224,6 @@ public void testGenerateSingleCertificateSigningRequest() throws Exception {
220224 }
221225
222226 public void testGenerateSingleCertificateWithExistingCA () throws Exception {
223- assumeFalse ("JDK bug JDK-8266279, https://github.com/elastic/elasticsearch/issues/72359" ,
224- JavaVersion .current ().compareTo (JavaVersion .parse ("8" )) == 0 );
225227 final Path outFile = testRoot .resolve ("certs.zip" ).toAbsolutePath ();
226228
227229 final List <String > hostNames = randomHostNames ();
@@ -335,8 +337,6 @@ public void testGenerateSingleCertificateWithExistingCA() throws Exception {
335337 }
336338
337339 public void testGenerateMultipleCertificateWithNewCA () throws Exception {
338- assumeFalse ("JDK bug JDK-8266279, https://github.com/elastic/elasticsearch/issues/72359" ,
339- JavaVersion .current ().compareTo (JavaVersion .parse ("8" )) == 0 );
340340 final Path outFile = testRoot .resolve ("certs.zip" ).toAbsolutePath ();
341341
342342 final int numberCerts = randomIntBetween (3 , 6 );
@@ -478,8 +478,6 @@ public void testGenerateMultipleCertificateWithNewCA() throws Exception {
478478 }
479479
480480 public void testParsingValidityPeriod () throws Exception {
481- assumeFalse ("JDK bug JDK-8266279, https://github.com/elastic/elasticsearch/issues/72359" ,
482- JavaVersion .current ().compareTo (JavaVersion .parse ("8" )) == 0 );
483481 final HttpCertificateCommand command = new HttpCertificateCommand ();
484482 final MockTerminal terminal = new MockTerminal ();
485483
@@ -533,8 +531,6 @@ public void testParsingValidityPeriod() throws Exception {
533531 }
534532
535533 public void testValidityPeriodToString () throws Exception {
536- assumeFalse ("JDK bug JDK-8266279, https://github.com/elastic/elasticsearch/issues/72359" ,
537- JavaVersion .current ().compareTo (JavaVersion .parse ("8" )) == 0 );
538534 assertThat (HttpCertificateCommand .toString (Period .ofYears (2 )), is ("2y" ));
539535 assertThat (HttpCertificateCommand .toString (Period .ofMonths (5 )), is ("5m" ));
540536 assertThat (HttpCertificateCommand .toString (Period .ofDays (60 )), is ("60d" ));
@@ -548,8 +544,6 @@ public void testValidityPeriodToString() throws Exception {
548544 }
549545
550546 public void testGuessFileType () throws Exception {
551- assumeFalse ("JDK bug JDK-8266279, https://github.com/elastic/elasticsearch/issues/72359" ,
552- JavaVersion .current ().compareTo (JavaVersion .parse ("8" )) == 0 );
553547 MockTerminal terminal = new MockTerminal ();
554548
555549 final Path caCert = getDataPath ("ca.crt" );
@@ -577,8 +571,6 @@ public void testGuessFileType() throws Exception {
577571 }
578572
579573 public void testTextFileSubstitutions () throws Exception {
580- assumeFalse ("JDK bug JDK-8266279, https://github.com/elastic/elasticsearch/issues/72359" ,
581- JavaVersion .current ().compareTo (JavaVersion .parse ("8" )) == 0 );
582574 CheckedBiFunction <String , Map <String , String >, String , Exception > copy = (source , subs ) -> {
583575 try (InputStream in = new ByteArrayInputStream (source .getBytes (StandardCharsets .UTF_8 ));
584576 StringWriter out = new StringWriter ();
0 commit comments