-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Disable specific locales for tests in fips mode #38938
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
Changes from all commits
db1512b
0148b94
7d068cf
59ee5cb
7a27f26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -327,6 +327,16 @@ public static void restoreContentType() { | |
| Requests.INDEX_CONTENT_TYPE = XContentType.JSON; | ||
| } | ||
|
|
||
| @BeforeClass | ||
| public static void ensureSupportedLocale() { | ||
| if (isUnusableLocale()) { | ||
| Logger logger = LogManager.getLogger(ESTestCase.class); | ||
| logger.warn("Attempting to run tests in an unusable locale in a FIPS JVM. Certificate expiration validation will fail, " + | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it would be good to provide a link to the upstream bug so it's easier to check if this is still relevant ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the log message you mean ? Sure thing
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, move it to the log message rather than the comment. |
||
| "switching to English. See: https://github.com/bcgit/bc-java/issues/405"); | ||
| Locale.setDefault(Locale.ENGLISH); | ||
| } | ||
| } | ||
|
|
||
| @Before | ||
| public final void before() { | ||
| logger.info("{}before test", getTestParamsForLogging()); | ||
|
|
@@ -1419,6 +1429,12 @@ public TestAnalysis(IndexAnalyzers indexAnalyzers, | |
| } | ||
| } | ||
|
|
||
| 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")); | ||
| } | ||
|
|
||
| public static boolean inFipsJvm() { | ||
| return Security.getProviders()[0].getName().toLowerCase(Locale.ROOT).contains("fips"); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels a little too much of a blanket approach to do this in ESTestCase, but failing tests could be anywhere from classes implementing ESRestTestCase, or security related ones implementing ESTestCase. Doing this here, also protects us from future tests inadvertently causing this. I'm definitely open to suggestions to limit the scope if necessary but given the fact that the upstream bug makes using BCFipsProvider unusable in these 3 locales for users when dealing with certificates, I believe it's ok to not run the tests using these.