use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.
the class WebMigrateTestCase method testMigrateOperation.
@Test
public void testMigrateOperation() throws Exception {
String subsystemXml = readResource("subsystem-migrate-2.2.0.xml");
NewSubsystemAdditionalInitialization additionalInitialization = new NewSubsystemAdditionalInitialization();
KernelServices services = createKernelServicesBuilder(additionalInitialization).setSubsystemXml(subsystemXml).build();
ModelNode model = services.readWholeModel();
assertFalse(additionalInitialization.extensionAdded);
assertTrue(model.get(SUBSYSTEM, WebExtension.SUBSYSTEM_NAME).isDefined());
assertFalse(model.get(SUBSYSTEM, UNDERTOW_SUBSYSTEM_NAME).isDefined());
ModelNode migrateOp = new ModelNode();
migrateOp.get(OP).set("migrate");
migrateOp.get(OP_ADDR).add(SUBSYSTEM, WebExtension.SUBSYSTEM_NAME);
checkOutcome(services.executeOperation(migrateOp));
model = services.readWholeModel();
assertTrue(additionalInitialization.extensionAdded);
assertFalse(model.get(SUBSYSTEM, WebExtension.SUBSYSTEM_NAME).isDefined());
assertTrue(model.get(SUBSYSTEM, UNDERTOW_SUBSYSTEM_NAME).isDefined());
//make sure we have an IO subsystem
ModelNode ioSubsystem = model.get(SUBSYSTEM, "io");
assertTrue(ioSubsystem.isDefined());
assertTrue(ioSubsystem.get("worker", "default").isDefined());
assertTrue(ioSubsystem.get("buffer-pool", "default").isDefined());
ModelNode newSubsystem = model.get(SUBSYSTEM, UNDERTOW_SUBSYSTEM_NAME);
ModelNode newServer = newSubsystem.get("server", "default-server");
assertNotNull(newServer);
assertTrue(newServer.isDefined());
assertEquals("default-host", newServer.get(Constants.DEFAULT_HOST).asString());
//servlet container
ModelNode servletContainer = newSubsystem.get(Constants.SERVLET_CONTAINER, "default");
assertNotNull(servletContainer);
assertTrue(servletContainer.isDefined());
assertEquals("${prop.default-session-timeout:30}", servletContainer.get(Constants.DEFAULT_SESSION_TIMEOUT).asString());
assertEquals("${prop.listings:true}", servletContainer.get(Constants.DIRECTORY_LISTING).asString());
//jsp settings
ModelNode jsp = servletContainer.get(Constants.SETTING, Constants.JSP);
assertNotNull(jsp);
assertEquals("${prop.recompile-on-fail:true}", jsp.get(Constants.RECOMPILE_ON_FAIL).asString());
//welcome file
ModelNode welcome = servletContainer.get(Constants.WELCOME_FILE, "toto");
assertTrue(welcome.isDefined());
//mime mapping
ModelNode mimeMapping = servletContainer.get(Constants.MIME_MAPPING, "ogx");
assertTrue(mimeMapping.isDefined());
assertEquals("application/ogg", mimeMapping.get(Constants.VALUE).asString());
//http connector
ModelNode connector = newServer.get(Constants.HTTP_LISTENER, "http");
assertTrue(connector.isDefined());
assertEquals("http", connector.get(Constants.SOCKET_BINDING).asString());
assertEquals("${prop.enabled:true}", connector.get(Constants.ENABLED).asString());
assertEquals("${prop.enable-lookups:false}", connector.get(Constants.RESOLVE_PEER_ADDRESS).asString());
assertEquals("${prop.max-post-size:2097153}", connector.get(Constants.MAX_POST_SIZE).asString());
assertEquals("https", connector.get(Constants.REDIRECT_SOCKET).asString());
//https connector
ModelNode httpsConnector = newServer.get(Constants.HTTPS_LISTENER, "https");
String realmName = httpsConnector.get(Constants.SECURITY_REALM).asString();
assertTrue(realmName, realmName.startsWith("jbossweb-migration-security-realm"));
assertEquals("${prop.session-cache-size:512}", httpsConnector.get(Constants.SSL_SESSION_CACHE_SIZE).asString());
assertEquals("REQUESTED", httpsConnector.get(Constants.VERIFY_CLIENT).asString());
//realm name is dynamic
ModelNode realm = model.get(CORE_SERVICE, MANAGEMENT).get(SECURITY_REALM, realmName);
//trust store
ModelNode trustStore = realm.get(AUTHENTICATION, TRUSTSTORE);
assertEquals("${file-base}/jsse.keystore", trustStore.get(KeystoreAttributes.KEYSTORE_PATH.getName()).asString());
//Valves
ModelNode filters = newSubsystem.get(Constants.CONFIGURATION, Constants.FILTER);
ModelNode dumpFilter = filters.get("expression-filter", "request-dumper");
assertEquals("dump-request", dumpFilter.get("expression").asString());
validateExpressionFilter(dumpFilter);
ModelNode remoteAddrFilter = filters.get("expression-filter", "remote-addr");
assertEquals("access-control(acl={'192.168.1.20 deny', '127.0.0.1 allow', '127.0.0.2 allow'} , attribute=%a)", remoteAddrFilter.get("expression").asString());
validateExpressionFilter(remoteAddrFilter);
ModelNode stuckFilter = filters.get("expression-filter", "stuck");
assertEquals("stuck-thread-detector(threshhold='1000')", stuckFilter.get("expression").asString());
validateExpressionFilter(stuckFilter);
ModelNode proxyFilter = filters.get("expression-filter", "proxy");
assertEquals("regex(pattern=\"proxy1|proxy2\", value=%{i,x-forwarded-for}, full-match=true) and regex(pattern=\"192\\.168\\.0\\.10|192\\.168\\.0\\.11\", value=%{i,x-forwarded-for}, full-match=true) -> proxy-peer-address", proxyFilter.get("expression").asString());
validateExpressionFilter(proxyFilter);
ModelNode crawler = servletContainer.get(Constants.SETTING, Constants.CRAWLER_SESSION_MANAGEMENT);
assertTrue(crawler.isDefined());
assertEquals(1, crawler.get(Constants.SESSION_TIMEOUT).asInt());
assertEquals("Google", crawler.get(Constants.USER_AGENTS).asString());
//virtual host
ModelNode virtualHost = newServer.get(Constants.HOST, "default-host");
//welcome content
assertEquals("welcome-content", virtualHost.get("location", "/").get(Constants.HANDLER).asString());
assertEquals("localhost", virtualHost.get("alias").asList().get(0).asString());
assertTrue(virtualHost.hasDefined(Constants.FILTER_REF, "request-dumper"));
assertTrue(virtualHost.hasDefined(Constants.FILTER_REF, "remote-addr"));
assertTrue(virtualHost.hasDefined(Constants.FILTER_REF, "proxy"));
assertTrue(virtualHost.hasDefined(Constants.FILTER_REF, "stuck"));
assertFalse(virtualHost.hasDefined(Constants.FILTER_REF, "myvalve"));
ModelNode accessLog = virtualHost.get(Constants.SETTING, Constants.ACCESS_LOG);
assertEquals("prefix", accessLog.get(Constants.PREFIX).asString());
assertEquals("true", accessLog.get(Constants.ROTATE).asString());
assertEquals("extended", accessLog.get(Constants.PATTERN).asString());
assertEquals("toto", accessLog.get(Constants.DIRECTORY).asString());
assertEquals("jboss.server.base.dir", accessLog.get(Constants.RELATIVE_TO).asString());
//sso
ModelNode sso = virtualHost.get(Constants.SETTING, Constants.SINGLE_SIGN_ON);
assertEquals("${prop.domain:myDomain}", sso.get(Constants.DOMAIN).asString());
assertEquals("${prop.http-only:true}", sso.get(Constants.HTTP_ONLY).asString());
//global access log valve
virtualHost = newServer.get(Constants.HOST, "vs1");
assertTrue(virtualHost.hasDefined(Constants.FILTER_REF, "request-dumper"));
assertTrue(virtualHost.hasDefined(Constants.FILTER_REF, "remote-addr"));
assertFalse(virtualHost.hasDefined(Constants.FILTER_REF, "myvalve"));
assertTrue(virtualHost.hasDefined(Constants.FILTER_REF, "proxy"));
assertTrue(virtualHost.hasDefined(Constants.FILTER_REF, "stuck"));
accessLog = virtualHost.get(Constants.SETTING, Constants.ACCESS_LOG);
assertEquals("myapp_access_log.", accessLog.get(Constants.PREFIX).asString());
assertEquals(".log", accessLog.get(Constants.SUFFIX).asString());
assertEquals("true", accessLog.get(Constants.ROTATE).asString());
assertEquals("common", accessLog.get(Constants.PATTERN).asString());
assertEquals("${jboss.server.log.dir}", accessLog.get(Constants.DIRECTORY).asString());
assertEquals("exists(%{r,log-enabled})", accessLog.get(Constants.PREDICATE).asString());
//proxy valve
virtualHost = newServer.get(Constants.HOST, "vs1");
assertTrue(virtualHost.hasDefined(Constants.FILTER_REF, "request-dumper"));
assertTrue(virtualHost.hasDefined(Constants.FILTER_REF, "remote-addr"));
assertFalse(virtualHost.hasDefined(Constants.FILTER_REF, "myvalve"));
assertTrue(virtualHost.hasDefined(Constants.FILTER_REF, "proxy"));
assertTrue(virtualHost.hasDefined(Constants.FILTER_REF, "stuck"));
assertEquals("myapp_access_log.", accessLog.get(Constants.PREFIX).asString());
assertEquals(".log", accessLog.get(Constants.SUFFIX).asString());
assertEquals("true", accessLog.get(Constants.ROTATE).asString());
assertEquals("common", accessLog.get(Constants.PATTERN).asString());
assertEquals("${jboss.server.log.dir}", accessLog.get(Constants.DIRECTORY).asString());
assertEquals("exists(%{r,log-enabled})", accessLog.get(Constants.PREDICATE).asString());
}
use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.
the class WebSubsystemTestCase method testRejectingTransformers_1_4_0.
private void testRejectingTransformers_1_4_0(ModelTestControllerVersion controllerVersion) throws Exception {
ModelVersion modelVersion = ModelVersion.create(1, 4, 0);
KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization());
builder.createLegacyKernelServicesBuilder(null, controllerVersion, modelVersion).addMavenResourceURL("org.jboss.as:jboss-as-web:" + controllerVersion.getMavenGavVersion()).setExtensionClassName("org.jboss.as.web.WebExtension").configureReverseControllerCheck(createAdditionalInitialization(), null);
KernelServices mainServices = builder.build();
KernelServices legacyServices = mainServices.getLegacyServices(modelVersion);
Assert.assertTrue("main services did not boot", mainServices.isSuccessfulBoot());
Assert.assertTrue(legacyServices.isSuccessfulBoot());
final PathAddress subsystem = PathAddress.EMPTY_ADDRESS.append("subsystem", "web");
List<ModelNode> xmlOps = builder.parseXmlResource("subsystem-2.2.0.xml");
FailedOperationTransformationConfig config = new FailedOperationTransformationConfig().addFailedAttribute(subsystem, new IntExpressionConfig("default-session-timeout")).addFailedAttribute(subsystem.append("virtual-server", "default-host").append("configuration", "sso"), new BooleanExpressionConfig("http-only"));
ModelTestUtils.checkFailedTransformedBootOperations(mainServices, modelVersion, xmlOps, config);
}
use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.
the class WebSubsystemTestCase method testTransformation_1_4_0.
//no need to test target 6.4 as current == 6.4
private void testTransformation_1_4_0(ModelTestControllerVersion controllerVersion) throws Exception {
ModelVersion modelVersion = ModelVersion.create(1, 4, 0);
String subsystemXml = readResource("subsystem-1.4.0.xml");
KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization()).setSubsystemXml(subsystemXml);
builder.createLegacyKernelServicesBuilder(null, controllerVersion, modelVersion).addMavenResourceURL("org.jboss.as:jboss-as-web:" + controllerVersion.getMavenGavVersion()).setExtensionClassName("org.jboss.as.web.WebExtension").configureReverseControllerCheck(createAdditionalInitialization(), null);
KernelServices mainServices = builder.build();
KernelServices legacyServices = mainServices.getLegacyServices(modelVersion);
Assert.assertTrue(mainServices.isSuccessfulBoot());
Assert.assertTrue(legacyServices.isSuccessfulBoot());
checkSubsystemModelTransformation(mainServices, modelVersion, new ModelFixer.CumulativeModelFixer(SSLConfigurationNameFixer.INSTANCE, AccessLogPrefixFixer_1_2_0.INSTANCE));
}
use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.
the class WebSubsystemTestCase method testRejectingTransformers_1_3_0.
private void testRejectingTransformers_1_3_0(ModelTestControllerVersion controllerVersion) throws Exception {
ModelVersion modelVersion = ModelVersion.create(1, 3, 0);
KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization());
builder.createLegacyKernelServicesBuilder(null, controllerVersion, modelVersion).addMavenResourceURL("org.jboss.as:jboss-as-web:" + controllerVersion.getMavenGavVersion()).setExtensionClassName("org.jboss.as.web.WebExtension").configureReverseControllerCheck(createAdditionalInitialization(), null);
KernelServices mainServices = builder.build();
KernelServices legacyServices = mainServices.getLegacyServices(modelVersion);
Assert.assertTrue("main services did not boot", mainServices.isSuccessfulBoot());
Assert.assertTrue(legacyServices.isSuccessfulBoot());
final PathAddress subsystem = PathAddress.EMPTY_ADDRESS.append("subsystem", "web");
List<ModelNode> xmlOps = builder.parseXmlResource("subsystem-2.2.0.xml");
FailedOperationTransformationConfig config = new FailedOperationTransformationConfig().addFailedAttribute(subsystem, new IntExpressionConfig("default-session-timeout")).addFailedAttribute(subsystem.append(PathElement.pathElement("connector", "http")), new FailedOperationTransformationConfig.NewAttributesConfig("redirect-binding", "proxy-binding")).addFailedAttribute(subsystem.append("virtual-server", "default-host").append("configuration", "sso"), new BooleanExpressionConfig("http-only"));
ModelTestUtils.checkFailedTransformedBootOperations(mainServices, modelVersion, xmlOps, config);
checkUndefinedCipherSuite(mainServices, modelVersion);
}
use of org.jboss.as.subsystem.test.KernelServices in project wildfly by wildfly.
the class SingletonSubsystemParsingTestCase method testParseAndMarshalModel.
/**
* Starts a controller with a given subsystem xml and then checks that a second controller
* started with the xml marshalled from the first one results in the same model
*/
@Test
public void testParseAndMarshalModel() throws Exception {
KernelServices services = this.buildKernelServices();
ModelNode modelA = services.readWholeModel();
String marshalled = services.getPersistedSubsystemXml();
ModelNode modelB = this.buildKernelServices(marshalled).readWholeModel();
this.compare(modelA, modelB);
}
Aggregations