|
|
|
@ -28,7 +28,6 @@ import org.junit.jupiter.params.provider.ValueSource; |
|
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
import static org.assertj.core.api.Assertions.assertThatIllegalStateException; |
|
|
|
import static org.assertj.core.api.Assertions.assertThatIllegalStateException; |
|
|
|
import static org.assertj.core.api.Assertions.assertThatThrownBy; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Tests for {@link PrivateKeyParser}. |
|
|
|
* Tests for {@link PrivateKeyParser}. |
|
|
|
@ -75,12 +74,12 @@ class PrivateKeyParserTests { |
|
|
|
}) |
|
|
|
}) |
|
|
|
// @formatter:on
|
|
|
|
// @formatter:on
|
|
|
|
void shouldNotParseUnsupportedTraditionalPkcs1(String file) { |
|
|
|
void shouldNotParseUnsupportedTraditionalPkcs1(String file) { |
|
|
|
assertThatThrownBy(() -> PrivateKeyParser.parse("classpath:org/springframework/boot/web/server/pkcs1/" + file)) |
|
|
|
assertThatIllegalStateException() |
|
|
|
.isInstanceOf(IllegalStateException.class) |
|
|
|
.isThrownBy(() -> PrivateKeyParser.parse("classpath:org/springframework/boot/web/server/pkcs1/" + file)) |
|
|
|
.hasMessageContaining("Error loading private key file") |
|
|
|
.withMessageContaining("Error loading private key file") |
|
|
|
.hasCauseInstanceOf(IllegalStateException.class) |
|
|
|
.withCauseInstanceOf(IllegalStateException.class) |
|
|
|
.getCause() |
|
|
|
.havingCause() |
|
|
|
.hasMessageContaining("Unrecognized private key format"); |
|
|
|
.withMessageContaining("Unrecognized private key format"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ParameterizedTest |
|
|
|
@ParameterizedTest |
|
|
|
@ -118,12 +117,12 @@ class PrivateKeyParserTests { |
|
|
|
}) |
|
|
|
}) |
|
|
|
// @formatter:on
|
|
|
|
// @formatter:on
|
|
|
|
void shouldNotParseUnsupportedEcPkcs8(String file) { |
|
|
|
void shouldNotParseUnsupportedEcPkcs8(String file) { |
|
|
|
assertThatThrownBy(() -> PrivateKeyParser.parse("classpath:org/springframework/boot/web/server/pkcs8/" + file)) |
|
|
|
assertThatIllegalStateException() |
|
|
|
.isInstanceOf(IllegalStateException.class) |
|
|
|
.isThrownBy(() -> PrivateKeyParser.parse("classpath:org/springframework/boot/web/server/pkcs8/" + file)) |
|
|
|
.hasMessageContaining("Error loading private key file") |
|
|
|
.withMessageContaining("Error loading private key file") |
|
|
|
.hasCauseInstanceOf(IllegalStateException.class) |
|
|
|
.withCauseInstanceOf(IllegalStateException.class) |
|
|
|
.getCause() |
|
|
|
.havingCause() |
|
|
|
.hasMessageContaining("Unrecognized private key format"); |
|
|
|
.withMessageContaining("Unrecognized private key format"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@EnabledForJreRange(min = JRE.JAVA_17, disabledReason = "EdDSA is only supported since Java 17") |
|
|
|
@EnabledForJreRange(min = JRE.JAVA_17, disabledReason = "EdDSA is only supported since Java 17") |
|
|
|
@ -191,12 +190,12 @@ class PrivateKeyParserTests { |
|
|
|
}) |
|
|
|
}) |
|
|
|
// @formatter:on
|
|
|
|
// @formatter:on
|
|
|
|
void shouldNotParseUnsupportedEcSec1(String file) { |
|
|
|
void shouldNotParseUnsupportedEcSec1(String file) { |
|
|
|
assertThatThrownBy(() -> PrivateKeyParser.parse("classpath:org/springframework/boot/web/server/sec1/" + file)) |
|
|
|
assertThatIllegalStateException() |
|
|
|
.isInstanceOf(IllegalStateException.class) |
|
|
|
.isThrownBy(() -> PrivateKeyParser.parse("classpath:org/springframework/boot/web/server/sec1/" + file)) |
|
|
|
.hasMessageContaining("Error loading private key file") |
|
|
|
.withMessageContaining("Error loading private key file") |
|
|
|
.hasCauseInstanceOf(IllegalStateException.class) |
|
|
|
.withCauseInstanceOf(IllegalStateException.class) |
|
|
|
.getCause() |
|
|
|
.havingCause() |
|
|
|
.hasMessageContaining("Unrecognized private key format"); |
|
|
|
.withMessageContaining("Unrecognized private key format"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
|