|
|
@ -17,6 +17,8 @@ |
|
|
|
|
|
|
|
|
|
|
|
package org.apache.dolphinscheduler.api.interceptor; |
|
|
|
package org.apache.dolphinscheduler.api.interceptor; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static org.mockito.ArgumentMatchers.any; |
|
|
|
|
|
|
|
import static org.mockito.ArgumentMatchers.eq; |
|
|
|
import static org.mockito.Mockito.when; |
|
|
|
import static org.mockito.Mockito.when; |
|
|
|
|
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.api.ApiApplicationServer; |
|
|
|
import org.apache.dolphinscheduler.api.ApiApplicationServer; |
|
|
@ -45,6 +47,8 @@ import org.springframework.test.context.ActiveProfiles; |
|
|
|
import org.springframework.test.context.junit4.SpringRunner; |
|
|
|
import org.springframework.test.context.junit4.SpringRunner; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
|
|
|
|
|
|
|
|
@ActiveProfiles(value = {ProfileType.H2}) |
|
|
|
@ActiveProfiles(value = {ProfileType.H2}) |
|
|
|
@RunWith(SpringRunner.class) |
|
|
|
@RunWith(SpringRunner.class) |
|
|
|
@SpringBootTest(classes = ApiApplicationServer.class) |
|
|
|
@SpringBootTest(classes = ApiApplicationServer.class) |
|
|
@ -81,7 +85,7 @@ public class LoginHandlerInterceptorTest { |
|
|
|
// test token
|
|
|
|
// test token
|
|
|
|
String token = "123456"; |
|
|
|
String token = "123456"; |
|
|
|
when(request.getHeader("token")).thenReturn(token); |
|
|
|
when(request.getHeader("token")).thenReturn(token); |
|
|
|
when(userMapper.queryUserByToken(token)).thenReturn(mockUser); |
|
|
|
when(userMapper.queryUserByToken(eq(token), any(Date.class))).thenReturn(mockUser); |
|
|
|
Assert.assertTrue(interceptor.preHandle(request, response, null)); |
|
|
|
Assert.assertTrue(interceptor.preHandle(request, response, null)); |
|
|
|
|
|
|
|
|
|
|
|
// test disable user
|
|
|
|
// test disable user
|
|
|
|