Search in sources :

Example 46 with ModelControllerClient

use of org.jboss.as.controller.client.ModelControllerClient in project wildfly by wildfly.

the class HTTPSWebConnectorTestCase method serverSetup.

private void serverSetup(ManagementClient managementClient) throws Exception {
    FileUtils.deleteDirectory(WORK_DIR);
    WORK_DIR.mkdirs();
    Utils.createKeyMaterial(WORK_DIR);
    TRACE_SECURITY.setup(managementClient, null);
    SecurityDomainsSetup.INSTANCE.setup(managementClient, null);
    final ModelControllerClient client = managementClient.getControllerClient();
    // add new HTTPS_REALM with SSL
    ModelNode operation = createOpNode("core-service=management/security-realm=" + HTTPS_REALM, ModelDescriptionConstants.ADD);
    Utils.applyUpdate(operation, client);
    operation = createOpNode("core-service=management/security-realm=" + HTTPS_REALM + "/authentication=truststore", ModelDescriptionConstants.ADD);
    operation.get("keystore-path").set(SERVER_TRUSTSTORE_FILE.getAbsolutePath());
    operation.get("keystore-password").set(SecurityTestConstants.KEYSTORE_PASSWORD);
    Utils.applyUpdate(operation, client);
    operation = createOpNode("core-service=management/security-realm=" + HTTPS_REALM + "/server-identity=ssl", ModelDescriptionConstants.ADD);
    operation.get(PROTOCOL).set("TLSv1");
    operation.get("keystore-path").set(SERVER_KEYSTORE_FILE.getAbsolutePath());
    operation.get("keystore-password").set(SecurityTestConstants.KEYSTORE_PASSWORD);
    // operation.get("alias").set("management");
    Utils.applyUpdate(operation, client);
    LOGGER.trace("*** restarting server");
    containerController.stop(CONTAINER);
    containerController.start(CONTAINER);
    addHttpsConnector("NOT_REQUESTED", HTTPS_NAME_VERIFY_NOT_REQUESTED, HTTPS_PORT_VERIFY_FALSE, client);
    addHttpsConnector("REQUESTED", HTTPS_NAME_VERIFY_REQUESTED, HTTPS_PORT_VERIFY_WANT, client);
    addHttpsConnector("REQUIRED", HTTPS_NAME_VERIFY_REQUIRED, HTTPS_PORT_VERIFY_TRUE, client);
}
Also used : ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) ModelNode(org.jboss.dmr.ModelNode)

Example 47 with ModelControllerClient

use of org.jboss.as.controller.client.ModelControllerClient in project wildfly by wildfly.

the class WSAttributesChangesTestCase method performWsdlHostAttributeTest.

private void performWsdlHostAttributeTest(boolean checkUpdateWithDeployedEndpoint) throws Exception {
    Assert.assertTrue(containerController.isStarted(DEFAULT_JBOSSAS));
    ManagementClient managementClient = new ManagementClient(TestSuiteEnvironment.getModelControllerClient(), TestSuiteEnvironment.getServerAddress(), TestSuiteEnvironment.getServerPort(), "http-remoting");
    ModelControllerClient client = managementClient.getControllerClient();
    String initialWsdlHost = null;
    try {
        initialWsdlHost = getAttribute("wsdl-host", client);
        final String hostnameA = "foo-host-a";
        ModelNode op = createOpNode("subsystem=webservices/", WRITE_ATTRIBUTE_OPERATION);
        op.get(NAME).set("wsdl-host");
        op.get(VALUE).set(hostnameA);
        //update successful, no need to reload
        applyUpdate(client, op, false);
        //now we deploy an endpoint...
        deployer.deploy(DEP_1);
        //verify the updated wsdl host is used...
        URL wsdlURL = new URL(managementClient.getWebUri().toURL(), '/' + DEP_1 + "/POJOService?wsdl");
        checkWsdl(wsdlURL, hostnameA);
        if (checkUpdateWithDeployedEndpoint) {
            final String hostnameB = "foo-host-b";
            ModelNode opB = createOpNode("subsystem=webservices/", WRITE_ATTRIBUTE_OPERATION);
            opB.get(NAME).set("wsdl-host");
            opB.get(VALUE).set(hostnameB);
            //update again, but we'll need to reload, as there's an active deployment
            applyUpdate(client, opB, true);
            //check the wsdl host is still the one we updated to before
            checkWsdl(wsdlURL, hostnameA);
            //and check that still applies even if we undeploy and redeploy the endpoint
            deployer.undeploy(DEP_1);
            deployer.deploy(DEP_1);
            checkWsdl(wsdlURL, hostnameA);
        }
    } finally {
        try {
            deployer.undeploy(DEP_1);
        } catch (Throwable t) {
        //ignore
        }
        try {
            if (initialWsdlHost != null) {
                ModelNode op = createOpNode("subsystem=webservices/", WRITE_ATTRIBUTE_OPERATION);
                op.get(NAME).set("wsdl-host");
                op.get(VALUE).set(initialWsdlHost);
                applyUpdate(client, op, checkUpdateWithDeployedEndpoint);
            }
        } finally {
            managementClient.close();
        }
    }
}
Also used : ManagementClient(org.jboss.as.arquillian.container.ManagementClient) ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) ModelNode(org.jboss.dmr.ModelNode) URL(java.net.URL)

