diff --git a/rc-auth/src/main/java/com/red/circle/auth/common/LoginAccessValidationService.java b/rc-auth/src/main/java/com/red/circle/auth/common/LoginAccessValidationService.java index 9cb58826..747ec451 100644 --- a/rc-auth/src/main/java/com/red/circle/auth/common/LoginAccessValidationService.java +++ b/rc-auth/src/main/java/com/red/circle/auth/common/LoginAccessValidationService.java @@ -39,10 +39,10 @@ public class LoginAccessValidationService { "香港", "澳门", "澳門", "台湾", "台灣", "Hong Kong", "Macau", "Macao", "Taiwan" ); private static final List BLOCKED_COUNTRY_CODES = List.of( - "MO", "SG", "TW" + "MO", "SG" ); private static final List BLOCKED_COUNTRY_NAMES = List.of( - "澳门", "澳門", "台湾", "台灣", "Macau", "Macao", "Taiwan", "新加坡", "Singapore" + "澳门", "澳門", "Macau", "Macao", "新加坡", "Singapore" ); private static final List IP_GEO_PROVIDERS = List.of( new IpGeoProvider("ip.sb", "https://api.ip.sb/geoip/%s"), diff --git a/rc-auth/src/test/java/com/red/circle/auth/common/LoginAccessValidationServiceTest.java b/rc-auth/src/test/java/com/red/circle/auth/common/LoginAccessValidationServiceTest.java index 6c9dd628..36991a35 100644 --- a/rc-auth/src/test/java/com/red/circle/auth/common/LoginAccessValidationServiceTest.java +++ b/rc-auth/src/test/java/com/red/circle/auth/common/LoginAccessValidationServiceTest.java @@ -107,21 +107,21 @@ public class LoginAccessValidationServiceTest { } @Test - public void blockTaiwanRegion() { + public void allowTaiwanRegion() { JSONObject data = JSON.parseObject(""" {"country_id":"CN","country":"中国","region":"台湾"} """); assertFalse(LoginAccessValidationService.isMainlandChina(data)); - assertTrue(LoginAccessValidationService.isBlockedIpRegion(data)); + assertFalse(LoginAccessValidationService.isBlockedIpRegion(data)); } @Test - public void blockTaiwanCountryCode() { + public void allowTaiwanCountryCode() { JSONObject data = JSON.parseObject(""" {"country_id":"TW","country":"Taiwan","region":""} """); - assertTrue(LoginAccessValidationService.isBlockedIpRegion(data)); + assertFalse(LoginAccessValidationService.isBlockedIpRegion(data)); } } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/utils/IpCountryUtils.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/utils/IpCountryUtils.java index 184f9fd9..9374c750 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/utils/IpCountryUtils.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/utils/IpCountryUtils.java @@ -32,10 +32,10 @@ public class IpCountryUtils { "香港", "澳门", "澳門", "台湾", "台灣", "Hong Kong", "Macau", "Macao", "Taiwan" ); private static final List BLOCKED_COUNTRY_CODES = List.of( - "MO", "SG", "TW" + "MO", "SG" ); private static final List BLOCKED_COUNTRY_NAMES = List.of( - "澳门", "澳門", "台湾", "台灣", "Macau", "Macao", "Taiwan", "新加坡", "Singapore" + "澳门", "澳門", "Macau", "Macao", "新加坡", "Singapore" ); private static final List IP_GEO_PROVIDERS = List.of( new IpGeoProvider("ip.sb", "https://api.ip.sb/geoip/%s"), diff --git a/rc-service/rc-service-other/other-infrastructure/src/test/java/com/red/circle/other/infra/utils/IpCountryUtilsTest.java b/rc-service/rc-service-other/other-infrastructure/src/test/java/com/red/circle/other/infra/utils/IpCountryUtilsTest.java index 3557b31c..3af523ee 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/test/java/com/red/circle/other/infra/utils/IpCountryUtilsTest.java +++ b/rc-service/rc-service-other/other-infrastructure/src/test/java/com/red/circle/other/infra/utils/IpCountryUtilsTest.java @@ -99,17 +99,17 @@ public class IpCountryUtilsTest { } @Test - public void blockTaiwanRegion() { + public void allowTaiwanRegion() { IpCountryUtils.IpGeoData data = new IpCountryUtils.IpGeoData("CN", "中国", "台湾", "test"); assertFalse(IpCountryUtils.isMainlandChina(data)); - assertTrue(IpCountryUtils.isBlockedIpRegion(data)); + assertFalse(IpCountryUtils.isBlockedIpRegion(data)); } @Test - public void blockTaiwanCountryCode() { + public void allowTaiwanCountryCode() { IpCountryUtils.IpGeoData data = new IpCountryUtils.IpGeoData("TW", "Taiwan", "", "test"); - assertTrue(IpCountryUtils.isBlockedIpRegion(data)); + assertFalse(IpCountryUtils.isBlockedIpRegion(data)); } }