fix: return Chinese security messages in UTF-8
parent
5753cb6fa8
commit
a0cf97a0f0
@ -0,0 +1,33 @@
|
||||
package com.yau.digitalrmb.security;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@SpringBootTest
|
||||
@AutoConfigureMockMvc
|
||||
@ActiveProfiles("test")
|
||||
class SecurityConfigTest {
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@Test
|
||||
void returnsChineseUtf8MessageWhenAuthenticationIsMissing() throws Exception {
|
||||
mockMvc.perform(get("/api/v1/commercial-banks/issuance/inventory"))
|
||||
.andExpect(status().isUnauthorized())
|
||||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON))
|
||||
.andExpect(content().encoding(StandardCharsets.UTF_8))
|
||||
.andExpect(jsonPath("$.message").value("未登录或登录已失效"));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue