SecurityRestApi { @GET @Path("ticket") @ZeppelinApi public Response ticket() { ZeppelinConfiguration conf = ZeppelinConfiguration.create(); String principal = SecurityUtils.getPrincipal(); HashSet<String> roles = SecurityUtils.getRoles(); JsonResponse response; String ticket; if ("anonymous".equals(principal)) ticket = "anonymous"; else ticket = TicketContainer.instance.getTicket(principal); Map<String, String> data = new HashMap<>(); data.put("principal", principal); data.put("roles", roles.toString()); data.put("ticket", ticket); response = new JsonResponse(Response.Status.OK, "", data); LOG.warn(response.toString()); return response.build(); } SecurityRestApi(); @GET @Path("ticket") @ZeppelinApi Response ticket(); @GET @Path("userlist/{searchText}") Response getUserList(@PathParam("searchText") String searchText);  }
@Test public void testTicket() throws IOException { GetMethod get = httpGet("/security/ticket"); get.addRequestHeader("Origin", "http: Map<String, Object> resp = gson.fromJson(get.getResponseBodyAsString(), new TypeToken<Map<String, Object>>(){}.getType()); Map<String, String> body = (Map<String, String>) resp.get("body"); assertEquals("anonymous", body.get("principal")); assertEquals("anonymous", body.get("ticket")); get.releaseConnection(); }