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

Use HTTP for Azure fixture in FIPS tests #111397

Merged
merged 1 commit into from
Jul 29, 2024
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 @@ -14,6 +14,7 @@
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;

import org.elasticsearch.core.Booleans;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.TestTrustStore;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
Expand All @@ -30,7 +31,9 @@ public class RepositoryAzureClientYamlTestSuiteIT extends ESClientYamlSuiteTestC
private static final String AZURE_TEST_SASTOKEN = System.getProperty("test.azure.sas_token");

private static AzureHttpFixture fixture = new AzureHttpFixture(
USE_FIXTURE ? AzureHttpFixture.Protocol.HTTPS : AzureHttpFixture.Protocol.NONE,
USE_FIXTURE
? ESTestCase.inFipsJvm() ? AzureHttpFixture.Protocol.HTTP : AzureHttpFixture.Protocol.HTTPS
: AzureHttpFixture.Protocol.NONE,
AZURE_TEST_ACCOUNT,
AZURE_TEST_CONTAINER,
AzureHttpFixture.sharedKeyForAccountPredicate(AZURE_TEST_ACCOUNT)
Expand Down Expand Up @@ -59,7 +62,11 @@ public class RepositoryAzureClientYamlTestSuiteIT extends ESClientYamlSuiteTestC
s -> USE_FIXTURE
)
.setting("thread_pool.repository_azure.max", () -> String.valueOf(randomIntBetween(1, 10)), s -> USE_FIXTURE)
.systemProperty("javax.net.ssl.trustStore", () -> trustStore.getTrustStorePath().toString(), s -> USE_FIXTURE)
.systemProperty(
"javax.net.ssl.trustStore",
() -> trustStore.getTrustStorePath().toString(),
s -> USE_FIXTURE && ESTestCase.inFipsJvm() == false
)
.build();

@ClassRule(order = 1)
Expand Down
12 changes: 0 additions & 12 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,6 @@ tests:
issue: https://github.com/elastic/elasticsearch/issues/111308
- class: org.elasticsearch.xpack.ml.integration.DatafeedJobsRestIT
issue: https://github.com/elastic/elasticsearch/issues/111319
- class: org.elasticsearch.xpack.searchablesnapshots.AzureSearchableSnapshotsIT
issue: https://github.com/elastic/elasticsearch/issues/111279
- class: org.elasticsearch.repositories.azure.RepositoryAzureClientYamlTestSuiteIT
issue: https://github.com/elastic/elasticsearch/issues/111345
- class: org.elasticsearch.xpack.repositories.metering.azure.AzureRepositoriesMeteringIT
issue: https://github.com/elastic/elasticsearch/issues/111307
- class: org.elasticsearch.xpack.snapshotbasedrecoveries.recovery.AzureSnapshotBasedRecoveryIT
method: testRecoveryUsingSnapshots
issue: https://github.com/elastic/elasticsearch/issues/111377
- class: org.elasticsearch.repositories.blobstore.testkit.AzureSnapshotRepoTestKitIT
method: testRepositoryAnalysis
issue: https://github.com/elastic/elasticsearch/issues/111280
- class: org.elasticsearch.xpack.esql.analysis.VerifierTests
method: testMatchFilter
issue: https://github.com/elastic/elasticsearch/issues/111380
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.Objects;

