Add a test that verifies that Netty uses native SSL when we expect it to.
RELNOTES: None.
PiperOrigin-RevId: 251442944
diff --git a/src/test/java/com/google/devtools/build/lib/remote/BUILD b/src/test/java/com/google/devtools/build/lib/remote/BUILD
index d35bd3e..aa6b6af 100644
--- a/src/test/java/com/google/devtools/build/lib/remote/BUILD
+++ b/src/test/java/com/google/devtools/build/lib/remote/BUILD
@@ -15,10 +15,25 @@
visibility = ["//src/test/java/com/google/devtools/build/lib:__pkg__"],
)
+# Do not run NativeSslTest on platforms where native SSL is not available.
+
+NATIVE_SSL_TEST = ["NativeSslTest.java"]
+
+NATIVE_SSL_TEST_MAYBE = select({
+ "//src/conditions:windows": NATIVE_SSL_TEST,
+ "//src/conditions:darwin": NATIVE_SSL_TEST,
+ "//src/conditions:darwin_x86_64": NATIVE_SSL_TEST,
+ "//src/conditions:linux_x86_64": NATIVE_SSL_TEST,
+ "//conditions:default": [],
+})
+
java_test(
name = "remote",
size = "small",
- srcs = glob(["**/*.java"]),
+ srcs = glob(
+ ["**/*.java"],
+ exclude = NATIVE_SSL_TEST,
+ ) + NATIVE_SSL_TEST_MAYBE,
test_class = "com.google.devtools.build.lib.AllTests",
deps = [
"//src/main/java/com/google/devtools/build/lib:build-base",
@@ -49,6 +64,7 @@
"//third_party:api_client",
"//third_party:guava",
"//third_party:mockito",
+ "//third_party:netty",
"//third_party:truth",
"//third_party/grpc:grpc-jar",
"//third_party/protobuf:protobuf_java",
diff --git a/src/test/java/com/google/devtools/build/lib/remote/NativeSslTest.java b/src/test/java/com/google/devtools/build/lib/remote/NativeSslTest.java
new file mode 100644
index 0000000..05da702
--- /dev/null
+++ b/src/test/java/com/google/devtools/build/lib/remote/NativeSslTest.java
@@ -0,0 +1,29 @@
+// Copyright 2019 The Bazel Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.build.lib.remote;
+
+import io.netty.handler.ssl.SslContextBuilder;
+import io.netty.handler.ssl.SslProvider;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/** Tests that we use OpenSSL instead of a Java implementation. */
+@RunWith(JUnit4.class)
+public class NativeSslTest {
+ @Test
+ public void nativeSslPresent() throws Exception {
+ SslContextBuilder.forClient().sslProvider(SslProvider.OPENSSL).build();
+ }
+}