From 61fbb12499492d3f007c7f9d52d4071a9bfddbe6 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 22 Oct 2024 13:12:09 -0700 Subject: [PATCH] Polish --- .../ssl/SslAutoConfigurationTests.java | 37 +++++++------------ 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ssl/SslAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ssl/SslAutoConfigurationTests.java index 06cbc41282..87e2e0c3d1 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ssl/SslAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ssl/SslAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 the original author or authors. + * Copyright 2012-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,29 +53,22 @@ class SslAutoConfigurationTests { @Test void sslBundlesCreatedWithCertificates() { List propertyValues = new ArrayList<>(); + String location = "classpath:org/springframework/boot/autoconfigure/ssl/"; propertyValues.add("spring.ssl.bundle.pem.first.key.alias=alias1"); propertyValues.add("spring.ssl.bundle.pem.first.key.password=secret1"); - propertyValues.add( - "spring.ssl.bundle.pem.first.keystore.certificate=classpath:org/springframework/boot/autoconfigure/ssl/rsa-cert.pem"); - propertyValues.add( - "spring.ssl.bundle.pem.first.keystore.private-key=classpath:org/springframework/boot/autoconfigure/ssl/rsa-key.pem"); + propertyValues.add("spring.ssl.bundle.pem.first.keystore.certificate=" + location + "rsa-cert.pem"); + propertyValues.add("spring.ssl.bundle.pem.first.keystore.private-key=" + location + "rsa-key.pem"); propertyValues.add("spring.ssl.bundle.pem.first.keystore.type=PKCS12"); propertyValues.add("spring.ssl.bundle.pem.first.truststore.type=PKCS12"); - propertyValues.add( - "spring.ssl.bundle.pem.first.truststore.certificate=classpath:org/springframework/boot/autoconfigure/ssl/rsa-cert.pem"); - propertyValues.add( - "spring.ssl.bundle.pem.first.truststore.private-key=classpath:org/springframework/boot/autoconfigure/ssl/rsa-key.pem"); + propertyValues.add("spring.ssl.bundle.pem.first.truststore.certificate=" + location + "rsa-cert.pem"); + propertyValues.add("spring.ssl.bundle.pem.first.truststore.private-key=" + location + "rsa-key.pem"); propertyValues.add("spring.ssl.bundle.pem.second.key.alias=alias2"); propertyValues.add("spring.ssl.bundle.pem.second.key.password=secret2"); - propertyValues.add( - "spring.ssl.bundle.pem.second.keystore.certificate=classpath:org/springframework/boot/autoconfigure/ssl/ed25519-cert.pem"); - propertyValues.add( - "spring.ssl.bundle.pem.second.keystore.private-key=classpath:org/springframework/boot/autoconfigure/ssl/ed25519-key.pem"); + propertyValues.add("spring.ssl.bundle.pem.second.keystore.certificate=" + location + "ed25519-cert.pem"); + propertyValues.add("spring.ssl.bundle.pem.second.keystore.private-key=" + location + "ed25519-key.pem"); propertyValues.add("spring.ssl.bundle.pem.second.keystore.type=PKCS12"); - propertyValues.add( - "spring.ssl.bundle.pem.second.truststore.certificate=classpath:org/springframework/boot/autoconfigure/ssl/ed25519-cert.pem"); - propertyValues.add( - "spring.ssl.bundle.pem.second.truststore.private-key=classpath:org/springframework/boot/autoconfigure/ssl/ed25519-key.pem"); + propertyValues.add("spring.ssl.bundle.pem.second.truststore.certificate=" + location + "ed25519-cert.pem"); + propertyValues.add("spring.ssl.bundle.pem.second.truststore.private-key=" + location + "ed25519-key.pem"); propertyValues.add("spring.ssl.bundle.pem.second.truststore.type=PKCS12"); this.contextRunner.withPropertyValues(propertyValues.toArray(String[]::new)).run((context) -> { assertThat(context).hasSingleBean(SslBundles.class); @@ -102,14 +95,12 @@ class SslAutoConfigurationTests { @Test void sslBundlesCreatedWithCustomSslBundle() { List propertyValues = new ArrayList<>(); + String location = "classpath:org/springframework/boot/autoconfigure/ssl/"; propertyValues.add("custom.ssl.key.alias=alias1"); propertyValues.add("custom.ssl.key.password=secret1"); - propertyValues - .add("custom.ssl.keystore.certificate=classpath:org/springframework/boot/autoconfigure/ssl/rsa-cert.pem"); - propertyValues.add( - "custom.ssl.keystore.keystore.private-key=classpath:org/springframework/boot/autoconfigure/ssl/rsa-key.pem"); - propertyValues - .add("custom.ssl.truststore.certificate=classpath:org/springframework/boot/autoconfigure/ssl/rsa-cert.pem"); + propertyValues.add("custom.ssl.keystore.certificate=" + location + "rsa-cert.pem"); + propertyValues.add("custom.ssl.keystore.keystore.private-key=" + location + "rsa-key.pem"); + propertyValues.add("custom.ssl.truststore.certificate=" + location + "rsa-cert.pem"); propertyValues.add("custom.ssl.keystore.type=PKCS12"); propertyValues.add("custom.ssl.truststore.type=PKCS12"); this.contextRunner.withUserConfiguration(CustomSslBundleConfiguration.class)