Skip to content

Commit 8376bdf

Browse files
authored
Merge pull request #38 from CJP2004/dev
Dev
2 parents ba7940d + 42fd946 commit 8376bdf

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

auth-service/src/main/java/com/servicegovernance/auth/vo/DashboardTopologyVo.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
public 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
}

auth-service/src/test/java/com/servicegovernance/auth/common/interceptor/LoginSessionInterceptorTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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

auth-service/src/test/java/com/servicegovernance/auth/controller/AuthControllerTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)