-
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
Use ephemeral ports for idp-fixture #40333
Changes from 1 commit
f2722d4
030e513
0cc6791
df6a969
23cbf4f
35bedf9
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
import com.avast.gradle.dockercompose.ComposeExtension | ||
import com.avast.gradle.dockercompose.ServiceInfo | ||
|
||
Project idpFixtureProject = xpackProject("test:idp-fixture") | ||
evaluationDependsOn(idpFixtureProject.path) | ||
|
||
|
@@ -17,11 +20,29 @@ testFixtures.useFixture ":x-pack:test:idp-fixture" | |
|
||
String outputDir = "${project.buildDir}/generated-resources/${project.name}" | ||
task copyIdpCertificate(type: Copy) { | ||
from idpFixtureProject.file('idp/shibboleth-idp/credentials/idp-browser.pem'); | ||
from idpFixtureProject.files('idp/shibboleth-idp/credentials/idp-browser.pem', 'idp/shibboleth-idp/metadata/idp-metadata.xml'); | ||
into outputDir | ||
} | ||
project.sourceSets.test.output.dir(outputDir, builtBy: copyIdpCertificate) | ||
integTestCluster.dependsOn copyIdpCertificate | ||
|
||
task setupPorts { | ||
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. Thanks for noticing and fixing this @jaymode ! 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. thanks for that tip! |
||
dependsOn copyIdpCertificate, idpFixtureProject.postProcessFixture | ||
doFirst { | ||
Map<String, ServiceInfo> serviceInfoMap = idpFixtureProject.getExtensions().getByType(ComposeExtension.class).getServicesInfos() | ||
ServiceInfo shibIdp = serviceInfoMap.get('shibboleth-idp') | ||
int ephemeralPort = shibIdp.getTcpPorts().get(4443) | ||
File idpMetaFile = file(outputDir + '/idp-metadata.xml') | ||
List<String> lines = idpMetaFile.readLines("UTF-8") | ||
StringBuilder content = new StringBuilder() | ||
for (String line : lines) { | ||
content.append(line.replace("localhost:4443", "localhost:" + ephemeralPort)) | ||
} | ||
idpMetaFile.delete() | ||
idpMetaFile.createNewFile() | ||
idpMetaFile.write(content.toString(), "UTF-8") | ||
} | ||
} | ||
integTestCluster.dependsOn setupPorts | ||
|
||
integTestCluster { | ||
setting 'xpack.license.self_generated.type', 'trial' | ||
|
@@ -51,8 +72,9 @@ integTestCluster { | |
setting 'xpack.security.authc.realms.native.native.order', '3' | ||
|
||
setting 'xpack.ml.enabled', 'false' | ||
setting 'logger.org.elasticsearch.xpack.security', 'TRACE' | ||
|
||
extraConfigFile 'idp-metadata.xml', idpFixtureProject.file("idp/shibboleth-idp/metadata/idp-metadata.xml") | ||
extraConfigFile 'idp-metadata.xml', file(outputDir + "/idp-metadata.xml") | ||
|
||
setupCommand 'setupTestAdmin', | ||
'bin/elasticsearch-users', 'useradd', "test_admin", '-p', 'x-pack-test-password', '-r', "superuser" | ||
|
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.
Rename task to
copyFiles
or something generic like that ?