[
https://issues.apache.org/jira/browse/KNOX-2105?focusedWorklogId=340135&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-340135
]
ASF GitHub Bot logged work on KNOX-2105:
----------------------------------------
Author: ASF GitHub Bot
Created on: 07/Nov/19 20:25
Start Date: 07/Nov/19 20:25
Worklog Time Spent: 10m
Work Description: pzampino commented on pull request #180: KNOX-2105 -
KnoxShell support for token renewal and revocation
URL: https://github.com/apache/knox/pull/180#discussion_r343857133
##########
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:
Actually, I should remove the printing of the stack trace. The call should
fail, but is required to setup the actual underlying request (so the setting of
the entity can be verified). Short answer: no, it should not fail the test in
either case.
----------------------------------------------------------------
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]
Issue Time Tracking
-------------------
Worklog Id: (was: 340135)
Time Spent: 50m (was: 40m)
> KnoxShell support for token renewal and revocation
> --------------------------------------------------
>
> Key: KNOX-2105
> URL: https://issues.apache.org/jira/browse/KNOX-2105
> Project: Apache Knox
> Issue Type: Bug
> Components: KnoxShell
> Affects Versions: 1.4.0
> Reporter: Philip Zampino
> Assignee: Philip Zampino
> Priority: Major
> Fix For: 1.4.0
>
> Attachments: ExampleTokenRenewal.groovy
>
> Time Spent: 50m
> Remaining Estimate: 0h
>
> KNOX-2067 added the ability to renew and revoke Knox tokens. This should be
> exposed by theĀ org.apache.knox.gateway.shell.knox.token.Token KnoxShell type.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)