Skip to content

Commit

Permalink
Extract common test cluster authentication wiring (elastic#77551)
Browse files Browse the repository at this point in the history
* Extract common test cluster authentication wiring

* Fix imports

* Minor polishing

* no extension property neeeded

* Use common cluster authenticationi

* Do not configure distro type in authenticated-cluster plugin

Apply review feedback
  • Loading branch information
breskeby authored Sep 20, 2021
1 parent 5cf5a81 commit 195859c
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 110 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask

def clusterCredentials = [
username: providers.systemProperty('tests.rest.cluster.username')
.forUseAtConfigurationTime()
.getOrElse('test_admin'),
password: providers.systemProperty('tests.rest.cluster.password')
.forUseAtConfigurationTime()
.getOrElse('x-pack-test-password')
]

tasks.withType(StandaloneRestIntegTestTask).configureEach {
systemProperty 'tests.rest.cluster.username', clusterCredentials.username
systemProperty 'tests.rest.cluster.password', clusterCredentials.password
}

testClusters.all {
setting 'xpack.security.enabled', 'true'
setting 'xpack.license.self_generated.type', 'trial'
user clusterCredentials
}
21 changes: 2 additions & 19 deletions x-pack/plugin/ilm/qa/rest/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
apply plugin: 'elasticsearch.internal-yaml-rest-test'
apply plugin: 'elasticsearch.yaml-rest-compat-test'
apply plugin: 'elasticsearch.authenticated-testclusters'

dependencies {
yamlRestTestImplementation(testArtifact(project(xpackModule('core'))))
Expand All @@ -11,27 +12,9 @@ restResources {
}
}

def clusterCredentials = [
username: providers.systemProperty('tests.rest.cluster.username')
.orElse('test_admin')
.forUseAtConfigurationTime()
.get(),
password: providers.systemProperty('tests.rest.cluster.password')
.orElse('x-pack-test-password')
.forUseAtConfigurationTime()
.get()
]

tasks.withType(Test).configureEach {
systemProperty 'tests.rest.cluster.username', clusterCredentials.username
systemProperty 'tests.rest.cluster.password', clusterCredentials.password
}

testClusters.all {
testClusters.configureEach {
testDistribution = 'DEFAULT'
setting 'xpack.ml.enabled', 'false'
setting 'xpack.security.enabled', 'true'
setting 'xpack.license.self_generated.type', 'trial'
setting 'xpack.security.autoconfiguration.enabled', 'false'
user clusterCredentials
}
20 changes: 2 additions & 18 deletions x-pack/plugin/ilm/qa/with-security/build.gradle
Original file line number Diff line number Diff line change
@@ -1,32 +1,16 @@
apply plugin: 'elasticsearch.internal-java-rest-test'
apply plugin: 'elasticsearch.authenticated-testclusters'

dependencies {
javaRestTestImplementation(testArtifact(project(xpackModule('core'))))
}

def clusterCredentials = [
username: providers.systemProperty('tests.rest.cluster.username')
.orElse('test_admin')
.forUseAtConfigurationTime()
.get(),
password: providers.systemProperty('tests.rest.cluster.password')
.orElse('x-pack-test-password')
.forUseAtConfigurationTime()
.get()
]

tasks.named("javaRestTest").configure {
systemProperty 'tests.rest.cluster.username', clusterCredentials.username
systemProperty 'tests.rest.cluster.password', clusterCredentials.password
}

testClusters.all {
testDistribution = 'DEFAULT'
setting 'xpack.security.enabled', 'true'
setting 'xpack.watcher.enabled', 'false'
setting 'xpack.watcher.enabled', 'false'
setting 'xpack.ml.enabled', 'false'
setting 'xpack.license.self_generated.type', 'trial'
extraConfigFile 'roles.yml', file('roles.yml')
user clusterCredentials
user username: "test_ilm", password: "x-pack-test-password", role: "ilm"
}
20 changes: 1 addition & 19 deletions x-pack/plugin/shutdown/qa/multi-node/build.gradle
Original file line number Diff line number Diff line change
@@ -1,31 +1,13 @@
import org.elasticsearch.gradle.VersionProperties

apply plugin: 'elasticsearch.internal-java-rest-test'
apply plugin: 'elasticsearch.authenticated-testclusters'

dependencies {
javaRestTestImplementation(testArtifact(project(xpackModule('core'))))
}

def clusterCredentials = [
username: providers.systemProperty('tests.rest.cluster.username')
.orElse('test_admin')
.forUseAtConfigurationTime()
.get(),
password: providers.systemProperty('tests.rest.cluster.password')
.orElse('x-pack-test-password')
.forUseAtConfigurationTime()
.get()
]

tasks.named("javaRestTest").configure {
systemProperty 'tests.rest.cluster.username', clusterCredentials.username
systemProperty 'tests.rest.cluster.password', clusterCredentials.password
}

testClusters.all {
testDistribution = 'DEFAULT'
numberOfNodes = 4

setting 'xpack.security.enabled', 'true'
user username: clusterCredentials.username, password: clusterCredentials.password, role: 'superuser'
}
19 changes: 1 addition & 18 deletions x-pack/plugin/stack/qa/rest/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
apply plugin: 'elasticsearch.internal-yaml-rest-test'
apply plugin: 'elasticsearch.yaml-rest-compat-test'
apply plugin: 'elasticsearch.authenticated-testclusters'

dependencies {
yamlRestTestImplementation(testArtifact(project(xpackModule('core'))))
Expand All @@ -11,26 +12,8 @@ restResources {
}
}

def clusterCredentials = [
username: providers.systemProperty('tests.rest.cluster.username')
.orElse('test_admin')
.forUseAtConfigurationTime()
.get(),
password: providers.systemProperty('tests.rest.cluster.password')
.orElse('x-pack-test-password')
.forUseAtConfigurationTime()
.get()
]

tasks.withType(Test).configureEach {
systemProperty 'tests.rest.cluster.username', clusterCredentials.username
systemProperty 'tests.rest.cluster.password', clusterCredentials.password
}

testClusters.all {
testDistribution = 'DEFAULT'
setting 'xpack.ml.enabled', 'false'
setting 'xpack.security.enabled', 'true'
setting 'xpack.license.self_generated.type', 'trial'
user clusterCredentials
}
19 changes: 1 addition & 18 deletions x-pack/qa/core-rest-tests-with-security/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ apply plugin: 'elasticsearch.internal-testclusters'
apply plugin: 'elasticsearch.standalone-rest-test'
apply plugin: 'elasticsearch.rest-test'
apply plugin: 'elasticsearch.rest-resources'
apply plugin: 'elasticsearch.authenticated-testclusters'

dependencies {
testImplementation project(':x-pack:qa')
Expand All @@ -15,31 +16,16 @@ restResources {
}
}

def clusterCredentials = [
username: providers.systemProperty('tests.rest.cluster.username')
.orElse('test_admin')
.forUseAtConfigurationTime()
.get(),
password: providers.systemProperty('tests.rest.cluster.password')
.orElse('x-pack-test-password')
.forUseAtConfigurationTime()
.get()
]

tasks.named("integTest").configure {
systemProperty 'tests.rest.blacklist',
[
'index/10_with_id/Index with ID',
'indices.get_alias/10_basic/Get alias against closed indices'
].join(',')

systemProperty 'tests.rest.cluster.username', clusterCredentials.username
systemProperty 'tests.rest.cluster.password', clusterCredentials.password
}

testClusters.matching { it.name == "integTest" }.configureEach {
testDistribution = 'DEFAULT'
setting 'xpack.security.enabled', 'true'
setting 'xpack.watcher.enabled', 'false'
setting 'xpack.ml.enabled', 'false'
setting 'xpack.license.self_generated.type', 'trial'
Expand All @@ -48,7 +34,4 @@ testClusters.matching { it.name == "integTest" }.configureEach {
if (BuildParams.isSnapshotBuild() == false) {
systemProperty 'es.index_mode_feature_flag_registered', 'true'
}

user username: clusterCredentials.username,
password: clusterCredentials.password
}
19 changes: 1 addition & 18 deletions x-pack/qa/runtime-fields/with-security/build.gradle
Original file line number Diff line number Diff line change
@@ -1,32 +1,15 @@
apply plugin: 'elasticsearch.internal-java-rest-test'
apply plugin: 'elasticsearch.authenticated-testclusters'

dependencies {
javaRestTestImplementation(testArtifact(project(xpackModule('core'))))
}

def clusterCredentials = [
username: providers.systemProperty('tests.rest.cluster.username')
.orElse('test_admin')
.forUseAtConfigurationTime()
.get(),
password: providers.systemProperty('tests.rest.cluster.password')
.orElse('x-pack-test-password')
.forUseAtConfigurationTime()
.get()
]

tasks.named("javaRestTest").configure {
systemProperty 'tests.rest.cluster.username', clusterCredentials.username
systemProperty 'tests.rest.cluster.password', clusterCredentials.password
}

testClusters.all {
testDistribution = 'DEFAULT'
setting 'xpack.security.enabled', 'true'
setting 'xpack.watcher.enabled', 'false'
setting 'xpack.ml.enabled', 'false'
setting 'xpack.license.self_generated.type', 'trial'
extraConfigFile 'roles.yml', file('roles.yml')
user clusterCredentials
user username: "test", password: "x-pack-test-password", role: "test"
}

0 comments on commit 195859c

Please sign in to comment.