import static org.apache.lucene.tests.util.LuceneTestCase.createTempDir;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class TestTrustStore extends ExternalResource {
Expand All @@ -35,6 +36,7 @@ public TestTrustStore(CheckedSupplier<InputStream, IOException> pemStreamSupplie
private Path trustStorePath;

public Path getTrustStorePath() {
assertFalse("Tests in FIPS mode cannot supply a custom trust store", ESTestCase.inFipsJvm());
return Objects.requireNonNullElseGet(trustStorePath, () -> ESTestCase.fail(null, "trust store not created"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.TestTrustStore;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.xpack.repositories.metering.AbstractRepositoriesMeteringAPIRestTestCase;
Expand All @@ -28,7 +29,9 @@ public class AzureRepositoriesMeteringIT extends AbstractRepositoriesMeteringAPI
private static final String AZURE_TEST_SASTOKEN = System.getProperty("test.azure.sas_token");

private static AzureHttpFixture fixture = new AzureHttpFixture(
USE_FIXTURE ? AzureHttpFixture.Protocol.HTTPS : AzureHttpFixture.Protocol.NONE,
USE_FIXTURE
? ESTestCase.inFipsJvm() ? AzureHttpFixture.Protocol.HTTP : AzureHttpFixture.Protocol.HTTPS
: AzureHttpFixture.Protocol.NONE,
AZURE_TEST_ACCOUNT,
AZURE_TEST_CONTAINER,
AzureHttpFixture.sharedKeyForAccountPredicate(AZURE_TEST_ACCOUNT)
Expand Down Expand Up @@ -57,7 +60,11 @@ public class AzureRepositoriesMeteringIT extends AbstractRepositoriesMeteringAPI
() -> "ignored;DefaultEndpointsProtocol=https;BlobEndpoint=" + fixture.getAddress(),
s -> USE_FIXTURE
)
.systemProperty("javax.net.ssl.trustStore", () -> trustStore.getTrustStorePath().toString(), s -> USE_FIXTURE)
.systemProperty(
"javax.net.ssl.trustStore",
() -> trustStore.getTrustStorePath().toString(),
s -> USE_FIXTURE && ESTestCase.inFipsJvm() == false
)
.build();

@ClassRule(order = 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.TestTrustStore;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.rest.ESRestTestCase;
Expand All @@ -29,7 +30,9 @@ public class AzureSearchableSnapshotsIT extends AbstractSearchableSnapshotsRestT
private static final String AZURE_TEST_SASTOKEN = System.getProperty("test.azure.sas_token");

private static AzureHttpFixture fixture = new AzureHttpFixture(
USE_FIXTURE ? AzureHttpFixture.Protocol.HTTPS : AzureHttpFixture.Protocol.NONE,
USE_FIXTURE
? ESTestCase.inFipsJvm() ? AzureHttpFixture.Protocol.HTTP : AzureHttpFixture.Protocol.HTTPS
: AzureHttpFixture.Protocol.NONE,
AZURE_TEST_ACCOUNT,
AZURE_TEST_CONTAINER,
AzureHttpFixture.sharedKeyForAccountPredicate(AZURE_TEST_ACCOUNT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.TestTrustStore;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.junit.ClassRule;
Expand All @@ -28,7 +29,9 @@ public class AzureSnapshotBasedRecoveryIT extends AbstractSnapshotBasedRecoveryR
private static final String AZURE_TEST_SASTOKEN = System.getProperty("test.azure.sas_token");

private static AzureHttpFixture fixture = new AzureHttpFixture(
USE_FIXTURE ? AzureHttpFixture.Protocol.HTTPS : AzureHttpFixture.Protocol.NONE,
USE_FIXTURE
? ESTestCase.inFipsJvm() ? AzureHttpFixture.Protocol.HTTP : AzureHttpFixture.Protocol.HTTPS
: AzureHttpFixture.Protocol.NONE,
AZURE_TEST_ACCOUNT,
AZURE_TEST_CONTAINER,
AzureHttpFixture.sharedKeyForAccountPredicate(AZURE_TEST_ACCOUNT)
Expand Down Expand Up @@ -59,7 +62,11 @@ public class AzureSnapshotBasedRecoveryIT extends AbstractSnapshotBasedRecoveryR
s -> USE_FIXTURE
)
.setting("xpack.license.self_generated.type", "trial")
.systemProperty("javax.net.ssl.trustStore", () -> trustStore.getTrustStorePath().toString(), s -> USE_FIXTURE)
.systemProperty(
"javax.net.ssl.trustStore",
() -> trustStore.getTrustStorePath().toString(),
s -> USE_FIXTURE && ESTestCase.inFipsJvm() == false
)
.build();

@ClassRule(order = 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.TestTrustStore;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.junit.ClassRule;
Expand All @@ -27,7 +28,9 @@ public class AzureSnapshotRepoTestKitIT extends AbstractSnapshotRepoTestKitRestT
private static final String AZURE_TEST_SASTOKEN = System.getProperty("test.azure.sas_token");

private static AzureHttpFixture fixture = new AzureHttpFixture(
USE_FIXTURE ? AzureHttpFixture.Protocol.HTTPS : AzureHttpFixture.Protocol.NONE,
USE_FIXTURE
? ESTestCase.inFipsJvm() ? AzureHttpFixture.Protocol.HTTP : AzureHttpFixture.Protocol.HTTPS
: AzureHttpFixture.Protocol.NONE,
AZURE_TEST_ACCOUNT,
AZURE_TEST_CONTAINER,
AzureHttpFixture.sharedKeyForAccountPredicate(AZURE_TEST_ACCOUNT)
Expand Down Expand Up @@ -62,7 +65,11 @@ public class AzureSnapshotRepoTestKitIT extends AbstractSnapshotRepoTestKitRestT
c.systemProperty("test.repository_test_kit.skip_cas", "true");
}
})
.systemProperty("javax.net.ssl.trustStore", () -> trustStore.getTrustStorePath().toString(), s -> USE_FIXTURE)
.systemProperty(
"javax.net.ssl.trustStore",
() -> trustStore.getTrustStorePath().toString(),
s -> USE_FIXTURE && ESTestCase.inFipsJvm() == false
)
.build();

@ClassRule(order = 1)
Expand Down