oxsean commented on code in PR #14520: URL: https://github.com/apache/dubbo/pull/14520#discussion_r1724486877
########## dubbo-rpc/dubbo-rpc-triple/src/test/resources/certs/server.key: ########## @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- Review Comment: Confirm all certificates are valid for more than 50 years ########## dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/TripleHttp3ProtocolTest.java: ########## @@ -0,0 +1,148 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.dubbo.rpc.protocol.tri; + +import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.stream.StreamObserver; +import org.apache.dubbo.common.utils.ClassUtils; +import org.apache.dubbo.common.utils.NetUtils; +import org.apache.dubbo.config.SslConfig; +import org.apache.dubbo.config.context.ConfigManager; +import org.apache.dubbo.rpc.Constants; +import org.apache.dubbo.rpc.Exporter; +import org.apache.dubbo.rpc.Invoker; +import org.apache.dubbo.rpc.Protocol; +import org.apache.dubbo.rpc.ProxyFactory; +import org.apache.dubbo.rpc.model.ApplicationModel; +import org.apache.dubbo.rpc.model.ConsumerModel; +import org.apache.dubbo.rpc.model.ModuleServiceRepository; +import org.apache.dubbo.rpc.model.ProviderModel; +import org.apache.dubbo.rpc.model.ServiceDescriptor; +import org.apache.dubbo.rpc.model.ServiceMetadata; +import org.apache.dubbo.rpc.protocol.tri.support.IGreeter; +import org.apache.dubbo.rpc.protocol.tri.support.IGreeterImpl; +import org.apache.dubbo.rpc.protocol.tri.support.MockStreamObserver; + +import java.nio.file.Paths; +import java.util.concurrent.TimeUnit; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import static org.apache.dubbo.rpc.protocol.tri.support.IGreeter.SERVER_MSG; + +class TripleHttp3ProtocolTest { + + @Test + void testDemoProtocol() throws Exception { + IGreeter serviceImpl = new IGreeterImpl(); + int availablePort = NetUtils.getAvailablePort(); + ApplicationModel applicationModel = ApplicationModel.defaultModel(); + ConfigManager configManager = applicationModel.getApplicationConfigManager(); + + SslConfig sslConfig = new SslConfig(); + sslConfig.setScopeModel(applicationModel); + java.net.URL serverCertUrl = TripleHttp3ProtocolTest.class.getResource("/certs/server.pem"); + java.net.URL serverKeyUrl = TripleHttp3ProtocolTest.class.getResource("/certs/server.key"); + java.net.URL clientCertUrl = TripleHttp3ProtocolTest.class.getResource("/certs/client.pem"); + java.net.URL clientKeyUrl = TripleHttp3ProtocolTest.class.getResource("/certs/client.key"); + java.net.URL trustCertUrl = TripleHttp3ProtocolTest.class.getResource("/certs/ca.pem"); + Assertions.assertNotNull(serverCertUrl, "serverCertUrl should not be null"); + sslConfig.setServerKeyCertChainPath( + Paths.get(serverCertUrl.toURI()).toAbsolutePath().toString()); + Assertions.assertNotNull(serverKeyUrl, "serverKeyUrl should not be null"); + sslConfig.setServerPrivateKeyPath( + Paths.get(serverKeyUrl.toURI()).toAbsolutePath().toString()); + Assertions.assertNotNull(trustCertUrl, "serverKeyUrl should not be null"); Review Comment: trustCertUrl ########## dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/TripleHttp3ProtocolTest.java: ########## @@ -0,0 +1,148 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.dubbo.rpc.protocol.tri; + +import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.stream.StreamObserver; +import org.apache.dubbo.common.utils.ClassUtils; +import org.apache.dubbo.common.utils.NetUtils; +import org.apache.dubbo.config.SslConfig; +import org.apache.dubbo.config.context.ConfigManager; +import org.apache.dubbo.rpc.Constants; +import org.apache.dubbo.rpc.Exporter; +import org.apache.dubbo.rpc.Invoker; +import org.apache.dubbo.rpc.Protocol; +import org.apache.dubbo.rpc.ProxyFactory; +import org.apache.dubbo.rpc.model.ApplicationModel; +import org.apache.dubbo.rpc.model.ConsumerModel; +import org.apache.dubbo.rpc.model.ModuleServiceRepository; +import org.apache.dubbo.rpc.model.ProviderModel; +import org.apache.dubbo.rpc.model.ServiceDescriptor; +import org.apache.dubbo.rpc.model.ServiceMetadata; +import org.apache.dubbo.rpc.protocol.tri.support.IGreeter; +import org.apache.dubbo.rpc.protocol.tri.support.IGreeterImpl; +import org.apache.dubbo.rpc.protocol.tri.support.MockStreamObserver; + +import java.nio.file.Paths; +import java.util.concurrent.TimeUnit; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import static org.apache.dubbo.rpc.protocol.tri.support.IGreeter.SERVER_MSG; + +class TripleHttp3ProtocolTest { + + @Test + void testDemoProtocol() throws Exception { + IGreeter serviceImpl = new IGreeterImpl(); + int availablePort = NetUtils.getAvailablePort(); + ApplicationModel applicationModel = ApplicationModel.defaultModel(); + ConfigManager configManager = applicationModel.getApplicationConfigManager(); + + SslConfig sslConfig = new SslConfig(); + sslConfig.setScopeModel(applicationModel); + java.net.URL serverCertUrl = TripleHttp3ProtocolTest.class.getResource("/certs/server.pem"); + java.net.URL serverKeyUrl = TripleHttp3ProtocolTest.class.getResource("/certs/server.key"); + java.net.URL clientCertUrl = TripleHttp3ProtocolTest.class.getResource("/certs/client.pem"); + java.net.URL clientKeyUrl = TripleHttp3ProtocolTest.class.getResource("/certs/client.key"); + java.net.URL trustCertUrl = TripleHttp3ProtocolTest.class.getResource("/certs/ca.pem"); + Assertions.assertNotNull(serverCertUrl, "serverCertUrl should not be null"); + sslConfig.setServerKeyCertChainPath( + Paths.get(serverCertUrl.toURI()).toAbsolutePath().toString()); + Assertions.assertNotNull(serverKeyUrl, "serverKeyUrl should not be null"); + sslConfig.setServerPrivateKeyPath( + Paths.get(serverKeyUrl.toURI()).toAbsolutePath().toString()); + Assertions.assertNotNull(trustCertUrl, "serverKeyUrl should not be null"); + sslConfig.setServerTrustCertCollectionPath( + Paths.get(trustCertUrl.toURI()).toAbsolutePath().toString()); + Assertions.assertNotNull(clientCertUrl, "clientCertUrl should not be null"); + sslConfig.setClientKeyCertChainPath( + Paths.get(clientCertUrl.toURI()).toAbsolutePath().toString()); + Assertions.assertNotNull(clientKeyUrl, "serverKeyUrl should not be null"); Review Comment: clientKeyUrl ########## dubbo-rpc/dubbo-rpc-triple/src/test/resources/certs/client.key: ########## @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- Review Comment: No need for csr ########## dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/TripleHttp3ProtocolTest.java: ########## @@ -0,0 +1,148 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.dubbo.rpc.protocol.tri; + +import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.stream.StreamObserver; +import org.apache.dubbo.common.utils.ClassUtils; +import org.apache.dubbo.common.utils.NetUtils; +import org.apache.dubbo.config.SslConfig; +import org.apache.dubbo.config.context.ConfigManager; +import org.apache.dubbo.rpc.Constants; +import org.apache.dubbo.rpc.Exporter; +import org.apache.dubbo.rpc.Invoker; +import org.apache.dubbo.rpc.Protocol; +import org.apache.dubbo.rpc.ProxyFactory; +import org.apache.dubbo.rpc.model.ApplicationModel; +import org.apache.dubbo.rpc.model.ConsumerModel; +import org.apache.dubbo.rpc.model.ModuleServiceRepository; +import org.apache.dubbo.rpc.model.ProviderModel; +import org.apache.dubbo.rpc.model.ServiceDescriptor; +import org.apache.dubbo.rpc.model.ServiceMetadata; +import org.apache.dubbo.rpc.protocol.tri.support.IGreeter; +import org.apache.dubbo.rpc.protocol.tri.support.IGreeterImpl; +import org.apache.dubbo.rpc.protocol.tri.support.MockStreamObserver; + +import java.nio.file.Paths; +import java.util.concurrent.TimeUnit; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import static org.apache.dubbo.rpc.protocol.tri.support.IGreeter.SERVER_MSG; + +class TripleHttp3ProtocolTest { + + @Test + void testDemoProtocol() throws Exception { + IGreeter serviceImpl = new IGreeterImpl(); + int availablePort = NetUtils.getAvailablePort(); + ApplicationModel applicationModel = ApplicationModel.defaultModel(); + ConfigManager configManager = applicationModel.getApplicationConfigManager(); + + SslConfig sslConfig = new SslConfig(); + sslConfig.setScopeModel(applicationModel); + java.net.URL serverCertUrl = TripleHttp3ProtocolTest.class.getResource("/certs/server.pem"); + java.net.URL serverKeyUrl = TripleHttp3ProtocolTest.class.getResource("/certs/server.key"); + java.net.URL clientCertUrl = TripleHttp3ProtocolTest.class.getResource("/certs/client.pem"); + java.net.URL clientKeyUrl = TripleHttp3ProtocolTest.class.getResource("/certs/client.key"); + java.net.URL trustCertUrl = TripleHttp3ProtocolTest.class.getResource("/certs/ca.pem"); + Assertions.assertNotNull(serverCertUrl, "serverCertUrl should not be null"); + sslConfig.setServerKeyCertChainPath( + Paths.get(serverCertUrl.toURI()).toAbsolutePath().toString()); + Assertions.assertNotNull(serverKeyUrl, "serverKeyUrl should not be null"); + sslConfig.setServerPrivateKeyPath( + Paths.get(serverKeyUrl.toURI()).toAbsolutePath().toString()); + Assertions.assertNotNull(trustCertUrl, "serverKeyUrl should not be null"); + sslConfig.setServerTrustCertCollectionPath( + Paths.get(trustCertUrl.toURI()).toAbsolutePath().toString()); + Assertions.assertNotNull(clientCertUrl, "clientCertUrl should not be null"); + sslConfig.setClientKeyCertChainPath( + Paths.get(clientCertUrl.toURI()).toAbsolutePath().toString()); + Assertions.assertNotNull(clientKeyUrl, "serverKeyUrl should not be null"); + sslConfig.setClientPrivateKeyPath( + Paths.get(clientKeyUrl.toURI()).toAbsolutePath().toString()); + Assertions.assertNotNull(trustCertUrl, "trustCertUrl should not be null"); + sslConfig.setClientTrustCertCollectionPath( Review Comment: You can create a common method such as: ```java private static String getCertPath(String name) { java.net.URL certUrl = TripleHttp3ProtocolTest.class.getResource("/certs/"+name); Assertions.assertNotNull(certUrl, "Cert file '/certs/"+ name + "' is required"); return Paths.get(certUrl.toURI()).toAbsolutePath().toString() } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
