From 2266a8c51b3503c4f914eb48f5b6996a9e425f5a Mon Sep 17 00:00:00 2001 From: Ioannis Kakavas Date: Mon, 18 Feb 2019 14:56:39 +0200 Subject: [PATCH] Disable date parsing test in non english locale 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 https://github.com/bcgit/bc-java/issues/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 --- .../ingest/common/DateProcessorTests.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateProcessorTests.java b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateProcessorTests.java index 7582056e0b6b6..c390f14029c39 100644 --- a/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateProcessorTests.java +++ b/modules/ingest-common/src/test/java/org/elasticsearch/ingest/common/DateProcessorTests.java @@ -126,7 +126,6 @@ public void testInvalidJavaPattern() { } public void testJavaPatternLocale() { - // @AwaitsFix(bugUrl="https://github.com/elastic/elasticsearch/issues/31724") assumeFalse("Can't run in a FIPS JVM, Joda parse date error", inFipsJvm()); DateProcessor dateProcessor = new DateProcessor(randomAlphaOfLength(10), templatize(ZoneId.of("Europe/Amsterdam")), templatize(Locale.ITALIAN), @@ -138,6 +137,18 @@ public void testJavaPatternLocale() { assertThat(ingestDocument.getFieldValue("date_as_date", String.class), equalTo("2010-06-12T00:00:00.000+02:00")); } + public void testJavaPatternEnglishLocale() { + // Since testJavaPatternLocale is muted in FIPS mode, test that we can correctly parse dates in english + DateProcessor dateProcessor = new DateProcessor(randomAlphaOfLength(10), + templatize(ZoneId.of("Europe/Amsterdam")), templatize(Locale.ENGLISH), + "date_as_string", Collections.singletonList("yyyy dd MMMM"), "date_as_date"); + Map document = new HashMap<>(); + document.put("date_as_string", "2010 12 June"); + IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), document); + dateProcessor.execute(ingestDocument); + assertThat(ingestDocument.getFieldValue("date_as_date", String.class), equalTo("2010-06-12T00:00:00.000+02:00")); + } + public void testJavaPatternDefaultYear() { String format = randomFrom("dd/MM", "8dd/MM"); DateProcessor dateProcessor = new DateProcessor(randomAlphaOfLength(10),