Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TESTS] Disable specific locales for RestrictedTrustManagerTest #33299

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@
*/
package org.elasticsearch.xpack.core.ssl;

import org.apache.logging.log4j.Logger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;

import javax.net.ssl.X509ExtendedTrustManager;

import java.io.IOException;
Expand All @@ -28,6 +33,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.regex.Pattern;
Expand All @@ -40,6 +46,34 @@ public class RestrictedTrustManagerTests extends ESTestCase {
private int numberOfClusters;
private int numberOfNodes;

private static Locale restoreLocale;

@BeforeClass
public static void ensureSupportedLocale() throws Exception {
Logger logger = Loggers.getLogger(RestrictedTrustManagerTests.class);
if (isUnusableLocale()) {
// See: https://github.com/elastic/elasticsearch/issues/33081
logger.warn("Attempting to run RestrictedTrustManagerTests tests in an unusable locale in a FIPS JVM. Certificate expiration " +
"validation will fail, switching to English");
restoreLocale = Locale.getDefault();
Locale.setDefault(Locale.ENGLISH);
}
}

private static boolean isUnusableLocale() {
return inFipsJvm() && (Locale.getDefault().toLanguageTag().equals("th-TH")
|| Locale.getDefault().toLanguageTag().equals("ja-JP-u-ca-japanese-x-lvariant-JP")
|| Locale.getDefault().toLanguageTag().equals("th-TH-u-nu-thai-x-lvariant-TH"));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are very specific. I trust you've done the analysis and that's exactly what we need?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, see #33081 and bcgit/bc-java#405


@AfterClass
public static void restoreLocale() throws Exception {
if (restoreLocale != null) {
Locale.setDefault(restoreLocale);
restoreLocale = null;
}
}

@Before
public void readCertificates() throws GeneralSecurityException, IOException {

Expand Down