use of org.wildfly.swarm.management.AuthCallbackHandler in project wildfly-swarm by wildfly-swarm.
the class ArqSecuredManagementInterfaceTest method testClient.
@Test
@RunAsClient
public void testClient() throws Exception {
Security.addProvider(new WildFlyElytronProvider());
ModelControllerClient client = ModelControllerClient.Factory.create("localhost", 9990, new AuthCallbackHandler("ManagementRealm", "bob", "tacos!"));
ModelNode response = client.execute(Operations.createOperation("whoami"));
assertThat(response.get("outcome").asString()).isEqualTo("success");
ModelNode result = response.get("result");
assertThat(result).isNotNull();
assertThat(result.isDefined()).isTrue();
ModelNode identity = result.get("identity");
assertThat(identity).isNotNull();
assertThat(identity.isDefined()).isTrue();
assertThat(identity.get("username").asString()).isEqualTo("bob");
// ===
response = client.execute(Operations.createOperation("read-resource", PathAddress.pathAddress(PathElement.pathElement("deployment", "*")).toModelNode()));
assertThat(response.get("outcome").asString()).isEqualTo("success");
result = response.get("result");
assertThat(result).isNotNull();
assertThat(result.isDefined()).isTrue();
assertThat(result.getType()).isEqualTo(ModelType.LIST);
assertThat(result.asList()).hasSize(1);
ModelNode myapp = result.get(0);
assertThat(myapp).isNotNull();
assertThat(myapp.isDefined()).isTrue();
ModelNode myappResult = myapp.get("result");
assertThat(myappResult).isNotNull();
assertThat(myappResult.isDefined()).isTrue();
assertThat(myappResult.get("name").asString()).isEqualTo("ArqSecuredManagementInterfaceTest.war");
}
Aggregations