Example 48 with ModelControllerClient

use of org.jboss.as.controller.client.ModelControllerClient in project wildfly by wildfly.

the class WSAttributesChangesTestCase method performWsdlPortAttributeTest.

private void performWsdlPortAttributeTest(boolean checkUpdateWithDeployedEndpoint) throws Exception {
    Assert.assertTrue(containerController.isStarted(DEFAULT_JBOSSAS));
    ManagementClient managementClient = new ManagementClient(TestSuiteEnvironment.getModelControllerClient(), TestSuiteEnvironment.getServerAddress(), TestSuiteEnvironment.getServerPort(), "http-remoting");
    ModelControllerClient client = managementClient.getControllerClient();
    try {
        final String portA = "55667";
        ModelNode op = createOpNode("subsystem=webservices/", WRITE_ATTRIBUTE_OPERATION);
        op.get(NAME).set("wsdl-port");
        op.get(VALUE).set(portA);
        //update successful, no need to reload
        applyUpdate(client, op, false);
        //now we deploy an endpoint...
        deployer.deploy(DEP_2);
        //verify the updated wsdl port is used...
        URL wsdlURL = new URL(managementClient.getWebUri().toURL(), '/' + DEP_2 + "/POJOService?wsdl");
        checkWsdl(wsdlURL, portA);
        if (checkUpdateWithDeployedEndpoint) {
            final String portB = "55668";
            ModelNode opB = createOpNode("subsystem=webservices/", WRITE_ATTRIBUTE_OPERATION);
            opB.get(NAME).set("wsdl-port");
            opB.get(VALUE).set(portB);
            //update again, but we'll need to reload, as there's an active deployment
            applyUpdate(client, opB, true);
            //check the wsdl port is still the one we updated to before
            checkWsdl(wsdlURL, portA);
            //and check that still applies even if we undeploy and redeploy the endpoint
            deployer.undeploy(DEP_2);
            deployer.deploy(DEP_2);
            checkWsdl(wsdlURL, portA);
        }
    } finally {
        try {
            deployer.undeploy(DEP_2);
        } catch (Throwable t) {
        //ignore
        }
        try {
            ModelNode op = createOpNode("subsystem=webservices/", UNDEFINE_ATTRIBUTE_OPERATION);
            op.get(NAME).set("wsdl-port");
            applyUpdate(client, op, checkUpdateWithDeployedEndpoint);
        } finally {
            managementClient.close();
        }
    }
}
Also used : ManagementClient(org.jboss.as.arquillian.container.ManagementClient) ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) ModelNode(org.jboss.dmr.ModelNode) URL(java.net.URL)

Example 49 with ModelControllerClient

use of org.jboss.as.controller.client.ModelControllerClient in project wildfly by wildfly.

the class AbstractFederationServerSetupTask method tearDown.

@Override
public void tearDown(ManagementClient managementClient, String containerId) throws Exception {
    ModelControllerClient controllerClient = managementClient.getControllerClient();
    removeFederation(controllerClient);
    applyUpdate(Util.createRemoveOperation(PathAddress.pathAddress().append(SUBSYSTEM, SUBSYSTEM_NAME)), controllerClient);
    applyUpdate(Util.createRemoveOperation(PathAddress.pathAddress().append(EXTENSION, EXTENSION_MODULE_NAME)), controllerClient);
}
Also used : ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient)

Example 50 with ModelControllerClient

use of org.jboss.as.controller.client.ModelControllerClient in project wildfly by wildfly.

the class AbstractRbacTestCase method getClientForUser.

public ModelControllerClient getClientForUser(String userName) throws UnknownHostException {
    ModelControllerClient result = clients.get(userName);
    if (result == null) {
        result = createClient(userName);
        clients.put(userName, result);
    }
    return result;
}
Also used : ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient)

Aggregations

ModelControllerClient (org.jboss.as.controller.client.ModelControllerClient)58 ModelNode (org.jboss.dmr.ModelNode)27 Test (org.junit.Test)21 ManagementClient (org.jboss.as.arquillian.container.ManagementClient)17 IOException (java.io.IOException)11 InSequence (org.jboss.arquillian.junit.InSequence)8 URL (java.net.URL)5 PathAddress (org.jboss.as.controller.PathAddress)5 Before (org.junit.Before)5 JMSOperations (org.jboss.as.test.integration.common.jms.JMSOperations)4 UnknownHostException (java.net.UnknownHostException)3 InitialContext (javax.naming.InitialContext)2 NamingException (javax.naming.NamingException)2 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)2 CommandContext (org.jboss.as.cli.CommandContext)2 CommandFormatException (org.jboss.as.cli.CommandFormatException)2 OperationFormatException (org.jboss.as.cli.operation.OperationFormatException)2 DefaultOperationRequestBuilder (org.jboss.as.cli.operation.impl.DefaultOperationRequestBuilder)2 After (org.junit.After)2 BeforeClass (org.junit.BeforeClass)2