|
|
@@ -36,32 +36,43 @@ task krb5kdcFixture(type: org.elasticsearch.gradle.test.VagrantFixture) {
|
|
|
dependsOn krb5kdcUpdate
|
|
|
}
|
|
|
|
|
|
-task krb5AddPrincipals { dependsOn krb5kdcFixture }
|
|
|
+// lazily resolve to avoid any slowdowns from DNS lookups prior to when we need this value
|
|
|
+Object httpPrincipal = new Object() {
|
|
|
+ @Override
|
|
|
+ String toString() {
|
|
|
+ InetAddress resolvedAddress = InetAddress.getByName('127.0.0.1')
|
|
|
+ return "HTTP/" + resolvedAddress.getHostName()
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
-List<String> principals = [
|
|
|
- "HTTP/localhost",
|
|
|
- "peppa",
|
|
|
- "george~dino"
|
|
|
-]
|
|
|
String realm = "BUILD.ELASTIC.CO"
|
|
|
|
|
|
-for (String principal : principals) {
|
|
|
- String[] princPwdPair = principal.split('~');
|
|
|
- String princName = princPwdPair[0];
|
|
|
- String password = "";
|
|
|
- if (princPwdPair.length > 1) {
|
|
|
- password = princPwdPair[1];
|
|
|
- }
|
|
|
- Task create = project.tasks.create("addPrincipal#${principal}".replace('/', '_'), org.elasticsearch.gradle.vagrant.VagrantCommandTask) {
|
|
|
- command 'ssh'
|
|
|
- args '--command', "sudo bash /vagrant/src/main/resources/provision/addprinc.sh $princName $password"
|
|
|
- boxName box
|
|
|
- environmentVars vagrantEnvVars
|
|
|
- dependsOn krb5kdcFixture
|
|
|
- }
|
|
|
- krb5AddPrincipals.dependsOn(create)
|
|
|
+task 'addPrincipal#peppa'(type: org.elasticsearch.gradle.vagrant.VagrantCommandTask) {
|
|
|
+ command 'ssh'
|
|
|
+ args '--command', "sudo bash /vagrant/src/main/resources/provision/addprinc.sh peppa "
|
|
|
+ boxName box
|
|
|
+ environmentVars vagrantEnvVars
|
|
|
+ dependsOn krb5kdcFixture
|
|
|
+}
|
|
|
+
|
|
|
+task 'addPrincipal#george'(type: org.elasticsearch.gradle.vagrant.VagrantCommandTask) {
|
|
|
+ command 'ssh'
|
|
|
+ args '--command', "sudo bash /vagrant/src/main/resources/provision/addprinc.sh george dino"
|
|
|
+ boxName box
|
|
|
+ environmentVars vagrantEnvVars
|
|
|
+ dependsOn krb5kdcFixture
|
|
|
+}
|
|
|
+
|
|
|
+task 'addPrincipal#HTTP'(type: org.elasticsearch.gradle.vagrant.VagrantCommandTask) {
|
|
|
+ command 'ssh'
|
|
|
+ args '--command', "sudo bash /vagrant/src/main/resources/provision/addprinc.sh $httpPrincipal"
|
|
|
+ boxName box
|
|
|
+ environmentVars vagrantEnvVars
|
|
|
+ dependsOn krb5kdcFixture
|
|
|
}
|
|
|
|
|
|
+task krb5AddPrincipals { dependsOn krb5kdcFixture, 'addPrincipal#peppa', 'addPrincipal#george', 'addPrincipal#HTTP' }
|
|
|
+
|
|
|
def generatedResources = "$buildDir/generated-resources/keytabs"
|
|
|
task copyKeytabToGeneratedResources(type: Copy) {
|
|
|
Path peppaKeytab = project(':test:fixtures:krb5kdc-fixture').buildDir.toPath().resolve("keytabs").resolve("peppa.keytab").toAbsolutePath()
|
|
|
@@ -71,6 +82,9 @@ task copyKeytabToGeneratedResources(type: Copy) {
|
|
|
}
|
|
|
|
|
|
integTestCluster {
|
|
|
+ // force localhost IPv4 otherwise it is a chicken and egg problem where we need the keytab for the hostname when starting the cluster
|
|
|
+ // but do not know the exact address that is first in the http ports file
|
|
|
+ setting 'http.host', '127.0.0.1'
|
|
|
setting 'xpack.license.self_generated.type', 'trial'
|
|
|
setting 'xpack.security.enabled', 'true'
|
|
|
setting 'xpack.security.authc.realms.file.type', 'file'
|
|
|
@@ -87,7 +101,8 @@ integTestCluster {
|
|
|
Path krb5conf = project(':test:fixtures:krb5kdc-fixture').buildDir.toPath().resolve("conf").resolve("krb5.conf").toAbsolutePath()
|
|
|
String jvmArgsStr = " -Djava.security.krb5.conf=${krb5conf}" + " -Dsun.security.krb5.debug=true"
|
|
|
jvmArgs jvmArgsStr
|
|
|
- Path esKeytab = project(':test:fixtures:krb5kdc-fixture').buildDir.toPath().resolve("keytabs").resolve("HTTP_localhost.keytab").toAbsolutePath()
|
|
|
+ Path esKeytab = project(':test:fixtures:krb5kdc-fixture').buildDir.toPath().resolve("keytabs")
|
|
|
+ .resolve("$httpPrincipal".replace('/', '_') + ".keytab").toAbsolutePath()
|
|
|
extraConfigFile("es.keytab", "${esKeytab}")
|
|
|
|
|
|
setupCommand 'setupTestAdmin',
|