From 6029ea429021e9e84acff594c5e30b69441ec646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E7=BF=8A=20SionYang?= Date: Fri, 6 Dec 2024 10:38:57 +0800 Subject: [PATCH] Use new nacos.io url replace older. (#12928) --- README.md | 16 +- .../nacos/auth/config/AuthErrorCode.java | 4 +- ...ernalConfigInfoPersistServiceImplTest.java | 353 ++++++++++-------- console-ui/src/config.js | 12 +- distribution/conf/announcement_en-US.conf | 2 +- distribution/conf/announcement_zh-CN.conf | 2 +- distribution/conf/console-guide.conf | 2 +- .../auth/impl/token/impl/JwtTokenManager.java | 4 +- 8 files changed, 222 insertions(+), 173 deletions(-) diff --git a/README.md b/README.md index 625eb068440..67ce034542e 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Nacos (official site: [nacos.io](https://nacos.io)) is an easy-to-use platform designed for dynamic service discovery and configuration and service management. It helps you to build cloud native applications and microservices platform easily. -Service is a first-class citizen in Nacos. Nacos supports almost all type of services,for example,[Dubbo/gRPC service](https://nacos.io/en-us/docs/use-nacos-with-dubbo.html), [Spring Cloud RESTFul service](https://nacos.io/en-us/docs/use-nacos-with-springcloud.html) or [Kubernetes service](https://nacos.io/en-us/docs/use-nacos-with-kubernetes.html). +Service is a first-class citizen in Nacos. Nacos supports almost all type of services,for example,[Dubbo/gRPC service](https://nacos.io/docs/latest/ecology/use-nacos-with-dubbo/), [Spring Cloud RESTFul service](https://nacos.io/docs/latest/ecology/use-nacos-with-spring-cloud/) or [Kubernetes service](https://nacos.io/docs/latest/quickstart/quick-start-kubernetes/). Nacos provides four major functions. @@ -68,23 +68,23 @@ On the **Windows** platform, run the following command to start server with stan startup.cmd -m standalone ``` -For more details, see [quick-start.](https://nacos.io/en-us/docs/quick-start.html) +For more details, see [quick-start.](https://nacos.io/docs/latest/quickstart/quick-start/) ## Quick start for other open-source projects: -* [Quick start with Nacos command and console](https://nacos.io/en-us/docs/quick-start.html) +* [Quick start with Nacos command and console](https://nacos.io/docs/latest/quickstart/quick-start/) -* [Quick start with dubbo](https://nacos.io/en-us/docs/use-nacos-with-dubbo.html) +* [Quick start with dubbo](https://nacos.io/docs/latest/ecology/use-nacos-with-dubbo/) -* [Quick start with spring cloud](https://nacos.io/en-us/docs/quick-start-spring-cloud.html) +* [Quick start with spring cloud](https://nacos.io/docs/latest/ecology/use-nacos-with-spring-cloud/) -* [Quick start with kubernetes](https://nacos.io/en-us/docs/use-nacos-with-kubernetes.html) +* [Quick start with kubernetes](https://nacos.io/docs/latest/quickstart/quick-start-kubernetes/) ## Documentation -You can view the full documentation from the [Nacos website](https://nacos.io/en-us/docs/v2/what-is-nacos.html). +You can view the full documentation from the [Nacos website](https://nacos.io/docs/latest/overview/). -You can also read this online eBook from the [NACOS ARCHITECTURE & PRINCIPLES](https://www.yuque.com/nacos/ebook/kbyo6n). +You can also read this online eBook from the [NACOS ARCHITECTURE & PRINCIPLES](https://nacos.io/docs/ebook/kbyo6n/). All the latest and long-term notice can also be found here from [GitHub notice issue](https://github.com/alibaba/nacos/labels/notice). diff --git a/auth/src/main/java/com/alibaba/nacos/auth/config/AuthErrorCode.java b/auth/src/main/java/com/alibaba/nacos/auth/config/AuthErrorCode.java index 85e846f8172..4e2f27e3619 100644 --- a/auth/src/main/java/com/alibaba/nacos/auth/config/AuthErrorCode.java +++ b/auth/src/main/java/com/alibaba/nacos/auth/config/AuthErrorCode.java @@ -27,10 +27,10 @@ public enum AuthErrorCode { * invalid auth type. */ INVALID_TYPE(50001, - "Invalid auth type, Please set `nacos.core.auth.system.type`, detail: https://nacos.io/zh-cn/docs/v2/plugin/auth-plugin.html"), + "Invalid auth type, Please set `nacos.core.auth.system.type`, detail: https://nacos.io/docs/latest/manual/admin/auth/"), EMPTY_IDENTITY(50002, - "Empty identity, Please set `nacos.core.auth.server.identity.key` and `nacos.core.auth.server.identity.value`, detail: https://nacos.io/zh-cn/docs/v2/guide/user/auth.html"); + "Empty identity, Please set `nacos.core.auth.server.identity.key` and `nacos.core.auth.server.identity.value`, detail: https://nacos.io/docs/latest/manual/admin/auth/"); private final Integer code; diff --git a/config/src/test/java/com/alibaba/nacos/config/server/service/repository/extrnal/ExternalConfigInfoPersistServiceImplTest.java b/config/src/test/java/com/alibaba/nacos/config/server/service/repository/extrnal/ExternalConfigInfoPersistServiceImplTest.java index adce23f16e0..eb2cca31013 100644 --- a/config/src/test/java/com/alibaba/nacos/config/server/service/repository/extrnal/ExternalConfigInfoPersistServiceImplTest.java +++ b/config/src/test/java/com/alibaba/nacos/config/server/service/repository/extrnal/ExternalConfigInfoPersistServiceImplTest.java @@ -121,7 +121,8 @@ void before() { when(dataSourceService.getDataSourceType()).thenReturn("mysql"); /*when(EnvUtil.getProperty(anyString(), eq(Boolean.class), eq(false))).thenReturn(false);*/ - envUtilMockedStatic.when(() -> EnvUtil.getProperty(anyString(), eq(Boolean.class), eq(false))).thenReturn(false); + envUtilMockedStatic.when(() -> EnvUtil.getProperty(anyString(), eq(Boolean.class), eq(false))) + .thenReturn(false); externalConfigInfoPersistService = new ExternalConfigInfoPersistServiceImpl(historyConfigInfoPersistService); } @@ -151,20 +152,24 @@ void testInsertOrUpdateOfInsertConfigSuccess() { eq(CONFIG_INFO_STATE_WRAPPER_ROW_MAPPER))).thenReturn(null, new ConfigInfoStateWrapper()); //mock insert config info Mockito.when(jdbcTemplate.update(any(PreparedStatementCreator.class), eq(generatedKeyHolder))).thenReturn(1); - Mockito.when(jdbcTemplate.update(eq(externalConfigInfoPersistService.mapperManager.findMapper(dataSourceService.getDataSourceType(), - TableConstant.CONFIG_TAGS_RELATION) - .insert(Arrays.asList("id", "tag_name", "tag_type", "data_id", "group_id", "tenant_id"))), eq(insertConfigIndoId), - eq("tag1"), eq(StringUtils.EMPTY), eq(dataId), eq(group), eq(tenant))).thenReturn(1); - Mockito.when(jdbcTemplate.update(eq(externalConfigInfoPersistService.mapperManager.findMapper(dataSourceService.getDataSourceType(), - TableConstant.CONFIG_TAGS_RELATION) - .insert(Arrays.asList("id", "tag_name", "tag_type", "data_id", "group_id", "tenant_id"))), eq(insertConfigIndoId), - eq("tag2"), eq(StringUtils.EMPTY), eq(dataId), eq(group), eq(tenant))).thenReturn(1); + Mockito.when(jdbcTemplate.update( + eq(externalConfigInfoPersistService.mapperManager.findMapper(dataSourceService.getDataSourceType(), + TableConstant.CONFIG_TAGS_RELATION) + .insert(Arrays.asList("id", "tag_name", "tag_type", "data_id", "group_id", "tenant_id"))), + eq(insertConfigIndoId), eq("tag1"), eq(StringUtils.EMPTY), eq(dataId), eq(group), eq(tenant))) + .thenReturn(1); + Mockito.when(jdbcTemplate.update( + eq(externalConfigInfoPersistService.mapperManager.findMapper(dataSourceService.getDataSourceType(), + TableConstant.CONFIG_TAGS_RELATION) + .insert(Arrays.asList("id", "tag_name", "tag_type", "data_id", "group_id", "tenant_id"))), + eq(insertConfigIndoId), eq("tag2"), eq(StringUtils.EMPTY), eq(dataId), eq(group), eq(tenant))) + .thenReturn(1); String srcIp = "srcIp"; String srcUser = "srcUser"; //mock insert config info Mockito.doNothing().when(historyConfigInfoPersistService) - .insertConfigHistoryAtomic(eq(0), eq(configInfo), eq(srcIp), eq(srcUser), any(Timestamp.class), - eq("I"), eq("formal"), eq(ConfigExtInfoUtil.getExtraInfoFromAdvanceInfoMap(configAdvanceInfo, srcUser))); + .insertConfigHistoryAtomic(eq(0), eq(configInfo), eq(srcIp), eq(srcUser), any(Timestamp.class), eq("I"), + eq("formal"), eq(ConfigExtInfoUtil.getExtraInfoFromAdvanceInfoMap(configAdvanceInfo, srcUser))); externalConfigInfoPersistService.insertOrUpdate(srcIp, srcUser, configInfo, configAdvanceInfo); //expect insert config info @@ -173,18 +178,19 @@ void testInsertOrUpdateOfInsertConfigSuccess() { Mockito.verify(jdbcTemplate, times(1)).update(eq( externalConfigInfoPersistService.mapperManager.findMapper(dataSourceService.getDataSourceType(), TableConstant.CONFIG_TAGS_RELATION) - .insert(Arrays.asList("id", "tag_name", "tag_type", "data_id", "group_id", "tenant_id"))), eq(insertConfigIndoId), - eq("tag1"), eq(StringUtils.EMPTY), eq(dataId), eq(group), eq(tenant)); + .insert(Arrays.asList("id", "tag_name", "tag_type", "data_id", "group_id", "tenant_id"))), + eq(insertConfigIndoId), eq("tag1"), eq(StringUtils.EMPTY), eq(dataId), eq(group), eq(tenant)); Mockito.verify(jdbcTemplate, times(1)).update(eq( externalConfigInfoPersistService.mapperManager.findMapper(dataSourceService.getDataSourceType(), TableConstant.CONFIG_TAGS_RELATION) - .insert(Arrays.asList("id", "tag_name", "tag_type", "data_id", "group_id", "tenant_id"))), eq(insertConfigIndoId), - eq("tag2"), eq(StringUtils.EMPTY), eq(dataId), eq(group), eq(tenant)); + .insert(Arrays.asList("id", "tag_name", "tag_type", "data_id", "group_id", "tenant_id"))), + eq(insertConfigIndoId), eq("tag2"), eq(StringUtils.EMPTY), eq(dataId), eq(group), eq(tenant)); //expect insert history info Mockito.verify(historyConfigInfoPersistService, times(1)) .insertConfigHistoryAtomic(eq(0L), eq(configInfo), eq(srcIp), eq(srcUser), any(Timestamp.class), - eq("I"), eq("formal"), eq(ConfigExtInfoUtil.getExtraInfoFromAdvanceInfoMap(configAdvanceInfo, srcUser))); + eq("I"), eq("formal"), + eq(ConfigExtInfoUtil.getExtraInfoFromAdvanceInfoMap(configAdvanceInfo, srcUser))); } @@ -207,20 +213,24 @@ void testInsertOrUpdateCasOfInsertConfigSuccess() { eq(CONFIG_INFO_STATE_WRAPPER_ROW_MAPPER))).thenReturn(null, new ConfigInfoStateWrapper()); //mock insert config info Mockito.when(jdbcTemplate.update(any(PreparedStatementCreator.class), eq(generatedKeyHolder))).thenReturn(1); - Mockito.when(jdbcTemplate.update(eq(externalConfigInfoPersistService.mapperManager.findMapper(dataSourceService.getDataSourceType(), - TableConstant.CONFIG_TAGS_RELATION) - .insert(Arrays.asList("id", "tag_name", "tag_type", "data_id", "group_id", "tenant_id"))), eq(insertConfigIndoId), - eq("tag1"), eq(StringUtils.EMPTY), eq(dataId), eq(group), eq(tenant))).thenReturn(1); - Mockito.when(jdbcTemplate.update(eq(externalConfigInfoPersistService.mapperManager.findMapper(dataSourceService.getDataSourceType(), - TableConstant.CONFIG_TAGS_RELATION) - .insert(Arrays.asList("id", "tag_name", "tag_type", "data_id", "group_id", "tenant_id"))), eq(insertConfigIndoId), - eq("tag2"), eq(StringUtils.EMPTY), eq(dataId), eq(group), eq(tenant))).thenReturn(1); + Mockito.when(jdbcTemplate.update( + eq(externalConfigInfoPersistService.mapperManager.findMapper(dataSourceService.getDataSourceType(), + TableConstant.CONFIG_TAGS_RELATION) + .insert(Arrays.asList("id", "tag_name", "tag_type", "data_id", "group_id", "tenant_id"))), + eq(insertConfigIndoId), eq("tag1"), eq(StringUtils.EMPTY), eq(dataId), eq(group), eq(tenant))) + .thenReturn(1); + Mockito.when(jdbcTemplate.update( + eq(externalConfigInfoPersistService.mapperManager.findMapper(dataSourceService.getDataSourceType(), + TableConstant.CONFIG_TAGS_RELATION) + .insert(Arrays.asList("id", "tag_name", "tag_type", "data_id", "group_id", "tenant_id"))), + eq(insertConfigIndoId), eq("tag2"), eq(StringUtils.EMPTY), eq(dataId), eq(group), eq(tenant))) + .thenReturn(1); String srcIp = "srcIp"; String srcUser = "srcUser"; //mock insert config info Mockito.doNothing().when(historyConfigInfoPersistService) - .insertConfigHistoryAtomic(eq(0), eq(configInfo), eq(srcIp), eq(srcUser), any(Timestamp.class), - eq("I"), eq("formal"), eq(ConfigExtInfoUtil.getExtraInfoFromAdvanceInfoMap(configAdvanceInfo, srcUser))); + .insertConfigHistoryAtomic(eq(0), eq(configInfo), eq(srcIp), eq(srcUser), any(Timestamp.class), eq("I"), + eq("formal"), eq(ConfigExtInfoUtil.getExtraInfoFromAdvanceInfoMap(configAdvanceInfo, srcUser))); externalConfigInfoPersistService.insertOrUpdateCas(srcIp, srcUser, configInfo, configAdvanceInfo); //expect insert config info @@ -229,18 +239,19 @@ void testInsertOrUpdateCasOfInsertConfigSuccess() { Mockito.verify(jdbcTemplate, times(1)).update(eq( externalConfigInfoPersistService.mapperManager.findMapper(dataSourceService.getDataSourceType(), TableConstant.CONFIG_TAGS_RELATION) - .insert(Arrays.asList("id", "tag_name", "tag_type", "data_id", "group_id", "tenant_id"))), eq(insertConfigIndoId), - eq("tag1"), eq(StringUtils.EMPTY), eq(dataId), eq(group), eq(tenant)); + .insert(Arrays.asList("id", "tag_name", "tag_type", "data_id", "group_id", "tenant_id"))), + eq(insertConfigIndoId), eq("tag1"), eq(StringUtils.EMPTY), eq(dataId), eq(group), eq(tenant)); Mockito.verify(jdbcTemplate, times(1)).update(eq( externalConfigInfoPersistService.mapperManager.findMapper(dataSourceService.getDataSourceType(), TableConstant.CONFIG_TAGS_RELATION) - .insert(Arrays.asList("id", "tag_name", "tag_type", "data_id", "group_id", "tenant_id"))), eq(insertConfigIndoId), - eq("tag2"), eq(StringUtils.EMPTY), eq(dataId), eq(group), eq(tenant)); + .insert(Arrays.asList("id", "tag_name", "tag_type", "data_id", "group_id", "tenant_id"))), + eq(insertConfigIndoId), eq("tag2"), eq(StringUtils.EMPTY), eq(dataId), eq(group), eq(tenant)); //expect insert history info Mockito.verify(historyConfigInfoPersistService, times(1)) .insertConfigHistoryAtomic(eq(0L), eq(configInfo), eq(srcIp), eq(srcUser), any(Timestamp.class), - eq("I"), eq("formal"), eq(ConfigExtInfoUtil.getExtraInfoFromAdvanceInfoMap(configAdvanceInfo, srcUser))); + eq("I"), eq("formal"), + eq(ConfigExtInfoUtil.getExtraInfoFromAdvanceInfoMap(configAdvanceInfo, srcUser))); } @@ -291,8 +302,9 @@ void testInsertOrUpdateOfUpdateConfigSuccess() { configInfo.setEncryptedDataKey(encryptedDataKey); //mock get config state,first and second is not null Mockito.when(jdbcTemplate.queryForObject(anyString(), eq(new Object[] {dataId, group, tenant}), - eq(CONFIG_INFO_STATE_WRAPPER_ROW_MAPPER))).thenReturn(new ConfigInfoStateWrapper(), new ConfigInfoStateWrapper()); - + eq(CONFIG_INFO_STATE_WRAPPER_ROW_MAPPER))) + .thenReturn(new ConfigInfoStateWrapper(), new ConfigInfoStateWrapper()); + ConfigAllInfo configAllInfo = new ConfigAllInfo(); configAllInfo.setDataId(dataId); configAllInfo.setGroup(group); @@ -307,25 +319,30 @@ void testInsertOrUpdateOfUpdateConfigSuccess() { String srcIp = "srcIp"; String srcUser = "srcUser"; //mock update config info - Mockito.when(jdbcTemplate.update(eq(externalConfigInfoPersistService.mapperManager.findMapper(dataSourceService.getDataSourceType(), + Mockito.when(jdbcTemplate.update( + eq(externalConfigInfoPersistService.mapperManager.findMapper(dataSourceService.getDataSourceType(), TableConstant.CONFIG_INFO) - .update(Arrays.asList("content", "md5", "src_ip", "src_user", "gmt_modified@NOW()", "app_name", "c_desc", "c_use", - "effect", "type", "c_schema", "encrypted_data_key"), Arrays.asList("data_id", "group_id", "tenant_id"))), - eq(configInfo.getContent()), eq(configInfo.getMd5()), eq(srcIp), eq(srcUser), eq(configAllInfo.getAppName()), - eq(configAdvanceInfo.get("desc")), eq(configAdvanceInfo.get("use")), eq(configAdvanceInfo.get("effect")), - eq(configAdvanceInfo.get("type")), eq(configAdvanceInfo.get("schema")), eq(encryptedDataKey), eq(configInfo.getDataId()), + .update(Arrays.asList("content", "md5", "src_ip", "src_user", "gmt_modified@NOW()", "app_name", + "c_desc", "c_use", "effect", "type", "c_schema", "encrypted_data_key"), + Arrays.asList("data_id", "group_id", "tenant_id"))), eq(configInfo.getContent()), + eq(configInfo.getMd5()), eq(srcIp), eq(srcUser), eq(configAllInfo.getAppName()), + eq(configAdvanceInfo.get("desc")), eq(configAdvanceInfo.get("use")), + eq(configAdvanceInfo.get("effect")), eq(configAdvanceInfo.get("type")), + eq(configAdvanceInfo.get("schema")), eq(encryptedDataKey), eq(configInfo.getDataId()), eq(configInfo.getGroup()), eq(tenant))).thenReturn(1); //mock insert config tags. - Mockito.when(jdbcTemplate.update(eq(externalConfigInfoPersistService.mapperManager.findMapper(dataSourceService.getDataSourceType(), + Mockito.when(jdbcTemplate.update( + eq(externalConfigInfoPersistService.mapperManager.findMapper(dataSourceService.getDataSourceType(), TableConstant.CONFIG_TAGS_RELATION) - .insert(Arrays.asList("id", "tag_name", "tag_type", "data_id", "group_id", "tenant_id"))), eq(12345678765L), anyString(), - eq(StringUtils.EMPTY), eq(dataId), eq(group), eq(tenant))).thenReturn(1); + .insert(Arrays.asList("id", "tag_name", "tag_type", "data_id", "group_id", "tenant_id"))), + eq(12345678765L), anyString(), eq(StringUtils.EMPTY), eq(dataId), eq(group), eq(tenant))).thenReturn(1); //mock insert his config info Mockito.doNothing().when(historyConfigInfoPersistService) .insertConfigHistoryAtomic(eq(configAllInfo.getId()), eq(configInfo), eq(srcIp), eq(srcUser), - any(Timestamp.class), eq("I"), eq("formal"), eq(ConfigExtInfoUtil.getExtInfoFromAllInfo(configAllInfo))); + any(Timestamp.class), eq("I"), eq("formal"), + eq(ConfigExtInfoUtil.getExtInfoFromAllInfo(configAllInfo))); externalConfigInfoPersistService.insertOrUpdate(srcIp, srcUser, configInfo, configAdvanceInfo); @@ -343,8 +360,9 @@ void testInsertOrUpdateOfUpdateConfigSuccess() { //expect insert history info Mockito.verify(historyConfigInfoPersistService, times(1)) - .insertConfigHistoryAtomic(eq(configAllInfo.getId()), any(ConfigInfo.class), eq(srcIp), - eq(srcUser), any(Timestamp.class), eq("U"), eq("formal"), eq(ConfigExtInfoUtil.getExtInfoFromAllInfo(configAllInfo))); + .insertConfigHistoryAtomic(eq(configAllInfo.getId()), any(ConfigInfo.class), eq(srcIp), eq(srcUser), + any(Timestamp.class), eq("U"), eq("formal"), + eq(ConfigExtInfoUtil.getExtInfoFromAllInfo(configAllInfo))); } @@ -369,7 +387,8 @@ void testInsertOrUpdateCasOfUpdateConfigSuccess() { //mock get config state,first and second is not null Mockito.when(jdbcTemplate.queryForObject(anyString(), eq(new Object[] {dataId, group, tenant}), - eq(CONFIG_INFO_STATE_WRAPPER_ROW_MAPPER))).thenReturn(new ConfigInfoStateWrapper(), new ConfigInfoStateWrapper()); + eq(CONFIG_INFO_STATE_WRAPPER_ROW_MAPPER))) + .thenReturn(new ConfigInfoStateWrapper(), new ConfigInfoStateWrapper()); ConfigAllInfo configAllInfo = new ConfigAllInfo(); configAllInfo.setDataId(dataId); @@ -381,34 +400,39 @@ void testInsertOrUpdateCasOfUpdateConfigSuccess() { //mock get all config info Mockito.when(jdbcTemplate.queryForObject(anyString(), eq(new Object[] {dataId, group, tenant}), eq(CONFIG_ALL_INFO_ROW_MAPPER))).thenReturn(configAllInfo); - + String srcIp = "srcIp"; String srcUser = "srcUser"; //mock update config info cas - Mockito.when(jdbcTemplate.update(anyString(), eq(content), eq(MD5Utils.md5Hex(content, Constants.PERSIST_ENCODE)), - eq(srcIp), eq(srcUser), eq(configAllInfo.getAppName()), eq(configAdvanceInfo.get("desc")), - eq(configAdvanceInfo.get("use")), eq(configAdvanceInfo.get("effect")), eq(configAdvanceInfo.get("type")), - eq(configAdvanceInfo.get("schema")), eq(encryptedDataKey), eq(dataId), eq(group), eq(tenant), eq(casMd5))).thenReturn(1); - + Mockito.when( + jdbcTemplate.update(anyString(), eq(content), eq(MD5Utils.md5Hex(content, Constants.PERSIST_ENCODE)), + eq(srcIp), eq(srcUser), eq(configAllInfo.getAppName()), eq(configAdvanceInfo.get("desc")), + eq(configAdvanceInfo.get("use")), eq(configAdvanceInfo.get("effect")), + eq(configAdvanceInfo.get("type")), eq(configAdvanceInfo.get("schema")), eq(encryptedDataKey), + eq(dataId), eq(group), eq(tenant), eq(casMd5))).thenReturn(1); + //mock insert config tags. - Mockito.when(jdbcTemplate.update(eq(externalConfigInfoPersistService.mapperManager.findMapper(dataSourceService.getDataSourceType(), - TableConstant.CONFIG_TAGS_RELATION) - .insert(Arrays.asList("id", "tag_name", "tag_type", "data_id", "group_id", "tenant_id"))), - eq(configAllInfo.getId()), anyString(), eq(StringUtils.EMPTY), eq(dataId), eq(group), - eq(tenant))).thenReturn(1); + Mockito.when(jdbcTemplate.update( + eq(externalConfigInfoPersistService.mapperManager.findMapper(dataSourceService.getDataSourceType(), + TableConstant.CONFIG_TAGS_RELATION) + .insert(Arrays.asList("id", "tag_name", "tag_type", "data_id", "group_id", "tenant_id"))), + eq(configAllInfo.getId()), anyString(), eq(StringUtils.EMPTY), eq(dataId), eq(group), eq(tenant))) + .thenReturn(1); //mock insert his config info Mockito.doNothing().when(historyConfigInfoPersistService) .insertConfigHistoryAtomic(eq(configAllInfo.getId()), eq(configInfo), eq(srcIp), eq(srcUser), - any(Timestamp.class), eq("I"), eq("formal"), eq(ConfigExtInfoUtil.getExtInfoFromAllInfo(configAllInfo))); + any(Timestamp.class), eq("I"), eq("formal"), + eq(ConfigExtInfoUtil.getExtInfoFromAllInfo(configAllInfo))); externalConfigInfoPersistService.insertOrUpdateCas(srcIp, srcUser, configInfo, configAdvanceInfo); //expect update config cas Mockito.verify(jdbcTemplate, times(1)) .update(anyString(), eq(content), eq(MD5Utils.md5Hex(content, Constants.PERSIST_ENCODE)), eq(srcIp), eq(srcUser), eq(configAllInfo.getAppName()), eq(configAdvanceInfo.get("desc")), - eq(configAdvanceInfo.get("use")), eq(configAdvanceInfo.get("effect")), eq(configAdvanceInfo.get("type")), - eq(configAdvanceInfo.get("schema")), eq(encryptedDataKey), eq(dataId), eq(group), eq(tenant), eq(casMd5)); + eq(configAdvanceInfo.get("use")), eq(configAdvanceInfo.get("effect")), + eq(configAdvanceInfo.get("type")), eq(configAdvanceInfo.get("schema")), eq(encryptedDataKey), + eq(dataId), eq(group), eq(tenant), eq(casMd5)); //expect update config tags Mockito.verify(jdbcTemplate, times(1)).update(eq( @@ -425,7 +449,8 @@ void testInsertOrUpdateCasOfUpdateConfigSuccess() { //expect insert history info Mockito.verify(historyConfigInfoPersistService, times(1)) .insertConfigHistoryAtomic(eq(configAllInfo.getId()), any(ConfigInfo.class), eq(srcIp), eq(srcUser), - any(Timestamp.class), eq("U"), eq("formal"), eq(ConfigExtInfoUtil.getExtInfoFromAllInfo(configAllInfo))); + any(Timestamp.class), eq("U"), eq("formal"), + eq(ConfigExtInfoUtil.getExtInfoFromAllInfo(configAllInfo))); } @@ -447,14 +472,14 @@ void testCreatePsForInsertConfigInfo() throws SQLException { Connection mockConnection = Mockito.mock(Connection.class); PreparedStatement preparedStatement = Mockito.mock(PreparedStatement.class); - ConfigInfoMapper configInfoMapper = externalConfigInfoPersistService.mapperManager.findMapper(dataSourceService.getDataSourceType(), - TableConstant.CONFIG_INFO); + ConfigInfoMapper configInfoMapper = externalConfigInfoPersistService.mapperManager.findMapper( + dataSourceService.getDataSourceType(), TableConstant.CONFIG_INFO); Mockito.when(mockConnection.prepareStatement(anyString(), any(String[].class))).thenReturn(preparedStatement); String srcIp = "srcIp"; String srcUser = "srcUser"; - externalConfigInfoPersistService.createPsForInsertConfigInfo(srcIp, srcUser, configInfo, configAdvanceInfo, mockConnection, - configInfoMapper); + externalConfigInfoPersistService.createPsForInsertConfigInfo(srcIp, srcUser, configInfo, configAdvanceInfo, + mockConnection, configInfoMapper); Mockito.verify(preparedStatement, times(14)).setString(anyInt(), anyString()); } @@ -486,8 +511,8 @@ void testRemoveConfigInfo() { Mockito.verify(jdbcTemplate, times(1)).update(anyString(), eq(configAllInfo.getId())); //expect insert delete history Mockito.verify(historyConfigInfoPersistService, times(1)) - .insertConfigHistoryAtomic(eq(configAllInfo.getId()), eq(configAllInfo), eq(srcIp), - eq(srcUser), any(), eq("D"), eq("formal"), eq(ConfigExtInfoUtil.getExtInfoFromAllInfo(configAllInfo))); + .insertConfigHistoryAtomic(eq(configAllInfo.getId()), eq(configAllInfo), eq(srcIp), eq(srcUser), any(), + eq("D"), eq("formal"), eq(ConfigExtInfoUtil.getExtInfoFromAllInfo(configAllInfo))); } @@ -524,11 +549,13 @@ void testRemoveConfigInfoByIds() { Mockito.verify(jdbcTemplate, times(1)).update(anyString(), eq(deleteIds.get(1))); //expect insert delete history Mockito.verify(historyConfigInfoPersistService, times(1)) - .insertConfigHistoryAtomic(eq(configAllInfos.get(0).getId()), eq(configAllInfos.get(0)), eq(srcIp), eq(srcUser), - any(), eq("D"), eq("formal"), eq(ConfigExtInfoUtil.getExtInfoFromAllInfo(configAllInfos.get(0)))); + .insertConfigHistoryAtomic(eq(configAllInfos.get(0).getId()), eq(configAllInfos.get(0)), eq(srcIp), + eq(srcUser), any(), eq("D"), eq("formal"), + eq(ConfigExtInfoUtil.getExtInfoFromAllInfo(configAllInfos.get(0)))); Mockito.verify(historyConfigInfoPersistService, times(1)) - .insertConfigHistoryAtomic(eq(configAllInfos.get(1).getId()), eq(configAllInfos.get(1)), - eq(srcIp), eq(srcUser), any(), eq("D"), eq("formal"), eq(ConfigExtInfoUtil.getExtInfoFromAllInfo(configAllInfos.get(0)))); + .insertConfigHistoryAtomic(eq(configAllInfos.get(1).getId()), eq(configAllInfos.get(1)), eq(srcIp), + eq(srcUser), any(), eq("D"), eq("formal"), + eq(ConfigExtInfoUtil.getExtInfoFromAllInfo(configAllInfos.get(0)))); } @@ -549,11 +576,11 @@ void testBatchInsertOrUpdateOverwrite() throws NacosException { ReflectionTestUtils.setField(externalConfigInfoPersistService, "tjt", transactionTemplateCurrent); //mock add config 1 success,config 2 fail and update success,config 3 success Mockito.when(transactionTemplateCurrent.execute(any())) - .thenReturn(new ConfigOperateResult(true), new ConfigOperateResult(false), new ConfigOperateResult(true), - new ConfigOperateResult(true)); + .thenReturn(new ConfigOperateResult(true), new ConfigOperateResult(false), + new ConfigOperateResult(true), new ConfigOperateResult(true)); - Map stringObjectMap = externalConfigInfoPersistService.batchInsertOrUpdate(configInfoList, srcUser, srcIp, - configAdvanceInfo, SameConfigPolicy.OVERWRITE); + Map stringObjectMap = externalConfigInfoPersistService.batchInsertOrUpdate(configInfoList, + srcUser, srcIp, configAdvanceInfo, SameConfigPolicy.OVERWRITE); assertEquals(3, stringObjectMap.get("succCount")); assertEquals(0, stringObjectMap.get("skipCount")); } @@ -575,13 +602,15 @@ void testBatchInsertOrUpdateSkip() throws NacosException { ReflectionTestUtils.setField(externalConfigInfoPersistService, "tjt", transactionTemplateCurrent); //mock add config 1 success,config 2 fail and skip,config 3 success Mockito.when(transactionTemplateCurrent.execute(any())) - .thenReturn(new ConfigOperateResult(true), new ConfigOperateResult(false), new ConfigOperateResult(true)); + .thenReturn(new ConfigOperateResult(true), new ConfigOperateResult(false), + new ConfigOperateResult(true)); - Map stringObjectMap = externalConfigInfoPersistService.batchInsertOrUpdate(configInfoList, srcUser, srcIp, - configAdvanceInfo, SameConfigPolicy.SKIP); + Map stringObjectMap = externalConfigInfoPersistService.batchInsertOrUpdate(configInfoList, + srcUser, srcIp, configAdvanceInfo, SameConfigPolicy.SKIP); assertEquals(2, stringObjectMap.get("succCount")); assertEquals(1, stringObjectMap.get("skipCount")); - assertEquals(configInfoList.get(1).getDataId(), ((List>) stringObjectMap.get("skipData")).get(0).get("dataId")); + assertEquals(configInfoList.get(1).getDataId(), + ((List>) stringObjectMap.get("skipData")).get(0).get("dataId")); } @Test @@ -600,16 +629,19 @@ void testBatchInsertOrUpdateAbort() throws NacosException { TransactionTemplate transactionTemplateCurrent = Mockito.mock(TransactionTemplate.class); ReflectionTestUtils.setField(externalConfigInfoPersistService, "tjt", transactionTemplateCurrent); //mock add config 1 success,config 2 fail and abort,config 3 not operated - Mockito.when(transactionTemplateCurrent.execute(any())).thenReturn(new ConfigOperateResult(true), new ConfigOperateResult(false)); + Mockito.when(transactionTemplateCurrent.execute(any())) + .thenReturn(new ConfigOperateResult(true), new ConfigOperateResult(false)); - Map stringObjectMap = externalConfigInfoPersistService.batchInsertOrUpdate(configInfoList, srcUser, srcIp, - configAdvanceInfo, SameConfigPolicy.ABORT); + Map stringObjectMap = externalConfigInfoPersistService.batchInsertOrUpdate(configInfoList, + srcUser, srcIp, configAdvanceInfo, SameConfigPolicy.ABORT); assertEquals(1, stringObjectMap.get("succCount")); assertEquals(1, stringObjectMap.get("skipCount")); // config 2 failed - assertEquals(configInfoList.get(1).getDataId(), ((List>) stringObjectMap.get("failData")).get(0).get("dataId")); + assertEquals(configInfoList.get(1).getDataId(), + ((List>) stringObjectMap.get("failData")).get(0).get("dataId")); //skip config 3 - assertEquals(configInfoList.get(2).getDataId(), ((List>) stringObjectMap.get("skipData")).get(0).get("dataId")); + assertEquals(configInfoList.get(2).getDataId(), + ((List>) stringObjectMap.get("skipData")).get(0).get("dataId")); } private ConfigAllInfo createMockConfigAllInfo(long mockId) { @@ -668,7 +700,8 @@ void testFindConfigInfoById() { long id = 1234567890876L; ConfigInfo configInfo = new ConfigInfo(); configInfo.setId(id); - Mockito.when(jdbcTemplate.queryForObject(anyString(), eq(new Object[] {id}), eq(CONFIG_INFO_ROW_MAPPER))).thenReturn(configInfo); + Mockito.when(jdbcTemplate.queryForObject(anyString(), eq(new Object[] {id}), eq(CONFIG_INFO_ROW_MAPPER))) + .thenReturn(configInfo); ConfigInfo configReturn = externalConfigInfoPersistService.findConfigInfo(id); assertEquals(id, configReturn.getId()); } @@ -709,8 +742,8 @@ void testFindConfigInfoByDataId() { configInfoWrapper.setGroup(group); configInfoWrapper.setTenant(tenant); - Mockito.when(jdbcTemplate.queryForObject(anyString(), eq(new Object[] {dataId, group, tenant}), eq(CONFIG_INFO_WRAPPER_ROW_MAPPER))) - .thenReturn(configInfoWrapper); + Mockito.when(jdbcTemplate.queryForObject(anyString(), eq(new Object[] {dataId, group, tenant}), + eq(CONFIG_INFO_WRAPPER_ROW_MAPPER))).thenReturn(configInfoWrapper); ConfigInfo configReturn = externalConfigInfoPersistService.findConfigInfo(dataId, group, tenant); assertEquals(dataId, configReturn.getDataId()); } @@ -720,8 +753,8 @@ void testFindConfigInfoByDataIdNull() { String dataId = "dataId4567"; String group = "group3456789"; String tenant = "tenant4567890"; - Mockito.when(jdbcTemplate.queryForObject(anyString(), eq(new Object[] {dataId, group, tenant}), eq(CONFIG_INFO_WRAPPER_ROW_MAPPER))) - .thenThrow(new EmptyResultDataAccessException(1)); + Mockito.when(jdbcTemplate.queryForObject(anyString(), eq(new Object[] {dataId, group, tenant}), + eq(CONFIG_INFO_WRAPPER_ROW_MAPPER))).thenThrow(new EmptyResultDataAccessException(1)); ConfigInfoWrapper configReturn = externalConfigInfoPersistService.findConfigInfo(dataId, group, tenant); assertNull(configReturn); } @@ -732,8 +765,8 @@ void testFindConfigInfoByDataIdGetConFail() { String group = "group3456789"; String tenant = "tenant4567890"; - Mockito.when(jdbcTemplate.queryForObject(anyString(), eq(new Object[] {dataId, group, tenant}), eq(CONFIG_INFO_WRAPPER_ROW_MAPPER))) - .thenThrow(new CannotGetJdbcConnectionException("mocked exp")); + Mockito.when(jdbcTemplate.queryForObject(anyString(), eq(new Object[] {dataId, group, tenant}), + eq(CONFIG_INFO_WRAPPER_ROW_MAPPER))).thenThrow(new CannotGetJdbcConnectionException("mocked exp")); try { externalConfigInfoPersistService.findConfigInfo(dataId, group, tenant); assertTrue(false); @@ -749,17 +782,18 @@ void testFindConfigInfo4Page() { String tenant = "tenant4567890"; //mock total count - when(jdbcTemplate.queryForObject(anyString(), eq(new Object[] {tenant, dataId, group}), eq(Integer.class))).thenReturn( - new Integer(9)); + when(jdbcTemplate.queryForObject(anyString(), eq(new Object[] {tenant, dataId, group}), + eq(Integer.class))).thenReturn(new Integer(9)); //mock page list List result = new ArrayList<>(); result.add(createMockConfigInfo(0)); result.add(createMockConfigInfo(1)); result.add(createMockConfigInfo(2)); - when(jdbcTemplate.query(anyString(), eq(new Object[] {tenant, dataId, group}), eq(CONFIG_INFO_ROW_MAPPER))).thenReturn(result); + when(jdbcTemplate.query(anyString(), eq(new Object[] {tenant, dataId, group}), + eq(CONFIG_INFO_ROW_MAPPER))).thenReturn(result); Map configAdvanceInfo = new HashMap<>(); - Page configInfo4Page = externalConfigInfoPersistService.findConfigInfo4Page(1, 3, dataId, group, tenant, - configAdvanceInfo); + Page configInfo4Page = externalConfigInfoPersistService.findConfigInfo4Page(1, 3, dataId, group, + tenant, configAdvanceInfo); assertEquals(result.size(), configInfo4Page.getPageItems().size()); assertEquals(9, configInfo4Page.getTotalCount()); @@ -784,8 +818,8 @@ void testFindConfigInfo4PageWithTags() { when(jdbcTemplate.query(anyString(), eq(new Object[] {tenant, dataId, group, "tags1", "tags3"}), eq(CONFIG_INFO_ROW_MAPPER))).thenReturn(result); - Page configInfo4Page = externalConfigInfoPersistService.findConfigInfo4Page(1, 3, dataId, group, tenant, - configAdvanceInfo); + Page configInfo4Page = externalConfigInfoPersistService.findConfigInfo4Page(1, 3, dataId, group, + tenant, configAdvanceInfo); assertEquals(result.size(), configInfo4Page.getPageItems().size()); assertEquals(9, configInfo4Page.getTotalCount()); } @@ -813,7 +847,8 @@ void testConfigInfoCountByTenant() { String tenant = "tenant124"; //mock total count - when(jdbcTemplate.queryForObject(anyString(), eq(new Object[] {tenant}), eq(Integer.class))).thenReturn(new Integer(90)); + when(jdbcTemplate.queryForObject(anyString(), eq(new Object[] {tenant}), eq(Integer.class))).thenReturn( + new Integer(90)); int count = externalConfigInfoPersistService.configInfoCount(tenant); assertEquals(90, count); @@ -839,19 +874,19 @@ void testFindConfigInfoLike4Page() { configAdvanceInfo.put("content", content); //mock total count when(jdbcTemplate.queryForObject(anyString(), - eq(new Object[] {tenant, dataId.replaceAll("\\*", "%"), group.replaceAll("\\*", "%"), appName, content}), - eq(Integer.class))).thenReturn(new Integer(9)); + eq(new Object[] {tenant, dataId.replaceAll("\\*", "%"), group.replaceAll("\\*", "%"), appName, + content}), eq(Integer.class))).thenReturn(new Integer(9)); //mock page list List result = new ArrayList<>(); result.add(createMockConfigInfo(0)); result.add(createMockConfigInfo(1)); result.add(createMockConfigInfo(2)); when(jdbcTemplate.query(anyString(), - eq(new Object[] {tenant, dataId.replaceAll("\\*", "%"), group.replaceAll("\\*", "%"), appName, content}), - eq(CONFIG_INFO_ROW_MAPPER))).thenReturn(result); + eq(new Object[] {tenant, dataId.replaceAll("\\*", "%"), group.replaceAll("\\*", "%"), appName, + content}), eq(CONFIG_INFO_ROW_MAPPER))).thenReturn(result); - Page configInfo4Page = externalConfigInfoPersistService.findConfigInfoLike4Page(1, 3, dataId, group, tenant, - configAdvanceInfo); + Page configInfo4Page = externalConfigInfoPersistService.findConfigInfoLike4Page(1, 3, dataId, group, + tenant, configAdvanceInfo); assertEquals(result.size(), configInfo4Page.getPageItems().size()); assertEquals(9, configInfo4Page.getTotalCount()); @@ -871,19 +906,19 @@ void testFindConfigInfoLike4PageWithTags() { String tenant = "tenant4567890"; //mock total count when(jdbcTemplate.queryForObject(anyString(), - eq(new Object[] {tenant, dataId.replaceAll("\\*", "%"), group.replaceAll("\\*", "%"), appName, content, "tags", "tag2"}), - eq(Integer.class))).thenReturn(new Integer(9)); + eq(new Object[] {tenant, dataId.replaceAll("\\*", "%"), group.replaceAll("\\*", "%"), appName, content, + "tags", "tag2"}), eq(Integer.class))).thenReturn(new Integer(9)); //mock page list List result = new ArrayList<>(); result.add(createMockConfigInfo(0)); result.add(createMockConfigInfo(1)); result.add(createMockConfigInfo(2)); when(jdbcTemplate.query(anyString(), - eq(new Object[] {tenant, dataId.replaceAll("\\*", "%"), group.replaceAll("\\*", "%"), appName, content, "tags", "tag2"}), - eq(CONFIG_INFO_ROW_MAPPER))).thenReturn(result); + eq(new Object[] {tenant, dataId.replaceAll("\\*", "%"), group.replaceAll("\\*", "%"), appName, content, + "tags", "tag2"}), eq(CONFIG_INFO_ROW_MAPPER))).thenReturn(result); - Page configInfo4Page = externalConfigInfoPersistService.findConfigInfoLike4Page(1, 3, dataId, group, tenant, - configAdvanceInfo); + Page configInfo4Page = externalConfigInfoPersistService.findConfigInfoLike4Page(1, 3, dataId, group, + tenant, configAdvanceInfo); assertEquals(result.size(), configInfo4Page.getPageItems().size()); assertEquals(9, configInfo4Page.getTotalCount()); @@ -903,7 +938,8 @@ void testFindChangeConfig() { when(jdbcTemplate.query(anyString(), eq(new Object[] {startTime, lastMaxId, pageSize}), eq(CONFIG_INFO_STATE_WRAPPER_ROW_MAPPER))).thenReturn(result); - List configInfo4List = externalConfigInfoPersistService.findChangeConfig(startTime, lastMaxId, pageSize); + List configInfo4List = externalConfigInfoPersistService.findChangeConfig(startTime, + lastMaxId, pageSize); assertEquals(result.size(), configInfo4List.size()); } @@ -916,8 +952,8 @@ void testFindChangeConfigError() { when(jdbcTemplate.query(anyString(), eq(new Object[] {startTime, lastMaxId, pageSize}), eq(CONFIG_INFO_STATE_WRAPPER_ROW_MAPPER))).thenThrow(new CannotAcquireLockException("mock ex")); try { - List configInfo4List = externalConfigInfoPersistService.findChangeConfig(startTime, lastMaxId, - pageSize); + List configInfo4List = externalConfigInfoPersistService.findChangeConfig(startTime, + lastMaxId, pageSize); assertTrue(false); } catch (Exception e) { assertTrue(e instanceof CannotAcquireLockException); @@ -932,24 +968,25 @@ void testSelectTagByConfig() { //mock page list List tagStrings = Arrays.asList("", "", ""); - when(jdbcTemplate.queryForList(anyString(), eq(new Object[] {dataId, group, tenant}), eq(String.class))).thenReturn(tagStrings); + when(jdbcTemplate.queryForList(anyString(), eq(new Object[] {dataId, group, tenant}), + eq(String.class))).thenReturn(tagStrings); List configTags = externalConfigInfoPersistService.selectTagByConfig(dataId, group, tenant); assertEquals(tagStrings, configTags); //mock EmptyResultDataAccessException - when(jdbcTemplate.queryForList(anyString(), eq(new Object[] {dataId, group, tenant}), eq(String.class))).thenThrow( - new EmptyResultDataAccessException(3)); + when(jdbcTemplate.queryForList(anyString(), eq(new Object[] {dataId, group, tenant}), + eq(String.class))).thenThrow(new EmptyResultDataAccessException(3)); List nullResult = externalConfigInfoPersistService.selectTagByConfig(dataId, group, tenant); assertTrue(nullResult == null); //mock IncorrectResultSizeDataAccessException - when(jdbcTemplate.queryForList(anyString(), eq(new Object[] {dataId, group, tenant}), eq(String.class))).thenThrow( - new IncorrectResultSizeDataAccessException(3)); + when(jdbcTemplate.queryForList(anyString(), eq(new Object[] {dataId, group, tenant}), + eq(String.class))).thenThrow(new IncorrectResultSizeDataAccessException(3)); List nullResult2 = externalConfigInfoPersistService.selectTagByConfig(dataId, group, tenant); assertTrue(nullResult2 == null); //mock IncorrectResultSizeDataAccessException - when(jdbcTemplate.queryForList(anyString(), eq(new Object[] {dataId, group, tenant}), eq(String.class))).thenThrow( - new CannotGetJdbcConnectionException("mock exp")); + when(jdbcTemplate.queryForList(anyString(), eq(new Object[] {dataId, group, tenant}), + eq(String.class))).thenThrow(new CannotGetJdbcConnectionException("mock exp")); try { externalConfigInfoPersistService.selectTagByConfig(dataId, group, tenant); assertFalse(true); @@ -966,7 +1003,8 @@ void testFindConfigInfosByIds() { result.add(createMockConfigInfo(0)); result.add(createMockConfigInfo(1)); result.add(createMockConfigInfo(2)); - when(jdbcTemplate.query(anyString(), eq(new Object[] {123L, 1232345L}), eq(CONFIG_INFO_ROW_MAPPER))).thenReturn(result); + when(jdbcTemplate.query(anyString(), eq(new Object[] {123L, 1232345L}), eq(CONFIG_INFO_ROW_MAPPER))).thenReturn( + result); String ids = "123,1232345"; List configInfosByIds = externalConfigInfoPersistService.findConfigInfosByIds(ids); assertEquals(result.size(), configInfosByIds.size()); @@ -1001,7 +1039,8 @@ void testFindConfigAdvanceInfo() { String tenant = "tenant13245"; //mock select tags List mockTags = Arrays.asList("tag1", "tag2", "tag3"); - when(jdbcTemplate.queryForList(anyString(), eq(new Object[] {dataId, group, tenant}), eq(String.class))).thenReturn(mockTags); + when(jdbcTemplate.queryForList(anyString(), eq(new Object[] {dataId, group, tenant}), + eq(String.class))).thenReturn(mockTags); String schema = "schema12345654"; //mock select config advance @@ -1011,7 +1050,8 @@ void testFindConfigAdvanceInfo() { eq(CONFIG_ADVANCE_INFO_ROW_MAPPER))).thenReturn(mockedAdvance); //execute return mock obj - ConfigAdvanceInfo configAdvanceInfo = externalConfigInfoPersistService.findConfigAdvanceInfo(dataId, group, tenant); + ConfigAdvanceInfo configAdvanceInfo = externalConfigInfoPersistService.findConfigAdvanceInfo(dataId, group, + tenant); //expect check schema & tags. assertEquals(mockedAdvance.getSchema(), configAdvanceInfo.getSchema()); assertEquals(String.join(",", mockTags), configAdvanceInfo.getConfigTags()); @@ -1043,14 +1083,15 @@ void testFindConfigAllInfo() { String tenant = "tenant13245"; //mock select tags List mockTags = Arrays.asList("tag1", "tag2", "tag3"); - when(jdbcTemplate.queryForList(anyString(), eq(new Object[] {dataId, group, tenant}), eq(String.class))).thenReturn(mockTags); + when(jdbcTemplate.queryForList(anyString(), eq(new Object[] {dataId, group, tenant}), + eq(String.class))).thenReturn(mockTags); String schema = "schema12345654"; //mock select config advance ConfigAllInfo mockedConfig = new ConfigAllInfo(); mockedConfig.setSchema(schema); - when(jdbcTemplate.queryForObject(anyString(), eq(new Object[] {dataId, group, tenant}), eq(CONFIG_ALL_INFO_ROW_MAPPER))).thenReturn( - mockedConfig); + when(jdbcTemplate.queryForObject(anyString(), eq(new Object[] {dataId, group, tenant}), + eq(CONFIG_ALL_INFO_ROW_MAPPER))).thenReturn(mockedConfig); //execute return mock obj ConfigAllInfo configAllInfo = externalConfigInfoPersistService.findConfigAllInfo(dataId, group, tenant); @@ -1059,14 +1100,14 @@ void testFindConfigAllInfo() { assertEquals(String.join(",", mockTags), configAllInfo.getConfigTags()); //mock EmptyResultDataAccessException - when(jdbcTemplate.queryForObject(anyString(), eq(new Object[] {dataId, group, tenant}), eq(CONFIG_ALL_INFO_ROW_MAPPER))).thenThrow( - new EmptyResultDataAccessException(1)); + when(jdbcTemplate.queryForObject(anyString(), eq(new Object[] {dataId, group, tenant}), + eq(CONFIG_ALL_INFO_ROW_MAPPER))).thenThrow(new EmptyResultDataAccessException(1)); //expect return null. assertNull(externalConfigInfoPersistService.findConfigAllInfo(dataId, group, tenant)); //mock CannotGetJdbcConnectionException - when(jdbcTemplate.queryForObject(anyString(), eq(new Object[] {dataId, group, tenant}), eq(CONFIG_ALL_INFO_ROW_MAPPER))).thenThrow( - new CannotGetJdbcConnectionException("mock exp")); + when(jdbcTemplate.queryForObject(anyString(), eq(new Object[] {dataId, group, tenant}), + eq(CONFIG_ALL_INFO_ROW_MAPPER))).thenThrow(new CannotGetJdbcConnectionException("mock exp")); //expect throw exception. try { externalConfigInfoPersistService.findConfigAllInfo(dataId, group, tenant); @@ -1092,7 +1133,8 @@ void testFindConfigInfoState() { eq(CONFIG_INFO_STATE_WRAPPER_ROW_MAPPER))).thenReturn(mockedConfig); //execute return mock obj - ConfigInfoStateWrapper configInfoStateWrapper = externalConfigInfoPersistService.findConfigInfoState(dataId, group, tenant); + ConfigInfoStateWrapper configInfoStateWrapper = externalConfigInfoPersistService.findConfigInfoState(dataId, + group, tenant); //expect check schema & tags. assertEquals(mockedConfig.getId(), configInfoStateWrapper.getId()); assertEquals(mockedConfig.getLastModified(), configInfoStateWrapper.getLastModified()); @@ -1115,7 +1157,7 @@ void testFindConfigInfoState() { assertTrue(e.getMessage().endsWith("mock exp")); } } - + @Test void testFindAllConfigInfo4Export() { @@ -1131,24 +1173,25 @@ void testFindAllConfigInfo4Export() { String appName = "appName1243"; List ids = Arrays.asList(132L, 1343L, 245L); - when(jdbcTemplate.query(anyString(), eq(new Object[] {132L, 1343L, 245L}), eq(CONFIG_ALL_INFO_ROW_MAPPER))).thenReturn(mockConfigs); + when(jdbcTemplate.query(anyString(), eq(new Object[] {132L, 1343L, 245L}), + eq(CONFIG_ALL_INFO_ROW_MAPPER))).thenReturn(mockConfigs); //execute return mock obj - List configAllInfosIds = externalConfigInfoPersistService.findAllConfigInfo4Export(dataId, group, tenant, appName, - ids); + List configAllInfosIds = externalConfigInfoPersistService.findAllConfigInfo4Export(dataId, group, + tenant, appName, ids); //expect check assertEquals(mockConfigs, configAllInfosIds); - when(jdbcTemplate.query(anyString(), eq(new Object[] {tenant, dataId, group, appName}), eq(CONFIG_ALL_INFO_ROW_MAPPER))).thenReturn( - mockConfigs); + when(jdbcTemplate.query(anyString(), eq(new Object[] {tenant, dataId, group, appName}), + eq(CONFIG_ALL_INFO_ROW_MAPPER))).thenReturn(mockConfigs); //execute return mock obj - List configAllInfosWithDataId = externalConfigInfoPersistService.findAllConfigInfo4Export(dataId, group, tenant, - appName, null); + List configAllInfosWithDataId = externalConfigInfoPersistService.findAllConfigInfo4Export(dataId, + group, tenant, appName, null); //expect check assertEquals(mockConfigs, configAllInfosWithDataId); //mock CannotGetJdbcConnectionException - when(jdbcTemplate.query(anyString(), eq(new Object[] {132L, 1343L, 245L}), eq(CONFIG_ALL_INFO_ROW_MAPPER))).thenThrow( - new CannotGetJdbcConnectionException("mock exp11")); + when(jdbcTemplate.query(anyString(), eq(new Object[] {132L, 1343L, 245L}), + eq(CONFIG_ALL_INFO_ROW_MAPPER))).thenThrow(new CannotGetJdbcConnectionException("mock exp11")); //expect throw exception. try { externalConfigInfoPersistService.findAllConfigInfo4Export(dataId, group, tenant, appName, ids); @@ -1168,9 +1211,11 @@ void testQueryConfigInfoByNamespace() { mockConfigs.add(createMockConfigInfoWrapper(1)); mockConfigs.add(createMockConfigInfoWrapper(2)); String tenant = "tenant13245"; - when(jdbcTemplate.query(anyString(), eq(new Object[] {tenant}), eq(CONFIG_INFO_WRAPPER_ROW_MAPPER))).thenReturn(mockConfigs); + when(jdbcTemplate.query(anyString(), eq(new Object[] {tenant}), eq(CONFIG_INFO_WRAPPER_ROW_MAPPER))).thenReturn( + mockConfigs); //execute return mock obj - List configInfoWrappers = externalConfigInfoPersistService.queryConfigInfoByNamespace(tenant); + List configInfoWrappers = externalConfigInfoPersistService.queryConfigInfoByNamespace( + tenant); //expect check assertEquals(mockConfigs, configInfoWrappers); @@ -1178,7 +1223,8 @@ void testQueryConfigInfoByNamespace() { when(jdbcTemplate.query(anyString(), eq(new Object[] {tenant}), eq(CONFIG_INFO_WRAPPER_ROW_MAPPER))).thenThrow( new EmptyResultDataAccessException(2)); //execute return mock obj - List configInfoWrapperNull = externalConfigInfoPersistService.queryConfigInfoByNamespace(tenant); + List configInfoWrapperNull = externalConfigInfoPersistService.queryConfigInfoByNamespace( + tenant); //expect check assertEquals(Collections.EMPTY_LIST, configInfoWrapperNull); @@ -1233,10 +1279,12 @@ void testFindAllConfigInfoFragment() { mockConfigs.add(createMockConfigInfoWrapper(1)); mockConfigs.add(createMockConfigInfoWrapper(2)); long lastId = 10111L; - when(jdbcTemplate.query(anyString(), eq(new Object[] {lastId}), eq(CONFIG_INFO_WRAPPER_ROW_MAPPER))).thenReturn(mockConfigs); + when(jdbcTemplate.query(anyString(), eq(new Object[] {lastId}), eq(CONFIG_INFO_WRAPPER_ROW_MAPPER))).thenReturn( + mockConfigs); int pageSize = 100; //execute return mock obj - Page returnConfigPage = externalConfigInfoPersistService.findAllConfigInfoFragment(lastId, pageSize, true); + Page returnConfigPage = externalConfigInfoPersistService.findAllConfigInfoFragment(lastId, + pageSize, true); //expect check assertEquals(mockConfigs, returnConfigPage.getPageItems()); @@ -1251,16 +1299,17 @@ void testFindAllConfigInfoFragment() { } } - + @Test - void testBuildFindConfigInfoStateSql() { + void testBuildFindConfigInfoStateSql() { MapperManager mapperManager = MapperManager.instance(false); ConfigInfoMapper configInfoMapper = mapperManager.findMapper(dataSourceService.getDataSourceType(), TableConstant.CONFIG_INFO); - String select = configInfoMapper.select( - Arrays.asList("id", "data_id", "group_id", "tenant_id", "gmt_modified"), + String select = configInfoMapper.select(Arrays.asList("id", "data_id", "group_id", "tenant_id", "gmt_modified"), Arrays.asList("data_id", "group_id", "tenant_id")); - assertEquals("SELECT id,data_id,group_id,tenant_id,gmt_modified FROM config_info WHERE data_id = ? AND group_id = ? AND tenant_id = ?", select); + assertEquals( + "SELECT id,data_id,group_id,tenant_id,gmt_modified FROM config_info WHERE data_id = ? AND group_id = ? AND tenant_id = ?", + select); } } diff --git a/console-ui/src/config.js b/console-ui/src/config.js index 705d54cd788..6c7959760cb 100644 --- a/console-ui/src/config.js +++ b/console-ui/src/config.js @@ -27,12 +27,12 @@ module.exports = { { key: 'home', // 用作顶部菜单的选中 text: 'HOME', - link: 'https://nacos.io/en-us/index.html', + link: 'https://https://nacos.io/en/', }, { key: 'docs', text: 'DOCS', - link: 'https://nacos.io/en/docs/latest/what-is-nacos/', + link: 'https://nacos.io/en/docs/latest/overview/', }, { key: 'blog', @@ -42,7 +42,7 @@ module.exports = { { key: 'community', text: 'COMMUNITY', - link: 'https://nacos.io/en/news/', + link: 'https://nacos.io/en/blog/community/', }, { key: 'enterprise', @@ -92,12 +92,12 @@ module.exports = { { key: 'home', text: '首页', - link: 'https://nacos.io/zh-cn/', + link: 'https://nacos.io/', }, { key: 'docs', text: '文档', - link: 'https://nacos.io/docs/latest/what-is-nacos/', + link: 'https://nacos.io/docs/latest/overview/', }, { key: 'blog', @@ -107,7 +107,7 @@ module.exports = { { key: 'community', text: '社区', - link: 'https://nacos.io/news/', + link: 'https://nacos.io/blog/community/', }, { key: 'enterprise', diff --git a/distribution/conf/announcement_en-US.conf b/distribution/conf/announcement_en-US.conf index 19e8dbcd589..2ad141b91f5 100644 --- a/distribution/conf/announcement_en-US.conf +++ b/distribution/conf/announcement_en-US.conf @@ -1 +1 @@ -Authentication has not been enabled in cluster, please refer to Documentation to enable~ \ No newline at end of file +Authentication has not been enabled in cluster, please refer to Documentation to enable~ \ No newline at end of file diff --git a/distribution/conf/announcement_zh-CN.conf b/distribution/conf/announcement_zh-CN.conf index c18d8a41fc1..3047c864765 100644 --- a/distribution/conf/announcement_zh-CN.conf +++ b/distribution/conf/announcement_zh-CN.conf @@ -1 +1 @@ -当前集群没有开启鉴权,请参考文档开启鉴权~ \ No newline at end of file +当前集群没有开启鉴权,请参考文档开启鉴权~ \ No newline at end of file diff --git a/distribution/conf/console-guide.conf b/distribution/conf/console-guide.conf index e63b8cf46a1..9fb7f7e8fd0 100644 --- a/distribution/conf/console-guide.conf +++ b/distribution/conf/console-guide.conf @@ -1 +1 @@ -当前节点已关闭Nacos开源控制台使用,请修改application.properties中的nacos.console.ui.enabled参数为true打开开源控制台使用,详情查看文档中关于关闭默认控制台部分。 \ No newline at end of file +当前节点已关闭Nacos开源控制台使用,请修改application.properties中的nacos.console.ui.enabled参数为true打开开源控制台使用,详情查看文档中关于关闭默认控制台部分。 \ No newline at end of file diff --git a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/token/impl/JwtTokenManager.java b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/token/impl/JwtTokenManager.java index 7dc2cc57469..c52bbba402c 100644 --- a/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/token/impl/JwtTokenManager.java +++ b/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/token/impl/JwtTokenManager.java @@ -79,7 +79,7 @@ private void processProperties() { if (authConfigs.isAuthEnabled()) { throw new IllegalArgumentException( "the length of secret key must great than or equal 32 bytes; And the secret key must be encoded by base64." - + "Please see https://nacos.io/zh-cn/docs/v2/guide/user/auth.html", e); + + "Please see https://nacos.io/docs/latest/manual/admin/auth/", e); } } @@ -175,7 +175,7 @@ public Class subscribeType() { private void checkJwtParser() { if (null == jwtParser) { throw new NacosRuntimeException(NacosException.INVALID_PARAM, - "Please config `nacos.core.auth.plugin.nacos.token.secret.key`, detail see https://nacos.io/zh-cn/docs/v2/guide/user/auth.html"); + "Please config `nacos.core.auth.plugin.nacos.token.secret.key`, detail see https://nacos.io/docs/latest/manual/admin/auth/"); } } }