File tree Expand file tree Collapse file tree
main/java/com/servicegovernance/auth/vo
test/java/com/servicegovernance/auth Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55
66public class DashboardTopologyVo {
77
8+ private static final String TO_STRING_NAME_PREFIX = "name='" ;
9+
810 private List <NodeVo > nodes = new ArrayList <>();
911 private List <LinkVo > links = new ArrayList <>();
1012 private List <CategoryVo > categories = new ArrayList <>();
@@ -84,7 +86,7 @@ public void setCategory(Integer category) {
8486 @ Override
8587 public String toString () {
8688 return "NodeVo{"
87- + "name='" + name + '\''
89+ + TO_STRING_NAME_PREFIX + name + '\''
8890 + ", label='" + label + '\''
8991 + ", value=" + value
9092 + ", category=" + category
@@ -176,7 +178,7 @@ public void setPath(String path) {
176178 @ Override
177179 public String toString () {
178180 return "ApiDetailVo{"
179- + "name='" + name + '\''
181+ + TO_STRING_NAME_PREFIX + name + '\''
180182 + ", path='" + path + '\''
181183 + '}' ;
182184 }
@@ -197,7 +199,7 @@ public void setName(String name) {
197199 @ Override
198200 public String toString () {
199201 return "CategoryVo{"
200- + "name='" + name + '\''
202+ + TO_STRING_NAME_PREFIX + name + '\''
201203 + '}' ;
202204 }
203205 }
Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ public void logout(com.servicegovernance.auth.dto.LogoutRequestDto requestDto) {
7676
7777 @ Override
7878 public void checkSession (String sessionToken ) {
79+ // 当前拦截器测试不会触发登录状态检查,该方法仅用于满足 AuthService 接口契约。
7980 }
8081
8182 @ Override
Original file line number Diff line number Diff line change @@ -39,11 +39,25 @@ void shouldReturnLogoutSuccessResponseWhenTokenIsValid() {
3939 Assertions .assertEquals (0 , response .getCode ());
4040 }
4141
42+ @ Test
43+ void shouldDelegateSessionCheckWhenTokenIsProvided () {
44+ StubAuthService authService = new StubAuthService ();
45+ AuthController authController = new AuthController (authService );
46+
47+ ApiResponse <Void > response = authController .sessionCheck ("active-token" );
48+
49+ Assertions .assertTrue (authService .checkSessionCalled );
50+ Assertions .assertEquals ("active-token" , authService .lastCheckedSessionToken );
51+ Assertions .assertEquals (0 , response .getCode ());
52+ }
53+
4254 private static class StubAuthService implements AuthService {
4355
4456 private LoginResponseVo loginResponseVo ;
4557 private boolean logoutCalled ;
58+ private boolean checkSessionCalled ;
4659 private String lastSessionToken ;
60+ private String lastCheckedSessionToken ;
4761
4862 @ Override
4963 public LoginResponseVo login (LoginRequestDto requestDto ) {
@@ -58,6 +72,8 @@ public void logout(LogoutRequestDto requestDto) {
5872
5973 @ Override
6074 public void checkSession (String sessionToken ) {
75+ checkSessionCalled = true ;
76+ lastCheckedSessionToken = sessionToken ;
6177 }
6278
6379 @ Override
You can’t perform that action at this time.
0 commit comments