mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-03 01:19:10 +00:00
By default, in integ tests we wait for the standalone cluster to start by using the ant Get task to retrieve the cluster health endpoint. However the ant task has no facilities for customising the trusted CAs for a https resource, so if the integ test cluster has TLS enabled on the http interface (using a custom CA) we need a separate utility for that purpose. Backport of: #40573
62 lines
2.5 KiB
Groovy
62 lines
2.5 KiB
Groovy
import org.elasticsearch.gradle.http.WaitForHttpResource
|
|
|
|
apply plugin: 'elasticsearch.standalone-rest-test'
|
|
apply plugin: 'elasticsearch.rest-test'
|
|
|
|
dependencies {
|
|
// "org.elasticsearch.plugin:x-pack-core:${version}" doesn't work with idea because the testArtifacts are also here
|
|
testCompile project(path: xpackModule('core'), configuration: 'default')
|
|
testCompile project(path: xpackModule('security'), configuration: 'testArtifacts')
|
|
testCompile project(path: xpackModule('core'), configuration: 'testArtifacts')
|
|
testCompile project(path: ':modules:reindex')
|
|
}
|
|
|
|
forbiddenPatterns {
|
|
exclude '**/*.key'
|
|
exclude '**/*.pem'
|
|
exclude '**/*.p12'
|
|
exclude '**/*.jks'
|
|
}
|
|
|
|
File caFile = project.file('src/test/resources/ssl/ca.p12')
|
|
|
|
integTestCluster {
|
|
// Whitelist reindexing from the local node so we can test it.
|
|
extraConfigFile 'http.key', project.projectDir.toPath().resolve('src/test/resources/ssl/http.key')
|
|
extraConfigFile 'http.crt', project.projectDir.toPath().resolve('src/test/resources/ssl/http.crt')
|
|
extraConfigFile 'ca.p12', caFile
|
|
setting 'reindex.remote.whitelist', '127.0.0.1:*'
|
|
setting 'xpack.ilm.enabled', 'false'
|
|
setting 'xpack.security.enabled', 'true'
|
|
setting 'xpack.ml.enabled', 'false'
|
|
setting 'xpack.license.self_generated.type', 'trial'
|
|
setting 'xpack.security.http.ssl.enabled', 'true'
|
|
setting 'xpack.security.http.ssl.certificate', 'http.crt'
|
|
setting 'xpack.security.http.ssl.key', 'http.key'
|
|
setting 'xpack.security.http.ssl.key_passphrase', 'http-password'
|
|
setting 'reindex.ssl.truststore.path', 'ca.p12'
|
|
setting 'reindex.ssl.truststore.password', 'password'
|
|
extraConfigFile 'roles.yml', 'roles.yml'
|
|
[
|
|
test_admin: 'superuser',
|
|
powerful_user: 'superuser',
|
|
minimal_user: 'minimal',
|
|
minimal_with_task_user: 'minimal_with_task',
|
|
readonly_user: 'readonly',
|
|
dest_only_user: 'dest_only',
|
|
can_not_see_hidden_docs_user: 'can_not_see_hidden_docs',
|
|
can_not_see_hidden_fields_user: 'can_not_see_hidden_fields',
|
|
].each { String user, String role ->
|
|
setupCommand 'setupUser#' + user,
|
|
'bin/elasticsearch-users', 'useradd', user, '-p', 'x-pack-test-password', '-r', role
|
|
}
|
|
waitCondition = { node, ant ->
|
|
WaitForHttpResource http = new WaitForHttpResource("https", node.httpUri(), numNodes)
|
|
http.setTrustStoreFile(caFile)
|
|
http.setTrustStorePassword("password")
|
|
http.setUsername("test_admin")
|
|
http.setPassword("x-pack-test-password")
|
|
return http.wait(5000)
|
|
}
|
|
}
|