use of org.jboss.as.test.integration.management.util.CLIWrapper 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));
}
}
}
use of org.jboss.as.test.integration.management.util.CLIWrapper in project wildfly by wildfly.
the class CredentialStoreI18NTestCase method testAliasesCaseInsensitive.
/**
* Tests for CS aliases case-sensitiveness
*/
@Test
@Ignore("WFLY-8131")
public void testAliasesCaseInsensitive() throws Exception {
try (CLIWrapper cli = new CLIWrapper(true)) {
assertCredentialValue(NAME, UPPER, UPPER);
assertCredentialValue(NAME, LOWER, LOWER);
assertCredentialValue(NAME, UPPER.toLowerCase(Locale.ROOT), UPPER);
assertCredentialValue(NAME, LOWER.toUpperCase(Locale.ROOT), LOWER);
}
}
use of org.jboss.as.test.integration.management.util.CLIWrapper 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);
}
use of org.jboss.as.test.integration.management.util.CLIWrapper in project wildfly by wildfly.
the class RemoveDeploymentPermissionsServerSetupTask method setup.
/*
* (non-Javadoc)
*
* @see org.jboss.as.arquillian.api.ServerSetupTask#setup(org.jboss.as.arquillian.container.ManagementClient,
* java.lang.String)
*/
@Override
public final void setup(final ManagementClient managementClient, String containerId) throws Exception {
if (cli == null) {
cli = new CLIWrapper(true);
}
CLIOpResult result = null;
// remove the deployment permissions
cli.sendLine("/subsystem=security-manager/deployment-permissions=default:remove()");
result = cli.readAllAsOpResult();
assertTrue("Removing deployment-permissions by using management API failed", result.isIsOutcomeSuccess());
// reload the server
LOGGER.debug("Reloading the server");
reload(managementClient);
}
use of org.jboss.as.test.integration.management.util.CLIWrapper in project wildfly by wildfly.
the class AbstractCredentialStoreTestCase method assertAliasAndSecretSupported.
/**
* Creates alias in given credential store (must exist) with provided secret value. Then uses
* {@link #assertCredentialValue(String, String, String)} method to check if it's correctly stored in the credential store.
* It removes the alias as the final step.
*/
protected void assertAliasAndSecretSupported(String storeName, String alias, String secret) throws Exception {
try (CLIWrapper cli = new CLIWrapper(true)) {
try {
cli.sendLine(String.format("/subsystem=elytron/credential-store=%s/alias=%s:add(secret-value=\"%s\"", storeName, alias, secret));
assertCredentialValue(storeName, alias, secret);
} finally {
cli.sendLine(String.format("/subsystem=elytron/credential-store=%s/alias=%s:remove()", storeName, alias));
}
}
}
Aggregations