mirror of
https://gitee.com/dolphinscheduler/DolphinScheduler.git
synced 2024-12-04 21:28:00 +08:00
to feature 7418 (#7420)
Co-authored-by: ouyangyewei <yewei.oyyw@alibaba-inc.com>
This commit is contained in:
parent
bc995752d6
commit
801e6dd6bb
@ -194,7 +194,7 @@ public class AccessTokenController extends BaseController {
|
|||||||
* @param userId token for user
|
* @param userId token for user
|
||||||
* @param expireTime token expire time
|
* @param expireTime token expire time
|
||||||
* @param token token string (if it is absent, it will be automatically generated)
|
* @param token token string (if it is absent, it will be automatically generated)
|
||||||
* @return update result code
|
* @return updated access token entity
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "updateToken", notes = "UPDATE_TOKEN_NOTES")
|
@ApiOperation(value = "updateToken", notes = "UPDATE_TOKEN_NOTES")
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
|
@ -83,7 +83,7 @@ public interface AccessTokenService {
|
|||||||
* @param userId token for user
|
* @param userId token for user
|
||||||
* @param expireTime token expire time
|
* @param expireTime token expire time
|
||||||
* @param token token string (if it is absent, it will be automatically generated)
|
* @param token token string (if it is absent, it will be automatically generated)
|
||||||
* @return update result code
|
* @return updated access token entity
|
||||||
*/
|
*/
|
||||||
Map<String, Object> updateToken(User loginUser, int id, int userId, String expireTime, String token);
|
Map<String, Object> updateToken(User loginUser, int id, int userId, String expireTime, String token);
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ public class AccessTokenServiceImpl extends BaseServiceImpl implements AccessTok
|
|||||||
* @param userId token for user
|
* @param userId token for user
|
||||||
* @param expireTime token expire time
|
* @param expireTime token expire time
|
||||||
* @param token token string (if it is absent, it will be automatically generated)
|
* @param token token string (if it is absent, it will be automatically generated)
|
||||||
* @return update result code
|
* @return updated access token entity
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> updateToken(User loginUser, int id, int userId, String expireTime, String token) {
|
public Map<String, Object> updateToken(User loginUser, int id, int userId, String expireTime, String token) {
|
||||||
@ -241,6 +241,7 @@ public class AccessTokenServiceImpl extends BaseServiceImpl implements AccessTok
|
|||||||
|
|
||||||
accessTokenMapper.updateById(accessToken);
|
accessTokenMapper.updateById(accessToken);
|
||||||
|
|
||||||
|
result.put(Constants.DATA_LIST, accessToken);
|
||||||
putMsg(result, Status.SUCCESS);
|
putMsg(result, Status.SUCCESS);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -193,6 +193,7 @@ public class AccessTokenControllerTest extends AbstractControllerTest {
|
|||||||
|
|
||||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
|
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
|
||||||
Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
|
Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
|
||||||
|
Assert.assertNotNull(result.getData());
|
||||||
logger.info(mvcResult.getResponse().getContentAsString());
|
logger.info(mvcResult.getResponse().getContentAsString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,11 +152,13 @@ public class AccessTokenServiceTest {
|
|||||||
Map<String, Object> result = accessTokenService.updateToken(getLoginUser(), 1,Integer.MAX_VALUE,getDate(),"token");
|
Map<String, Object> result = accessTokenService.updateToken(getLoginUser(), 1,Integer.MAX_VALUE,getDate(),"token");
|
||||||
logger.info(result.toString());
|
logger.info(result.toString());
|
||||||
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
|
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
|
||||||
|
Assert.assertNotNull(result.get(Constants.DATA_LIST));
|
||||||
|
|
||||||
// Token is absent
|
// Token is absent
|
||||||
result = accessTokenService.updateToken(getLoginUser(), 1, Integer.MAX_VALUE,getDate(),null);
|
result = accessTokenService.updateToken(getLoginUser(), 1, Integer.MAX_VALUE,getDate(),null);
|
||||||
logger.info(result.toString());
|
logger.info(result.toString());
|
||||||
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
|
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
|
||||||
|
Assert.assertNotNull(result.get(Constants.DATA_LIST));
|
||||||
|
|
||||||
// ACCESS_TOKEN_NOT_EXIST
|
// ACCESS_TOKEN_NOT_EXIST
|
||||||
result = accessTokenService.updateToken(getLoginUser(), 2,Integer.MAX_VALUE,getDate(),"token");
|
result = accessTokenService.updateToken(getLoginUser(), 2,Integer.MAX_VALUE,getDate(),"token");
|
||||||
|
Loading…
Reference in New Issue
Block a user