use of io.etcd.jetcd.auth.AuthDisableResponse in project jetcd by coreos.
the class ClientConnectionManagerTest method testAuthHeaders.
@Test
public void testAuthHeaders() throws InterruptedException, ExecutionException {
final CountDownLatch latch = new CountDownLatch(1);
Auth authClient = TestUtil.client(cluster).build().getAuthClient();
authClient.userAdd(root, rootPass).get();
ByteSequence role = TestUtil.bytesOf("root");
authClient.userGrantRole(root, role).get();
authClient.authEnable().get();
final ClientBuilder builder = TestUtil.client(cluster).authHeader("MyAuthHeader", "MyAuthHeaderVal").header("MyHeader2", "MyHeaderVal2").user(root).password(rootPass);
assertThat(builder.authHeaders().get(Metadata.Key.of("MyAuthHeader", Metadata.ASCII_STRING_MARSHALLER))).isEqualTo("MyAuthHeaderVal");
try (Client client = builder.build()) {
CompletableFuture<AuthDisableResponse> future = client.getAuthClient().authDisable();
latch.await(10, TimeUnit.SECONDS);
future.get();
}
authClient.userRevokeRole(root, role).get();
authClient.userDelete(root).get();
}
Aggregations