TokenUtils { public void revokePowerToken(String token) { Response response = ControllerUtil.getReqProcessor().process("/auth/tvault/revoke","{}", token); if (HttpStatus.NO_CONTENT.equals(response.getHttpstatus()) || HttpStatus.OK.equals(response.getHttpstatus())) { log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "revokePowerToken"). put(LogMessage.MESSAGE, String.format ("SelfService token successfully revoked")). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); } else { log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder(). put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER).toString()). put(LogMessage.ACTION, "revokePowerToken"). put(LogMessage.MESSAGE, String.format ("SelfService token revoke failed")). put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL).toString()). build())); } } TokenUtils(); String getSelfServiceToken(); String getSelfServiceTokenWithAppRole(); void revokePowerToken(String token);  }
@Test public void test_revokePowerToken_success() { String token = "5PDrOhsy4ig8L3EpsJZSLAMg"; Response res = getMockResponse(HttpStatus.NO_CONTENT, true, ""); when(reqProcessor.process("/auth/tvault/revoke","{}", token)).thenReturn(res); tokenUtils.revokePowerToken(token); }
@Test public void test_revokePowerToken_failure() { String token = "5PDrOhsy4ig8L3EpsJZSLAMg"; Response res = getMockResponse(HttpStatus.NOT_FOUND, true, ""); when(reqProcessor.process("/auth/tvault/revoke","{}", token)).thenReturn(res); tokenUtils.revokePowerToken(token); }