Skip to content

Commit 285c930

Browse files
authored
[Test] Fix filename check on Windows (#76807)
Replaces "/" with platform file separator character Resolves: #76767
1 parent 077602e commit 285c930

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/ssl/SSLErrorMessageCertificateVerificationTests.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.apache.logging.log4j.Level;
1717
import org.apache.logging.log4j.LogManager;
1818
import org.apache.logging.log4j.Logger;
19-
import org.apache.lucene.util.Constants;
2019
import org.elasticsearch.client.Request;
2120
import org.elasticsearch.client.RestClient;
2221
import org.elasticsearch.common.logging.Loggers;
@@ -99,7 +98,6 @@ public void testMessageForRestClientHostnameVerificationFailure() throws IOExcep
9998

10099
public void testDiagnosticTrustManagerForHostnameVerificationFailure() throws Exception {
101100
assumeFalse("https://github.com/elastic/elasticsearch/issues/49094", inFipsJvm());
102-
assumeFalse("https://github.com/elastic/elasticsearch/issues/76767", Constants.WINDOWS);
103101
final Settings settings = getPemSSLSettings(HTTP_SERVER_SSL, "not-this-host.crt", "not-this-host.key",
104102
SslClientAuthenticationMode.NONE, SslVerificationMode.FULL, null)
105103
.putList("xpack.http.ssl.certificate_authorities", getPath("ca1.crt"))
@@ -118,6 +116,8 @@ public void testDiagnosticTrustManagerForHostnameVerificationFailure() throws Ex
118116
SSLSocket clientSocket = (SSLSocket) clientSocketFactory.createSocket()) {
119117
Loggers.addAppender(diagnosticLogger, mockAppender);
120118

119+
String fileName = "/x-pack/plugin/security/build/resources/test/org/elasticsearch/xpack/ssl/SSLErrorMessageTests/ca1.crt"
120+
.replace('/', platformFileSeparator());
121121
mockAppender.addExpectation(new MockLogAppender.PatternSeenEventExpectation(
122122
"ssl diagnostic",
123123
DiagnosticTrustManager.class.getName(),
@@ -133,9 +133,7 @@ public void testDiagnosticTrustManagerForHostnameVerificationFailure() throws Ex
133133
" is trusted in this ssl context " +
134134
Pattern.quote("([" + HTTP_CLIENT_SSL + " (with trust configuration: PEM-trust{") +
135135
"\\S+" +
136-
Pattern.quote(
137-
"/x-pack/plugin/security/build/resources/test/org/elasticsearch/xpack/ssl/SSLErrorMessageTests/ca1.crt" +
138-
"})])")
136+
Pattern.quote(fileName + "})])")
139137
));
140138

141139
enableHttpsHostnameChecking(clientSocket);
@@ -208,6 +206,11 @@ private Settings.Builder getPemSSLSettings(
208206
return builder;
209207
}
210208

209+
@SuppressForbidden(reason = "Checking error message that outputs platform file separator")
210+
private static char platformFileSeparator() {
211+
return java.io.File.separatorChar;
212+
}
213+
211214
private static String randomCapitalization(Enum<?> enumValue) {
212215
return randomBoolean() ? enumValue.name() : enumValue.name().toLowerCase(Locale.ROOT);
213216
}

0 commit comments

Comments
 (0)