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

Fix the REST FIPS tests #61001

Merged
merged 5 commits into from
Aug 13, 2020
Merged
Show file tree
Hide file tree
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 @@ -92,10 +92,6 @@ public void execute(Task t) {
test.systemProperty("java.locale.providers", "SPI,COMPAT");
}
});
if (BuildParams.isInFipsJvm()) {
project.getDependencies().add("testRuntimeOnly", "org.bouncycastle:bc-fips:1.0.1");
project.getDependencies().add("testRuntimeOnly", "org.bouncycastle:bctls-fips:1.0.9");
}
test.getJvmArgumentProviders().add(nonInputProperties);
test.getExtensions().add("nonInputProperties", nonInputProperties);

Expand Down
18 changes: 13 additions & 5 deletions gradle/fips.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import org.elasticsearch.gradle.testclusters.ElasticsearchCluster
// Common config when running with a FIPS-140 runtime JVM
if (BuildParams.inFipsJvm) {


allprojects {
File fipsResourcesDir = new File(project.buildDir, 'fips-resources')
File fipsSecurity = new File(fipsResourcesDir, 'fips_java.security')
File fipsPolicy = new File(fipsResourcesDir, 'fips_java.policy')
File fipsTrustStore = new File(fipsResourcesDir, 'cacerts.bcfks')
pluginManager.withPlugin('elasticsearch.java') {
def bcFips = dependencies.create('org.bouncycastle:bc-fips:1.0.1')
def bcTlsFips = dependencies.create('org.bouncycastle:bctls-fips:1.0.9')

pluginManager.withPlugin('java') {
TaskProvider<ExportElasticsearchBuildResourcesTask> fipsResourcesTask = project.tasks.register('fipsResources', ExportElasticsearchBuildResourcesTask)
fipsResourcesTask.configure {
outputDir = fipsResourcesDir
Expand All @@ -21,14 +23,20 @@ if (BuildParams.inFipsJvm) {
copy 'cacerts.bcfks'
}

project.afterEvaluate {
def extraFipsJars = configurations.detachedConfiguration(bcFips, bcTlsFips)
// ensure that bouncycastle is on classpath for the all of test types, must happen in evaluateAfter since the rest tests explicitly
// set the class path to help maintain pure black box testing, and here we are adding to that classpath
tasks.withType(Test).configureEach { Test test ->
test.setClasspath(test.getClasspath().plus(extraFipsJars))
}
}

pluginManager.withPlugin("elasticsearch.testclusters") {
afterEvaluate {
// This afterEvaluate hooks is required to avoid deprecated configuration resolution
// This configuration can be removed once system modules are available
def extraFipsJars = configurations.detachedConfiguration(dependencies.create('org.bouncycastle:bc-fips:1.0.1'),
dependencies.create('org.bouncycastle:bctls-fips:1.0.9'),
)
def extraFipsJars = configurations.detachedConfiguration(bcFips, bcTlsFips)
testClusters.all {
extraFipsJars.files.each {
extraJarFile it
Expand Down
2 changes: 1 addition & 1 deletion plugins/ingest-attachment/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,6 @@ if (BuildParams.inFipsJvm) {
// rather than provide a long list of exclusions, disable the check on FIPS.
jarHell.enabled = false
test.enabled = false
integTest.enabled = false;
yamlRestTest.enabled = false;
testingConventions.enabled = false;
}