Skip to content

Commit 2e9f53d

Browse files
Autorenew SSL certs and use them everywhere (#431) (#448)
* Autorenew SSL certs and use them everywhere: java unit tests, docker files, ruby spec and integration tests. * Upgrades junit, wiremock, mokito dependencies used by unit tests * Overall flow: - to generate certs first in CI host -> run_tests.sh: used by both unit and integration tests - generate in gradle only if needed, e.g. local ./gradlew clean test - we will not clean certs with gradle clean, if we do integration tests will fail due to mismatch - and genera.sh will skip if certs exist - makes sure we are not generating twice (cherry picked from commit 254e669) Co-authored-by: Mashhur <99575341+mashhurs@users.noreply.github.com>
1 parent b7694ae commit 2e9f53d

32 files changed

Lines changed: 33 additions & 808 deletions

.buildkite/scripts/run_tests.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ else
1111
git checkout "$TARGET_BRANCH"
1212
fi
1313

14+
./utils/ssl-certs-generator/generate.sh
15+
chmod -R 0440 utils/ssl-certs-generator/generated/*
1416
mkdir -p .ci && curl -sL --retry 5 --retry-delay 5 https://github.com/logstash-plugins/.ci/archive/1.x.tar.gz | tar zxvf - --skip-old-files --strip-components=1 -C .ci --wildcards '*Dockerfile*' '*docker*' '*.sh' '*logstash-versions*' && .ci/docker-setup.sh && .ci/docker-run.sh

.ci/Dockerfile.elasticsearch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ARG ES_SSL_SUPPORTED_PROTOCOLS
1010

1111
RUN rm -f $es_path/config/scripts
1212

13-
COPY --chown=elasticsearch:elasticsearch spec/fixtures/test_certs/* $es_path/config/test_certs/
13+
COPY --chown=elasticsearch:elasticsearch utils/ssl-certs-generator/generated/* $es_path/config/test_certs/
1414
COPY --chown=elasticsearch:elasticsearch .ci/elasticsearch-run.sh $es_path/
1515

1616
RUN if [ "$SECURE_INTEGRATION" != "true" ] ; then echo "xpack.security.enabled: false" >> $es_yml; fi

.ci/logstash-run.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,5 @@ else
3939
echo "Waiting for elasticsearch to respond..."
4040
ES_VERSION=$(wait_for_es)
4141
echo "Elasticsearch $ES_VERSION is Up!"
42-
chmod -R 0440 spec/fixtures/test_certs/*
4342
bundle exec rspec --format=documentation $extra_tag_args --tag es_version:$ES_VERSION spec/integration
4443
fi

build.gradle

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,16 @@ dependencies {
104104
from requiredLogstashCoreJar("guava", "jre")
105105
})
106106

107-
mockitoAgent('org.mockito:mockito-core:5.14.1') {
107+
mockitoAgent('org.mockito:mockito-core:5.23.0') {
108108
transitive = false
109109
}
110-
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.1.0'
111-
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.1.0'
112-
testImplementation 'org.mockito:mockito-junit-jupiter:5.14.1'
113-
testImplementation 'org.hamcrest:hamcrest-library:2.2'
114-
testImplementation "com.github.seregamorph:hamcrest-more-matchers:0.1"
115-
testImplementation 'org.wiremock:wiremock:3.12.0'
110+
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.14.3'
111+
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.14.3'
112+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.14.3'
113+
testImplementation 'org.mockito:mockito-junit-jupiter:5.23.0'
114+
testImplementation 'org.hamcrest:hamcrest-library:3.0'
115+
testImplementation "com.github.seregamorph:hamcrest-more-matchers:1.0"
116+
testImplementation 'org.wiremock:wiremock:3.13.2'
116117
testRuntimeOnly requiredLogstashCoreJar("log4j-core")
117118

118119
geolite2('org.elasticsearch:geolite2-databases:20191119') {
@@ -804,6 +805,7 @@ tasks.withType(JavaCompile) {
804805

805806
test {
806807
useJUnitPlatform()
808+
systemProperty 'ssl.test.certs.dir', "${projectDir}/utils/ssl-certs-generator/generated"
807809
testLogging {
808810
exceptionFormat "full"
809811
outputs.upToDateWhen { false }
@@ -812,7 +814,7 @@ test {
812814
}
813815

814816
task generateTestCertificates(type: Exec) {
815-
def sslTestCertsDir = "${projectDir}/src/test/resources/co/elastic/logstash/filters/elasticintegration/ssl-test-certs"
817+
def sslTestCertsDir = "${projectDir}/utils/ssl-certs-generator"
816818

817819
workingDir sslTestCertsDir
818820
commandLine './generate.sh'

spec/fixtures/test_certs/README.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

spec/fixtures/test_certs/ca.p12

-1.74 KB
Binary file not shown.

spec/fixtures/test_certs/client_from_root.chain.crt

Lines changed: 0 additions & 67 deletions
This file was deleted.

spec/fixtures/test_certs/client_from_root.crt

Lines changed: 0 additions & 35 deletions
This file was deleted.
-4.46 KB
Binary file not shown.

spec/fixtures/test_certs/client_from_root.key

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)