assertEquals(masterModel, slaveModel);
}
@Test
public void test9SecurityTransformers() throws Exception {
final DomainClient masterClient = support.getDomainMasterLifecycleUtil().createDomainClient();
final DomainClient slaveClient = support.getDomainSlaveLifecycleUtil().createDomainClient();
try {
PathAddress subsystem = PathAddress.pathAddress(PathElement.pathElement(PROFILE, getProfile()), PathElement.pathElement(SUBSYSTEM, SecurityExtension.SUBSYSTEM_NAME));
PathAddress webPolicy = subsystem.append(Constants.SECURITY_DOMAIN, "jboss-web-policy").append(Constants.AUTHORIZATION, Constants.CLASSIC);
ModelNode options = new ModelNode();
options.add("a", "b");
ModelNode op = Util.getWriteAttributeOperation(webPolicy.append(Constants.POLICY_MODULE, "Delegating"), Constants.MODULE_OPTIONS, options);
DomainTestUtils.executeForResult(op, masterClient);
//TODO check the resources
//System.out.println(DomainTestUtils.executeForResult(Util.createOperation(READ_RESOURCE_OPERATION, address), modelControllerClient));
PathAddress jaspi = subsystem.append(Constants.SECURITY_DOMAIN, "jaspi-test").append(Constants.AUTHENTICATION, Constants.JASPI);
PathAddress jaspiLoginStack = jaspi.append(Constants.LOGIN_MODULE_STACK, "lm-stack");
op = Util.createAddOperation(jaspiLoginStack.append(Constants.LOGIN_MODULE, "test2"));
op.get(Constants.CODE).set("UserRoles");
op.get(Constants.FLAG).set("required");
op.get(Constants.MODULE).set("test-jaspi");
DomainTestUtils.executeForResult(op, masterClient);
op = Util.createAddOperation(jaspi.append(Constants.AUTH_MODULE, "Delegating"));
op.get(Constants.CODE).set("Delegating");
op.get(Constants.LOGIN_MODULE_STACK_REF).set("lm-stack");
op.get(Constants.FLAG).set("optional");
DomainTestUtils.executeForResult(op, masterClient);
op = new ModelNode();
op.get(OP).set(READ_RESOURCE_OPERATION);
op.get(OP_ADDR).set(jaspi.toModelNode());
op.get(INCLUDE_ALIASES).set(false);
op.get(RECURSIVE).set(true);
ModelNode masterResource = DomainTestUtils.executeForResult(op, masterClient);
ModelNode slaveResource = DomainTestUtils.executeForResult(op, slaveClient);
//TODO only check this for 7.1.x
if (version == Version.AsVersion.AS_7_1_2_FINAL || version == Version.AsVersion.AS_7_1_3_FINAL) {
ModelNode masterModules = masterResource.get(Constants.AUTH_MODULE);
Assert.assertFalse(slaveResource.hasDefined(Constants.AUTH_MODULE));
List<ModelNode> slaveModules = slaveResource.get(Constants.AUTH_MODULES).asList();
Assert.assertEquals(masterModules.keys().size(), slaveModules.size());
Set<ModelNode> masterSet = getAllChildren(masterModules);
Assert.assertTrue(slaveModules.containsAll(masterSet));
masterModules = masterResource.get(Constants.LOGIN_MODULE_STACK, "lm-stack", Constants.LOGIN_MODULE);
Assert.assertFalse(slaveResource.get(Constants.LOGIN_MODULE_STACK, "lm-stack").hasDefined(Constants.LOGIN_MODULE));
slaveModules = slaveResource.get(Constants.LOGIN_MODULE_STACK, "lm-stack", Constants.LOGIN_MODULES).asList();
Assert.assertEquals(masterModules.keys().size(), slaveModules.size());
masterSet = getAllChildren(masterModules);
Assert.assertTrue(slaveModules.containsAll(masterSet));
} else {
ModelTestUtils.compare(masterResource, slaveResource, true);
}
} finally {
try {
//The server will be in restart-required mode, so restart it to get rid of the changes
PathAddress serverAddress = PathAddress.pathAddress(HOST, "slave").append(SERVER_CONFIG, "server-one");
ModelNode op = Util.createOperation(RESTART, PathAddress.pathAddress(serverAddress));
op.get(BLOCKING).set(true);
Assert.assertEquals("STARTED", validateResponse(slaveClient.execute(op), true).asString());
} finally {
IoUtils.safeClose(slaveClient);
IoUtils.safeClose(masterClient);
}
}