Adjust integration tests for ability, base, and client modules in the core module to comply with checkstyle. (#12335)
* Fix exception code error.(#10925) * [IT]Adjust integration tests for ability, base, and client modules in the core module to comply with checkstyle. * [IT]Optimize the class naming.
This commit is contained in:
parent
2233e6556c
commit
de5ade75c8
@ -30,7 +30,7 @@ public class TestServerAbilityControlManager extends ServerAbilityControlManager
|
||||
Map<AbilityKey, Boolean> map = new HashMap<>();
|
||||
map.put(AbilityKey.SERVER_TEST_1, true);
|
||||
map.put(AbilityKey.SERVER_TEST_2, false);
|
||||
HashMap res = new HashMap<>();
|
||||
HashMap<AbilityMode, Map<AbilityKey, Boolean>> res = new HashMap<>();
|
||||
res.put(AbilityMode.SERVER, map);
|
||||
|
||||
Map<AbilityKey, Boolean> map1 = new HashMap<>();
|
||||
|
@ -28,7 +28,7 @@ import org.springframework.web.util.UriComponentsBuilder;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* Http client for test module
|
||||
* Http client for test module.
|
||||
*
|
||||
* @author nkorange
|
||||
* @since 1.2.0
|
||||
@ -46,18 +46,21 @@ public class HttpClient4Test {
|
||||
|
||||
HttpEntity<?> entity = new HttpEntity<T>(headers);
|
||||
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(this.base.toString() + path).queryParams(params);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(this.base.toString() + path)
|
||||
.queryParams(params);
|
||||
|
||||
return this.restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, clazz);
|
||||
}
|
||||
|
||||
protected <T> ResponseEntity<T> request(String path, MultiValueMap<String, String> params, Class<T> clazz, HttpMethod httpMethod) {
|
||||
protected <T> ResponseEntity<T> request(String path, MultiValueMap<String, String> params, Class<T> clazz,
|
||||
HttpMethod httpMethod) {
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
HttpEntity<?> entity = new HttpEntity<T>(headers);
|
||||
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(this.base.toString() + path).queryParams(params);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(this.base.toString() + path)
|
||||
.queryParams(params);
|
||||
|
||||
return this.restTemplate.exchange(builder.toUriString(), httpMethod, entity, clazz);
|
||||
}
|
||||
|
@ -20,23 +20,42 @@ import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
/**
|
||||
* Utility class for building HTTP request parameters.
|
||||
*
|
||||
* @author nkorange
|
||||
*/
|
||||
public class Params {
|
||||
|
||||
private MultiValueMap<String, String> paramMap;
|
||||
|
||||
/**
|
||||
* Creates a new Params instance.
|
||||
*
|
||||
* @return A new Params instance.
|
||||
*/
|
||||
public static Params newParams() {
|
||||
Params params = new Params();
|
||||
params.paramMap = new LinkedMultiValueMap<String, String>();
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a parameter to the parameter map.
|
||||
*
|
||||
* @param name The name of the parameter.
|
||||
* @param value The value of the parameter.
|
||||
* @return This Params instance for method chaining.
|
||||
*/
|
||||
public Params appendParam(String name, String value) {
|
||||
this.paramMap.add(name, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the built parameter map.
|
||||
*
|
||||
* @return The built MultiValueMap containing all appended parameters.
|
||||
*/
|
||||
public MultiValueMap<String, String> done() {
|
||||
return paramMap;
|
||||
}
|
||||
|
@ -48,13 +48,14 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
*
|
||||
* @author githubcheng2978
|
||||
*/
|
||||
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
|
||||
@TestConfiguration
|
||||
@SpringBootTest(classes = {Nacos.class}, properties = {"server.servlet.context-path=/nacos",
|
||||
RpcConstants.NACOS_SERVER_RPC + ".compatibility=false", RpcConstants.NACOS_SERVER_RPC + ".enableTls=true",
|
||||
RpcConstants.NACOS_SERVER_RPC + ".certChainFile=test-server-cert.pem",
|
||||
RpcConstants.NACOS_SERVER_RPC + ".certPrivateKey=test-server-key.pem"}, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
|
||||
RpcConstants.NACOS_SERVER_RPC + ".certChainFile=test-server-cert.pem", RpcConstants.NACOS_SERVER_RPC
|
||||
+ ".certPrivateKey=test-server-key.pem"}, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
|
||||
@Disabled("TODO, Fix cert expired problem")
|
||||
public class ConfigIntegrationV1ServerNonCompatibility_CITCase {
|
||||
public class ConfigIntegrationV1ServerNonCompatibilityCoreITCase {
|
||||
|
||||
public static AtomicInteger increment = new AtomicInteger(100);
|
||||
|
||||
@ -63,7 +64,8 @@ public class ConfigIntegrationV1ServerNonCompatibility_CITCase {
|
||||
|
||||
@BeforeAll
|
||||
static void beforeClass() throws IOException {
|
||||
ConfigCleanUtils.changeToNewTestNacosHome(ConfigIntegrationV1ServerNonCompatibility_CITCase.class.getSimpleName());
|
||||
ConfigCleanUtils.changeToNewTestNacosHome(
|
||||
ConfigIntegrationV1ServerNonCompatibilityCoreITCase.class.getSimpleName());
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
@ -73,7 +75,7 @@ public class ConfigIntegrationV1ServerNonCompatibility_CITCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
void test_a_TlsServer() throws Exception {
|
||||
void testTlsServer() throws Exception {
|
||||
RpcClient client = RpcClientFactory.createClient("testTlsServer", ConnectionType.GRPC,
|
||||
Collections.singletonMap("labelKey", "labelValue"), null);
|
||||
RpcClient.ServerInfo serverInfo = new RpcClient.ServerInfo();
|
||||
@ -85,7 +87,7 @@ public class ConfigIntegrationV1ServerNonCompatibility_CITCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
void test_b_ServerTlsTrustAll() throws Exception {
|
||||
void testServerTlsTrustAll() throws Exception {
|
||||
RpcClientTlsConfig tlsConfig = new RpcClientTlsConfig();
|
||||
tlsConfig.setEnableTls(true);
|
||||
tlsConfig.setTrustAll(true);
|
||||
@ -108,7 +110,7 @@ public class ConfigIntegrationV1ServerNonCompatibility_CITCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
void test_c_ServerTlsTrustCa() throws Exception {
|
||||
void testServerTlsTrustCa() throws Exception {
|
||||
|
||||
RpcClient.ServerInfo serverInfo = new RpcClient.ServerInfo();
|
||||
serverInfo.setServerIp("127.0.0.1");
|
@ -14,7 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package com.alibaba.nacos.test.client;
|
||||
|
||||
import com.alibaba.nacos.Nacos;
|
||||
@ -48,12 +47,14 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
*
|
||||
* @author githubcheng2978
|
||||
*/
|
||||
@SpringBootTest(classes = {Nacos.class}, properties = {"nacos.standalone=true", RpcConstants.NACOS_SERVER_RPC + ".mutualAuthEnable=true",
|
||||
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
|
||||
@SpringBootTest(classes = {Nacos.class}, properties = {"nacos.standalone=true",
|
||||
RpcConstants.NACOS_SERVER_RPC + ".mutualAuthEnable=true",
|
||||
RpcConstants.NACOS_SERVER_RPC + ".compatibility=false", RpcConstants.NACOS_SERVER_RPC + ".enableTls=true",
|
||||
RpcConstants.NACOS_SERVER_RPC + ".certChainFile=test-server-cert.pem",
|
||||
RpcConstants.NACOS_SERVER_RPC + ".certPrivateKey=test-server-key.pem", RpcConstants.NACOS_SERVER_RPC
|
||||
+ ".trustCollectionCertFile=test-ca-cert.pem"}, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
|
||||
public class ConfigIntegrationV2MutualAuth_CITCase {
|
||||
public class ConfigIntegrationV2MutualAuthCoreITCase {
|
||||
|
||||
public static AtomicInteger increment = new AtomicInteger(100);
|
||||
|
||||
@ -62,7 +63,7 @@ public class ConfigIntegrationV2MutualAuth_CITCase {
|
||||
|
||||
@BeforeAll
|
||||
static void beforeClass() throws IOException {
|
||||
ConfigCleanUtils.changeToNewTestNacosHome(ConfigIntegrationV2MutualAuth_CITCase.class.getSimpleName());
|
||||
ConfigCleanUtils.changeToNewTestNacosHome(ConfigIntegrationV2MutualAuthCoreITCase.class.getSimpleName());
|
||||
|
||||
}
|
||||
|
||||
@ -73,7 +74,7 @@ public class ConfigIntegrationV2MutualAuth_CITCase {
|
||||
|
||||
@Test
|
||||
@Disabled("TODO, fix the cert expired problem")
|
||||
void test_d_MutualAuth() throws Exception {
|
||||
void testMutualAuth() throws Exception {
|
||||
|
||||
RpcClientTlsConfig tlsConfig = new RpcClientTlsConfig();
|
||||
tlsConfig.setEnableTls(true);
|
||||
@ -103,7 +104,7 @@ public class ConfigIntegrationV2MutualAuth_CITCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
void test_e_ServerMutualAuthOnly() throws Exception {
|
||||
void testServerMutualAuthOnly() throws Exception {
|
||||
|
||||
RpcClientTlsConfig tlsConfig = new RpcClientTlsConfig();
|
||||
tlsConfig.setEnableTls(true);
|
@ -14,7 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package com.alibaba.nacos.test.client;
|
||||
|
||||
import com.alibaba.nacos.Nacos;
|
||||
@ -44,16 +43,18 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* use configPublishRequest for communication verification between client and server
|
||||
* Use configPublishRequest for communication verification between client and server.
|
||||
*
|
||||
* @author githubcheng2978
|
||||
*/
|
||||
//todo fix this test case
|
||||
//ConfigIntegrationV3_CITCase and ConfigIntegrationV2MutualAuth_CITCase will fail when run together
|
||||
@SpringBootTest(classes = {Nacos.class}, properties = {"nacos.standalone=true", RpcConstants.NACOS_SERVER_RPC + ".enableTls=true",
|
||||
RpcConstants.NACOS_SERVER_RPC + ".certChainFile=test-server-cert.pem",
|
||||
RpcConstants.NACOS_SERVER_RPC + ".certPrivateKey=test-server-key.pem"}, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
|
||||
public class ConfigIntegrationV3_CITCase {
|
||||
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
|
||||
@SpringBootTest(classes = {Nacos.class}, properties = {"nacos.standalone=true",
|
||||
RpcConstants.NACOS_SERVER_RPC + ".enableTls=true",
|
||||
RpcConstants.NACOS_SERVER_RPC + ".certChainFile=test-server-cert.pem", RpcConstants.NACOS_SERVER_RPC
|
||||
+ ".certPrivateKey=test-server-key.pem"}, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
|
||||
public class ConfigIntegrationV3CoreITCase {
|
||||
|
||||
public static AtomicInteger increment = new AtomicInteger(100);
|
||||
|
||||
@ -62,7 +63,7 @@ public class ConfigIntegrationV3_CITCase {
|
||||
|
||||
@BeforeAll
|
||||
static void beforeClass() throws IOException {
|
||||
ConfigCleanUtils.changeToNewTestNacosHome(ConfigIntegrationV3_CITCase.class.getSimpleName());
|
||||
ConfigCleanUtils.changeToNewTestNacosHome(ConfigIntegrationV3CoreITCase.class.getSimpleName());
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
@ -72,7 +73,7 @@ public class ConfigIntegrationV3_CITCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
void test_e_TlsServerAndPlainClient() throws Exception {
|
||||
void testTlsServerAndPlainClient() throws Exception {
|
||||
RpcClient client = RpcClientFactory.createClient("testTlsServerAndPlainClient", ConnectionType.GRPC,
|
||||
Collections.singletonMap("labelKey", "labelValue"), null);
|
||||
RpcClient.ServerInfo serverInfo = new RpcClient.ServerInfo();
|
||||
@ -93,7 +94,7 @@ public class ConfigIntegrationV3_CITCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
void test_f_ServerTlsTrustAll() throws Exception {
|
||||
void testServerTlsTrustAll() throws Exception {
|
||||
RpcClientTlsConfig tlsConfig = new RpcClientTlsConfig();
|
||||
tlsConfig.setEnableTls(true);
|
||||
tlsConfig.setTrustAll(true);
|
||||
@ -116,7 +117,7 @@ public class ConfigIntegrationV3_CITCase {
|
||||
|
||||
@Disabled("TODO, Fix cert expired problem")
|
||||
@Test
|
||||
void test_g_ServerTlsTrustCa() throws Exception {
|
||||
void testServerTlsTrustCa() throws Exception {
|
||||
|
||||
RpcClient.ServerInfo serverInfo = new RpcClient.ServerInfo();
|
||||
serverInfo.setServerIp("127.0.0.1");
|
Loading…
Reference in New Issue
Block a user