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 6d3ec76b..77f1d624 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,11 @@ public class LoginAccessValidationService { "香港", "澳门", "澳門", "台湾", "台灣", "Hong Kong", "Macau", "Macao", "Taiwan" ); private static final List BLOCKED_COUNTRY_CODES = List.of( - "MO" + "HK", "MO", "TW", "SG" ); private static final List BLOCKED_COUNTRY_NAMES = List.of( - "澳门", "澳門", "Macau", "Macao" + "香港", "澳门", "澳門", "台湾", "台灣", "新加坡", + "Hong Kong", "Macau", "Macao", "Taiwan", "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 af46b42f..5cc1ecbb 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 @@ -70,22 +70,22 @@ public class LoginAccessValidationServiceTest { } @Test - public void allowHongKongRegion() { + public void blockHongKongRegion() { JSONObject data = JSON.parseObject(""" {"country_id":"CN","country":"中国","region":"香港"} """); assertFalse(LoginAccessValidationService.isMainlandChina(data)); - assertFalse(LoginAccessValidationService.isBlockedIpRegion(data)); + assertTrue(LoginAccessValidationService.isBlockedIpRegion(data)); } @Test - public void allowHongKongCountryCode() { + public void blockHongKongCountryCode() { JSONObject data = JSON.parseObject(""" {"country_id":"HK","country":"Hong Kong","region":"Kwai Tsing District"} """); - assertFalse(LoginAccessValidationService.isBlockedIpRegion(data)); + assertTrue(LoginAccessValidationService.isBlockedIpRegion(data)); } @Test @@ -98,30 +98,30 @@ public class LoginAccessValidationServiceTest { } @Test - public void allowSingaporeCountryCode() { + public void blockSingaporeCountryCode() { JSONObject data = JSON.parseObject(""" {"country_id":"SG","country":"Singapore","region":""} """); - assertFalse(LoginAccessValidationService.isBlockedIpRegion(data)); + assertTrue(LoginAccessValidationService.isBlockedIpRegion(data)); } @Test - public void allowTaiwanRegion() { + public void blockTaiwanRegion() { JSONObject data = JSON.parseObject(""" {"country_id":"CN","country":"中国","region":"台湾"} """); assertFalse(LoginAccessValidationService.isMainlandChina(data)); - assertFalse(LoginAccessValidationService.isBlockedIpRegion(data)); + assertTrue(LoginAccessValidationService.isBlockedIpRegion(data)); } @Test - public void allowTaiwanCountryCode() { + public void blockTaiwanCountryCode() { JSONObject data = JSON.parseObject(""" {"country_id":"TW","country":"Taiwan","region":""} """); - assertFalse(LoginAccessValidationService.isBlockedIpRegion(data)); + assertTrue(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 fbc408e3..c2c4477f 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,11 @@ public class IpCountryUtils { "香港", "澳门", "澳門", "台湾", "台灣", "Hong Kong", "Macau", "Macao", "Taiwan" ); private static final List BLOCKED_COUNTRY_CODES = List.of( - "MO" + "HK", "MO", "TW", "SG" ); private static final List BLOCKED_COUNTRY_NAMES = List.of( - "澳门", "澳門", "Macau", "Macao" + "香港", "澳门", "澳門", "台湾", "台灣", "新加坡", + "Hong Kong", "Macau", "Macao", "Taiwan", "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 98b3a47a..7c00d3fa 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 @@ -69,19 +69,19 @@ public class IpCountryUtilsTest { } @Test - public void allowHongKongRegion() { + public void blockHongKongRegion() { IpCountryUtils.IpGeoData data = new IpCountryUtils.IpGeoData("CN", "中国", "香港", "test"); assertFalse(IpCountryUtils.isMainlandChina(data)); - assertFalse(IpCountryUtils.isBlockedIpRegion(data)); + assertTrue(IpCountryUtils.isBlockedIpRegion(data)); } @Test - public void allowHongKongCountryCode() { + public void blockHongKongCountryCode() { IpCountryUtils.IpGeoData data = new IpCountryUtils.IpGeoData("HK", "Hong Kong", "", "test"); assertFalse(IpCountryUtils.isMainlandChina(data)); - assertFalse(IpCountryUtils.isBlockedIpRegion(data)); + assertTrue(IpCountryUtils.isBlockedIpRegion(data)); } @Test @@ -92,24 +92,24 @@ public class IpCountryUtilsTest { } @Test - public void allowSingaporeCountryCode() { + public void blockSingaporeCountryCode() { IpCountryUtils.IpGeoData data = new IpCountryUtils.IpGeoData("SG", "Singapore", "", "test"); - assertFalse(IpCountryUtils.isBlockedIpRegion(data)); + assertTrue(IpCountryUtils.isBlockedIpRegion(data)); } @Test - public void allowTaiwanRegion() { + public void blockTaiwanRegion() { IpCountryUtils.IpGeoData data = new IpCountryUtils.IpGeoData("CN", "中国", "台湾", "test"); assertFalse(IpCountryUtils.isMainlandChina(data)); - assertFalse(IpCountryUtils.isBlockedIpRegion(data)); + assertTrue(IpCountryUtils.isBlockedIpRegion(data)); } @Test - public void allowTaiwanCountryCode() { + public void blockTaiwanCountryCode() { IpCountryUtils.IpGeoData data = new IpCountryUtils.IpGeoData("TW", "Taiwan", "", "test"); - assertFalse(IpCountryUtils.isBlockedIpRegion(data)); + assertTrue(IpCountryUtils.isBlockedIpRegion(data)); } }