SecurityRestApi { @GET @Path("ticket") @ZeppelinApi public Response ticket() { ZeppelinConfiguration conf = ZeppelinConfiguration.create(); String principal = authenticationService.getPrincipal(); Set<String> roles = authenticationService.getAssociatedRoles(); 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", gson.toJson(roles)); data.put("ticket", ticket); response = new JsonResponse(Response.Status.OK, "", data); LOG.warn(response.toString()); return response.build(); } @Inject  SecurityRestApi(AuthenticationService authenticationService); @GET @Path("ticket") @ZeppelinApi Response ticket(); @GET @Path("userlist/{searchText}") Response getUserList(@PathParam("searchText") final String searchText);  }
@Test public void testTicket() throws IOException { GetMethod get = httpGet("/security/ticket", "admin", "password1"); 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"); collector.checkThat("Paramater principal", body.get("principal"), CoreMatchers.equalTo("admin")); collector.checkThat("Paramater ticket", body.get("ticket"), CoreMatchers.not("anonymous")); get.releaseConnection(); }