Skip to content

Commit f1d8eb6

Browse files
Fix for FP
1 parent 451acc1 commit f1d8eb6

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

  • its/it-tests/src/test/java/com/sonar/scanner/api/it

its/it-tests/src/test/java/com/sonar/scanner/api/it/SSLTest.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ private static void startSSLTransparentReverseProxy(boolean requireClientAuth) t
108108

109109
// Handler Structure
110110
HandlerCollection handlers = new HandlerCollection();
111-
handlers.setHandlers(new Handler[] {proxyHandler(), new DefaultHandler()});
111+
handlers.setHandlers(new Handler[]{proxyHandler(), new DefaultHandler()});
112112
server.setHandler(handlers);
113113

114114
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
@@ -123,7 +123,7 @@ private static void startSSLTransparentReverseProxy(boolean requireClientAuth) t
123123
sslContextFactory.setKeyStorePath(serverKeyStore.toString());
124124
sslContextFactory.setKeyStorePassword(JKS_PASSWORD);
125125
sslContextFactory.setKeyManagerPassword("");
126-
if ( requireClientAuth) {
126+
if (requireClientAuth) {
127127
Path serverTrustStore = Paths.get(SSLTest.class.getResource(SERVER_TRUSTSTORE).toURI()).toAbsolutePath();
128128
sslContextFactory.setTrustStorePath(serverTrustStore.toString());
129129
assertThat(serverTrustStore).exists();
@@ -212,7 +212,13 @@ public void simple_analysis_with_server_and_without_client_certificate_is_failin
212212

213213
buildResult = scanner.executeSimpleProject(project("js-sample"), "https://localhost:" + httpsPort, params);
214214
assertThat(buildResult.getLastStatus()).isEqualTo(1);
215-
assertThat(buildResult.getLogs()).contains("bad_certificate");
215+
216+
// different exception is thrown depending on the JDK version. See: https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8172163
217+
assertThat(buildResult.getLogs()).matches(p ->
218+
p.matches("(?s).*org\\.sonarsource\\.scanner\\.api\\.internal\\.ScannerException: Unable to execute SonarQube.*" +
219+
"Caused by: javax\\.net\\.ssl\\.SSLProtocolException: Broken pipe \\(Write failed\\).*") ||
220+
p.matches("(?s).*org\\.sonarsource\\.scanner\\.api\\.internal\\.ScannerException: Unable to execute SonarQube.*" +
221+
"Caused by: javax\\.net\\.ssl\\.SSLHandshakeException: Received fatal alert: bad_certificate.*"));
216222
}
217223

218224
private static Path project(String projectName) {

0 commit comments

Comments
 (0)