use of org.apache.knox.gateway.shell.KnoxSession in project knox by apache.
the class TokenTest method testToken.
private void testToken(boolean setDoAsUser, String doAsUser) {
KnoxSession knoxSession = createMock(KnoxSession.class);
expect(knoxSession.base()).andReturn("http://localhost/base").atLeastOnce();
replay(knoxSession);
Get.Request request = (setDoAsUser) ? Token.get(knoxSession, doAsUser) : Token.get(knoxSession);
if (setDoAsUser) {
assertEquals(doAsUser, request.getDoAsUser());
} else {
assertNull(request.getDoAsUser());
}
if (setDoAsUser && StringUtils.isNotEmpty(doAsUser)) {
assertEquals("http://localhost/base/knoxtoken/api/v1/token?doAs=" + doAsUser, request.getRequestURI().toString());
} else {
assertEquals("http://localhost/base/knoxtoken/api/v1/token", request.getRequestURI().toString());
}
assertSame(knoxSession, request.getSession());
verify(knoxSession);
}
use of org.apache.knox.gateway.shell.KnoxSession in project knox by apache.
the class GetTest method testGetRequest.
private void testGetRequest(boolean setDoAsUser, String doAsUser) {
KnoxSession knoxSession = createMock(KnoxSession.class);
expect(knoxSession.base()).andReturn("http://localhost/base").atLeastOnce();
replay(knoxSession);
Get.Request request = (setDoAsUser) ? new Get.Request(knoxSession, doAsUser) : new Get.Request(knoxSession);
if (setDoAsUser) {
assertEquals(doAsUser, request.getDoAsUser());
} else {
assertNull(request.getDoAsUser());
}
if (setDoAsUser && StringUtils.isNotEmpty(doAsUser)) {
assertEquals("http://localhost/base/knoxtoken/api/v1/token?doAs=" + doAsUser, request.getRequestURI().toString());
} else {
assertEquals("http://localhost/base/knoxtoken/api/v1/token", request.getRequestURI().toString());
}
assertSame(knoxSession, request.getSession());
verify(knoxSession);
}
Aggregations