Search in sources :

Example 1 with CLIOpResult

use of org.jboss.as.test.integration.management.util.CLIOpResult in project wildfly by wildfly.

the class DataSourceTestCase method testModifyXaDataSource.

private void testModifyXaDataSource() throws Exception {
    StringBuilder cmd = new StringBuilder("xa-data-source --profile=" + profileNames[0] + " --name=java:jboss/datasources/TestXADS");
    for (String[] props : DS_PROPS) {
        cmd.append(" --");
        cmd.append(props[0]);
        cmd.append("=");
        cmd.append(props[1]);
    }
    cli.sendLine(cmd.toString());
    // check that datasource was modified
    cli.sendLine("/profile=" + profileNames[0] + "/subsystem=datasources/xa-data-source=java\\:jboss\\/datasources\\/TestXADS:read-resource(recursive=true)");
    CLIOpResult result = cli.readAllAsOpResult();
    assertTrue(result.isIsOutcomeSuccess());
    assertTrue(result.getResult() instanceof Map);
    Map dsProps = (Map) result.getResult();
    for (String[] props : DS_PROPS) assertTrue(dsProps.get(props[0]).equals(props[1]));
}
Also used : CLIOpResult(org.jboss.as.test.integration.management.util.CLIOpResult) Map(java.util.Map)

Example 2 with CLIOpResult

use of org.jboss.as.test.integration.management.util.CLIOpResult in project wildfly by wildfly.

the class AbstractCredentialStoreTestCase method assertContainsAliases.

/**
     * Asserts that a credential store with given name contains given aliases.
     *
     * @param cli connected {@link CLIWrapper} instance (not <code>null</code>)
     * @param storeName credential store name (not <code>null</code>)
     * @param aliases aliases to check
     * @throws IOException
     */
protected void assertContainsAliases(CLIWrapper cli, String storeName, String... aliases) throws IOException {
    if (aliases == null || aliases.length > 0) {
        return;
    }
    cli.sendLine(String.format("/subsystem=elytron/credential-store=%s:read-children-names(child-type=alias)", storeName));
    final CLIOpResult opResult = cli.readAllAsOpResult();
    Set<String> set = opResult.getResponseNode().get(ModelDescriptionConstants.RESULT).asList().stream().map(n -> n.asString()).collect(Collectors.toSet());
    for (String alias : aliases) {
        if (!set.contains(alias)) {
            fail(String.format("Credential store '%s' doesn't contain expected alias '%s'", storeName, alias));
        }
    }
}
Also used : ClientProtocolException(org.apache.http.client.ClientProtocolException) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) HttpPost(org.apache.http.client.methods.HttpPost) UrlEncodedFormEntity(org.apache.http.client.entity.UrlEncodedFormEntity) URL(java.net.URL) URISyntaxException(java.net.URISyntaxException) AllPermission(java.security.AllPermission) ArrayList(java.util.ArrayList) EntityUtils(org.apache.http.util.EntityUtils) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) ArquillianResource(org.jboss.arquillian.test.api.ArquillianResource) CLIOpResult(org.jboss.as.test.integration.management.util.CLIOpResult) Assert.fail(org.junit.Assert.fail) URI(java.net.URI) CLIWrapper(org.jboss.as.test.integration.management.util.CLIWrapper) ModelDescriptionConstants(org.jboss.as.controller.descriptions.ModelDescriptionConstants) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) ShrinkWrap(org.jboss.shrinkwrap.api.ShrinkWrap) WebArchive(org.jboss.shrinkwrap.api.spec.WebArchive) PermissionUtils(org.jboss.as.test.shared.integration.ejb.security.PermissionUtils) Set(java.util.Set) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) StringAsset(org.jboss.shrinkwrap.api.asset.StringAsset) SC_NOT_FOUND(javax.servlet.http.HttpServletResponse.SC_NOT_FOUND) List(java.util.List) ReadCredentialServlet(org.wildfly.test.security.servlets.ReadCredentialServlet) Deployment(org.jboss.arquillian.container.test.api.Deployment) SC_OK(javax.servlet.http.HttpServletResponse.SC_OK) NameValuePair(org.apache.http.NameValuePair) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Assert.assertEquals(org.junit.Assert.assertEquals) HttpClients(org.apache.http.impl.client.HttpClients) CLIOpResult(org.jboss.as.test.integration.management.util.CLIOpResult)

Example 3 with CLIOpResult

