-
Notifications
You must be signed in to change notification settings - Fork 25k
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
[Kerberos] Rest client integration test #32070
Changes from 2 commits
de23f3f
7263235
b332be8
9b8d5ba
e31628f
307d0a4
25a6b87
a923328
7488540
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import java.nio.file.Path | ||
import java.nio.file.Paths | ||
import java.nio.file.Files | ||
|
||
apply plugin: 'elasticsearch.vagrantsupport' | ||
apply plugin: 'elasticsearch.standalone-rest-test' | ||
apply plugin: 'elasticsearch.rest-test' | ||
|
||
dependencies { | ||
testCompile project(path: xpackModule('core'), configuration: 'runtime') | ||
testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') | ||
testCompile project(path: xpackModule('security'), configuration: 'testArtifacts') | ||
} | ||
|
||
// MIT Kerberos Vagrant Testing Fixture | ||
String box = "krb5kdc" | ||
Map<String,String> vagrantEnvVars = [ | ||
'VAGRANT_CWD' : "${project(':test:fixtures:krb5kdc-fixture').projectDir}", | ||
'VAGRANT_VAGRANTFILE' : 'Vagrantfile', | ||
'VAGRANT_PROJECT_DIR' : "${project(':test:fixtures:krb5kdc-fixture').projectDir}" | ||
] | ||
|
||
task krb5kdcUpdate(type: org.elasticsearch.gradle.vagrant.VagrantCommandTask) { | ||
command 'box' | ||
subcommand 'update' | ||
boxName box | ||
environmentVars vagrantEnvVars | ||
dependsOn "vagrantCheckVersion", "virtualboxCheckVersion" | ||
} | ||
|
||
task krb5kdcFixture(type: org.elasticsearch.gradle.test.VagrantFixture) { | ||
command 'up' | ||
args '--provision', '--provider', 'virtualbox' | ||
boxName box | ||
environmentVars vagrantEnvVars | ||
dependsOn krb5kdcUpdate | ||
} | ||
|
||
task krb5AddPrincipals { dependsOn krb5kdcFixture } | ||
|
||
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) | ||
} | ||
|
||
integTestCluster { | ||
setting 'xpack.license.self_generated.type', 'trial' | ||
setting 'xpack.security.enabled', 'true' | ||
setting 'xpack.security.http.ssl.enabled', 'false' | ||
setting 'xpack.security.authc.token.enabled', 'true' | ||
setting 'xpack.security.authc.realms.file.type', 'file' | ||
setting 'xpack.security.authc.realms.file.order', '0' | ||
setting 'xpack.ml.enabled', 'false' | ||
setting 'xpack.security.audit.enabled', 'true' | ||
// Kerberos realm | ||
setting 'xpack.security.authc.realms.kerberos.type', 'kerberos' | ||
setting 'xpack.security.authc.realms.kerberos.order', '1' | ||
setting 'xpack.security.authc.realms.kerberos.keytab.path', 'es.keytab' | ||
setting 'xpack.security.authc.realms.kerberos.krb.debug', 'true' | ||
setting 'xpack.security.authc.realms.kerberos.remove_realm_name', 'false' | ||
|
||
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" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we specify debug in the realm and in the jvm args? Is it because our debug value overrides the system property? If so, we need to change the default of the setting to be the value of the system property. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are two flags for debug level logs, |
||
jvmArgs jvmArgsStr | ||
Path esKeytab = project(':test:fixtures:krb5kdc-fixture').buildDir.toPath().resolve("keytabs").resolve("HTTP_localhost.keytab").toAbsolutePath() | ||
extraConfigFile("es.keytab", "${esKeytab}") | ||
|
||
setupCommand 'setupTestAdmin', | ||
'bin/elasticsearch-users', 'useradd', "test_admin", '-p', 'x-pack-test-password', '-r', "superuser" | ||
|
||
waitCondition = { node, ant -> | ||
File tmpFile = new File(node.cwd, 'wait.success') | ||
ant.get(src: "http://${node.httpUri()}/_cluster/health?wait_for_nodes=>=${numNodes}&wait_for_status=yellow", | ||
dest: tmpFile.toString(), | ||
username: 'test_admin', | ||
password: 'x-pack-test-password', | ||
ignoreerrors: true, | ||
retries: 10) | ||
return tmpFile.exists() | ||
} | ||
|
||
dependsOn krb5AddPrincipals, krb5kdcFixture | ||
} | ||
|
||
integTestRunner { | ||
Path peppaKeytab = project(':test:fixtures:krb5kdc-fixture').buildDir.toPath().resolve("keytabs").resolve("peppa.keytab").toAbsolutePath() | ||
systemProperty 'test.userkt', "peppa@${realm}" | ||
systemProperty 'test.userkt.keytab', "${peppaKeytab}" | ||
systemProperty 'test.userpwd', "george@${realm}" | ||
systemProperty 'test.userpwd.password', "dino" | ||
systemProperty 'tests.security.manager', 'false' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add a comment on why we need to run without the security manager in these tests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was lazy and did want to keep the client simple. But I think it's better to run with the security manager. I have enabled it and also made some changes to make the tests run with the security manager. Thank you. |
||
Path krb5conf = project(':test:fixtures:krb5kdc-fixture').buildDir.toPath().resolve("conf").resolve("krb5.conf").toAbsolutePath() | ||
List jvmargs = ["-Djava.security.krb5.conf=${krb5conf}","-Dsun.security.krb5.debug=true"] | ||
jvmArgs jvmargs | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think we need this setting