use of org.jboss.as.test.integration.security.common.VaultHandler in project wildfly by wildfly.
the class RemoveSecuredAttributeTestCase method testRemoveSecuredAttributeByDifferentVaultHandler.
/**
* Test of remove secured attribute with another vault instance
*
* @throws Exception
*/
@Test
public void testRemoveSecuredAttributeByDifferentVaultHandler() throws Exception {
VaultSession vaultSession = vaultHandler.getVaultSession();
String securedAttribute = addSecuredAttributeToDefaultVault(vaultSession, ATTRIBUTE_VALUE);
VaultHandler vaultHandler2 = createDefaultVaultHandler();
VaultSession vaultSession2 = vaultHandler2.getVaultSession();
assertArrayEquals("Retrieved secured attribute differs from the saved", vaultSession2.retrieveSecuredAttribute(VAULT_BLOCK, ATTRIBUTE_NAME), ATTRIBUTE_VALUE);
assertCorrectAttributeRemoval(vaultSession2, securedAttribute);
}
use of org.jboss.as.test.integration.security.common.VaultHandler in project wildfly by wildfly.
the class SlaveHostControllerAuthenticationTestCase method slaveWithVaultPasswordTest.
private void slaveWithVaultPasswordTest() throws Exception {
VaultHandler.cleanFilesystem(RESOURCE_LOCATION, true);
// create new vault
VaultHandler vaultHandler = new VaultHandler(RESOURCE_LOCATION);
try {
// create security attributes
String attributeName = "value";
String vaultPasswordString = vaultHandler.addSecuredAttribute(VAULT_BLOCK, attributeName, RIGHT_PASSWORD.toCharArray());
// create new vault setting in host
ModelNode op = new ModelNode();
op.get(OP).set(ADD);
op.get(OP_ADDR).add(HOST, "slave").add(CORE_SERVICE, VAULT);
ModelNode vaultOption = op.get(VAULT_OPTIONS);
vaultOption.get("KEYSTORE_URL").set(vaultHandler.getKeyStore());
vaultOption.get("KEYSTORE_PASSWORD").set(vaultHandler.getMaskedKeyStorePassword());
vaultOption.get("KEYSTORE_ALIAS").set(vaultHandler.getAlias());
vaultOption.get("SALT").set(vaultHandler.getSalt());
vaultOption.get("ITERATION_COUNT").set(vaultHandler.getIterationCountAsString());
vaultOption.get("ENC_FILE_DIR").set(vaultHandler.getEncodedVaultFileDirectory());
domainSlaveClient.execute(new OperationBuilder(op).build());
setSlaveSecret("${" + vaultPasswordString + "}");
reloadSlave();
// Validate that it joined the master
readHostControllerStatus(domainMasterClient, 0);
} finally {
// remove temporary files
vaultHandler.cleanUp();
}
}
use of org.jboss.as.test.integration.security.common.VaultHandler in project wildfly by wildfly.
the class RemoveSecuredAttributeTestCase method testRemoveSecuredAttributeAndAddDifferent.
/**
* Test of remove secured attribute and then add different secured attribute with the same name to the same vault block
*
* @throws Exception
*/
@Test
public void testRemoveSecuredAttributeAndAddDifferent() throws Exception {
VaultSession vaultSession = vaultHandler.getVaultSession();
String securedAttribute = addSecuredAttributeToDefaultVault(vaultSession, ATTRIBUTE_VALUE);
assertArrayEquals("Retrieved secured attribute differs from the saved", vaultSession.retrieveSecuredAttribute(VAULT_BLOCK, ATTRIBUTE_NAME), ATTRIBUTE_VALUE);
assertCorrectAttributeRemoval(vaultSession, securedAttribute);
VaultHandler vaultHandler2 = createDefaultVaultHandler();
VaultSession vaultSession2 = vaultHandler2.getVaultSession();
securedAttribute = addSecuredAttributeToDefaultVault(vaultSession2, ANOTHER_ATTRIBUTE_VALUE);
assertArrayEquals("Retrieved secured attribute differs from the saved", vaultSession2.retrieveSecuredAttribute(VAULT_BLOCK, ATTRIBUTE_NAME), ANOTHER_ATTRIBUTE_VALUE);
assertCorrectAttributeRemoval(vaultSession2, securedAttribute);
}
Aggregations