risdenk commented on a change in pull request #180: KNOX-2105 - KnoxShell
support for token renewal and revocation
URL: https://github.com/apache/knox/pull/180#discussion_r343855590
##########
File path:
gateway-shell/src/test/java/org/apache/knox/gateway/shell/knox/token/TokenTest.java
##########
@@ -76,4 +127,100 @@ private void testToken(boolean setDoAsUser, String
doAsUser) {
verify(knoxSession);
}
+
+ private void testRenewToken(boolean setDoAsUser, String doAsUser) throws
Exception {
+ final String testToken = "ABCDEFG123456";
+
+ KnoxSession knoxSession = createMock(KnoxSession.class);
+
expect(knoxSession.base()).andReturn("http://localhost/base").atLeastOnce();
+
expect(knoxSession.getHeaders()).andReturn(Collections.emptyMap()).atLeastOnce();
+
expect(knoxSession.executeNow(isA(HttpRequest.class))).andReturn(null).atLeastOnce();
+ replay(knoxSession);
+
+ Renew.Request request = (setDoAsUser)
+ ? Token.renew(knoxSession, testToken, doAsUser)
+ : Token.renew(knoxSession, testToken);
+
+ boolean shouldHaveDoAs = false;
+
+ if (setDoAsUser) {
+ assertEquals(doAsUser, request.getDoAsUser());
+ shouldHaveDoAs = StringUtils.isNotEmpty(doAsUser);
+ } else {
+ assertNull(request.getDoAsUser());
+ }
+
+ assertEquals("http://localhost/base/knoxtoken/api/v1/token/renew" +
(shouldHaveDoAs ? ("?doAs=" + doAsUser) : ""),
+ request.getRequestURI().toString());
+
+ assertEquals(testToken, request.getToken());
+
+ Callable<TokenLifecycleResponse> callable = request.callable();
+ try {
+ callable.call();
+ } catch (Exception e) {
+ e.printStackTrace();
Review comment:
Should this fail the test? (same with other catch locations)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services