@Test
public void testSecure(TestContext context) {
Async async = context.async();
server = createServer(context, new HttpTermOptions().setAuthOptions(
new ShiroAuthOptions().
setType(ShiroAuthRealmType.PROPERTIES).
setConfig(new JsonObject().put("properties_path", "classpath:test-auth.properties"))).setPort(8080));
server.termHandler(term -> {
term.write("hello");
});
server.listen(context.asyncAssertSuccess(server -> {
HttpClient client = vertx.createHttpClient();
client.websocket(8080, "localhost", basePath + "/shell/websocket", ws -> {
context.fail();
}, err -> {
client.websocket(8080, "localhost", basePath + "/shell/websocket",
new CaseInsensitiveHeaders().add("Authorization", "Basic " + Base64.getEncoder().encodeToString("tim:sausages".getBytes())),
ws -> {
ws.handler(buf -> {
context.assertEquals("hello", buf.toString());
async.complete();
});
}, context::fail);
});
}));
}