|
21 | 21 | import java.net.SocketException;
|
22 | 22 | import java.net.URISyntaxException;
|
23 | 23 | import java.nio.charset.Charset;
|
| 24 | +import java.security.NoSuchProviderException; |
24 | 25 | import java.util.Arrays;
|
25 | 26 | import java.util.Collection;
|
26 | 27 | import java.util.HashSet;
|
|
54 | 55 | import static org.assertj.core.api.Assertions.assertThat;
|
55 | 56 | import static org.hamcrest.CoreMatchers.anyOf;
|
56 | 57 | import static org.hamcrest.CoreMatchers.instanceOf;
|
| 58 | +import static org.junit.Assert.fail; |
57 | 59 | import static org.mockito.Matchers.anyObject;
|
58 | 60 | import static org.mockito.Mockito.inOrder;
|
59 | 61 | import static org.mockito.Mockito.mock;
|
@@ -194,6 +196,41 @@ public void accessLogCanBeCustomized()
|
194 | 196 | testAccessLog("my_access.", "logz", "my_access.logz");
|
195 | 197 | }
|
196 | 198 |
|
| 199 | + @Test |
| 200 | + public void sslKeyStoreProvider() { |
| 201 | + AbstractEmbeddedServletContainerFactory factory = getFactory(); |
| 202 | + Ssl ssl = getSsl(null, "password", "classpath:test.jks"); |
| 203 | + ssl.setKeyStoreProvider("com.example.KeyStoreProvider"); |
| 204 | + factory.setSsl(ssl); |
| 205 | + try { |
| 206 | + factory.getEmbeddedServletContainer(); |
| 207 | + fail(); |
| 208 | + } |
| 209 | + catch (Exception ex) { |
| 210 | + Throwable cause = ex.getCause(); |
| 211 | + assertThat(cause).isInstanceOf(NoSuchProviderException.class); |
| 212 | + assertThat(cause).hasMessageContaining("com.example.KeyStoreProvider"); |
| 213 | + } |
| 214 | + } |
| 215 | + |
| 216 | + @Test |
| 217 | + public void sslTrustStoreProvider() { |
| 218 | + AbstractEmbeddedServletContainerFactory factory = getFactory(); |
| 219 | + Ssl ssl = getSsl(null, null, null); |
| 220 | + ssl.setTrustStore("classpath:test.jks"); |
| 221 | + ssl.setTrustStoreProvider("com.example.TrustStoreProvider"); |
| 222 | + factory.setSsl(ssl); |
| 223 | + try { |
| 224 | + factory.getEmbeddedServletContainer(); |
| 225 | + fail(); |
| 226 | + } |
| 227 | + catch (Exception ex) { |
| 228 | + Throwable cause = ex.getCause(); |
| 229 | + assertThat(cause).isInstanceOf(NoSuchProviderException.class); |
| 230 | + assertThat(cause).hasMessageContaining("com.example.TrustStoreProvider"); |
| 231 | + } |
| 232 | + } |
| 233 | + |
197 | 234 | private void testAccessLog(String prefix, String suffix, String expectedFile)
|
198 | 235 | throws IOException, URISyntaxException, InterruptedException {
|
199 | 236 | UndertowEmbeddedServletContainerFactory factory = getFactory();
|
|
0 commit comments