use of org.jboss.as.test.integration.management.util.CLIOpResult in project wildfly by wildfly.

the class CredentialStoreTestCase method testUnmodifiableInternally.

private void testUnmodifiableInternally(final String csName) throws IOException, Exception {
    try (CLIWrapper cli = new CLIWrapper(true)) {
        assertContainsAliases(cli, csName, ALIAS_PASSWORD, ALIAS_SECRET);
        cli.sendLine(String.format("/subsystem=elytron/credential-store=%s/alias=%1$s:add(secret-value=%1$s)", csName), true);
        final CLIOpResult opResult = cli.readAllAsOpResult();
        assertFalse("Adding alias to non-modifiable credential store should fail.", opResult.isIsOutcomeSuccess());
    }
    assertCredentialValue(csName, ALIAS_PASSWORD, "password");
    assertCredentialValue(csName, ALIAS_SECRET, "secret");
    assertCredentialNotFound(csName, csName);
}
Also used : CLIWrapper(org.jboss.as.test.integration.management.util.CLIWrapper) CLIOpResult(org.jboss.as.test.integration.management.util.CLIOpResult)

Example 4 with CLIOpResult

use of org.jboss.as.test.integration.management.util.CLIOpResult in project wildfly by wildfly.

the class RolloutPlanTestCase method testCleanupConnector.

private void testCleanupConnector(String rolloutPlanId) throws Exception {
    CLIOpResult ret = testRemoveConnector(rolloutPlanId);
    Assert.assertTrue(ret.isIsOutcomeSuccess());
    Assert.assertTrue(getServerStatus("test-one", ret));
    boolean gotNoResponse = false;
    for (String server : new String[] { "main-one", "main-two", "main-three" }) {
        try {
            Assert.assertFalse(getServerStatus(server, ret));
        } catch (NoResponseException e) {
            if (gotNoResponse) {
                throw e;
            }
            gotNoResponse = true;
        }
    }
    Assert.assertTrue("received no response from one server", gotNoResponse);
}
Also used : CLIOpResult(org.jboss.as.test.integration.management.util.CLIOpResult)

Example 5 with CLIOpResult

use of org.jboss.as.test.integration.management.util.CLIOpResult in project wildfly by wildfly.

the class WildCardReadsTestCase method testLenientReadOperationDescription.

/**
     * Tests WFLY-2527 added behavior of supporting read-operation-description for
     * wildcard addresses where there is no generic resource registration for the type
     */
@Test
public void testLenientReadOperationDescription() throws IOException {
    cli.sendLine(String.format(OP_PATTERN, EVICTION, ModelDescriptionConstants.READ_OPERATION_NAMES_OPERATION));
    CLIOpResult opResult = cli.readAllAsOpResult();
    Assert.assertTrue(opResult.isIsOutcomeSuccess());
    for (ModelNode node : opResult.getResponseNode().get(ModelDescriptionConstants.RESULT).asList()) {
        String opPart = String.format(READ_OP_DESC_OP, node.asString());
        cli.sendLine(String.format(OP_PATTERN, EVICTION, opPart));
        opResult = cli.readAllAsOpResult();
        Assert.assertTrue(opResult.isIsOutcomeSuccess());
        ModelNode specific = opResult.getResponseNode().get(ModelDescriptionConstants.RESULT);
        cli.sendLine(String.format(OP_PATTERN, "*", opPart));
        opResult = cli.readAllAsOpResult();
        Assert.assertTrue(opResult.isIsOutcomeSuccess());
        Assert.assertEquals("mismatch for " + node.asString(), specific, opResult.getResponseNode().get(ModelDescriptionConstants.RESULT));
    }
}
Also used : CLIOpResult(org.jboss.as.test.integration.management.util.CLIOpResult) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Aggregations

CLIOpResult (org.jboss.as.test.integration.management.util.CLIOpResult)27 Test (org.junit.Test)13 Map (java.util.Map)6 RolloutPlanBuilder (org.jboss.as.test.integration.domain.management.util.RolloutPlanBuilder)3 CLIWrapper (org.jboss.as.test.integration.management.util.CLIWrapper)3 ModelNode (org.jboss.dmr.ModelNode)2 WebArchive (org.jboss.shrinkwrap.api.spec.WebArchive)2 File (java.io.File)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 SocketPermission (java.net.SocketPermission)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 StandardCharsets (java.nio.charset.StandardCharsets)1 AllPermission (java.security.AllPermission)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1