solve the chaos code problem on rejectTips (#279)

* solve the chaos code problem on rejectTips

* Update CHANGELOG.md
pull/282/head
cheese8 2 years ago committed by GitHub
parent 6e2a3f1dc6
commit 6dc6bf305e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -12,3 +12,4 @@
- [fix:fix ClassNotFoundException while not importing openfeign when using circuit-breaker module.](https://github.com/Tencent/spring-cloud-tencent/pull/269)
- [Update GitHub Actions workflow](https://github.com/Tencent/spring-cloud-tencent/pull/273)
- [fix:fix TypeNotPresentException in @ConditionalOnClass of router.](https://github.com/Tencent/spring-cloud-tencent/pull/276)
- [fix:solve the chaos code problem on rejectTips.](https://github.com/Tencent/spring-cloud-tencent/pull/279)

@ -99,6 +99,7 @@ public class QuotaCheckServletFilter extends OncePerRequestFilter {
if (quotaResponse.getCode() == QuotaResultCode.QuotaResultLimited) {
response.setStatus(polarisRateLimitProperties.getRejectHttpCode());
response.setContentType("text/plain;charset=UTF-8");
response.getWriter().write(rejectTips);
return;
}

@ -118,7 +118,7 @@ public class QuotaCheckServletFilterTest {
});
PolarisRateLimitProperties polarisRateLimitProperties = new PolarisRateLimitProperties();
polarisRateLimitProperties.setRejectRequestTips("RejectRequestTips");
polarisRateLimitProperties.setRejectRequestTips("RejectRequestTips提示消息");
polarisRateLimitProperties.setRejectHttpCode(419);
RateLimitRuleLabelResolver rateLimitRuleLabelResolver = mock(RateLimitRuleLabelResolver.class);
@ -133,7 +133,7 @@ public class QuotaCheckServletFilterTest {
try {
Field rejectTips = QuotaCheckServletFilter.class.getDeclaredField("rejectTips");
rejectTips.setAccessible(true);
assertThat(rejectTips.get(quotaCheckServletFilter)).isEqualTo("RejectRequestTips");
assertThat(rejectTips.get(quotaCheckServletFilter)).isEqualTo("RejectRequestTips提示消息");
}
catch (NoSuchFieldException | IllegalAccessException e) {
fail("Exception encountered.", e);
@ -201,7 +201,7 @@ public class QuotaCheckServletFilterTest {
MetadataContext.LOCAL_SERVICE = "TestApp3";
quotaCheckServletFilter.doFilterInternal(request, response, filterChain);
assertThat(response.getStatus()).isEqualTo(419);
assertThat(response.getContentAsString()).isEqualTo("RejectRequestTips");
assertThat(response.getContentAsString()).isEqualTo("RejectRequestTips提示消息");
// Exception

Loading…
Cancel
Save