Skip to content

Commit ec2b64a

Browse files
committed
Disable date parsing test in non english locale (#39052)
This ensures we do not attempt to parse non english locale dates in FIPS mode. The error, originally assumed to affect only Joda, affects Java time in the same manner and manifests only with the version of BouncyCastle FIPS certified provider we use in tests. The upstream issue bcgit/bc-java#405 indicates that the behavior is resolved in later versions of the BouncyCastle library and should be tested again when the new versions become FIPS 140 certified
1 parent f5b28ca commit ec2b64a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateProcessorTests.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ public void testInvalidJavaPattern() {
126126
}
127127

128128
public void testJavaPatternLocale() {
129-
// @AwaitsFix(bugUrl="https://github.com/elastic/elasticsearch/issues/31724")
130129
assumeFalse("Can't run in a FIPS JVM, Joda parse date error", inFipsJvm());
131130
DateProcessor dateProcessor = new DateProcessor(randomAlphaOfLength(10),
132131
templatize(ZoneId.of("Europe/Amsterdam")), templatize(Locale.ITALIAN),
@@ -138,6 +137,18 @@ public void testJavaPatternLocale() {
138137
assertThat(ingestDocument.getFieldValue("date_as_date", String.class), equalTo("2010-06-12T00:00:00.000+02:00"));
139138
}
140139

140+
public void testJavaPatternEnglishLocale() {
141+
// Since testJavaPatternLocale is muted in FIPS mode, test that we can correctly parse dates in english
142+
DateProcessor dateProcessor = new DateProcessor(randomAlphaOfLength(10),
143+
templatize(ZoneId.of("Europe/Amsterdam")), templatize(Locale.ENGLISH),
144+
"date_as_string", Collections.singletonList("yyyy dd MMMM"), "date_as_date");
145+
Map<String, Object> document = new HashMap<>();
146+
document.put("date_as_string", "2010 12 June");
147+
IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), document);
148+
dateProcessor.execute(ingestDocument);
149+
assertThat(ingestDocument.getFieldValue("date_as_date", String.class), equalTo("2010-06-12T00:00:00.000+02:00"));
150+
}
151+
141152
public void testJavaPatternDefaultYear() {
142153
String format = randomFrom("dd/MM", "8dd/MM");
143154
DateProcessor dateProcessor = new DateProcessor(randomAlphaOfLength(10),

0 commit comments

Comments
 (0)