Search in sources :

Example 36 with KernelServicesBuilder

use of org.jboss.as.subsystem.test.KernelServicesBuilder in project wildfly by wildfly.

the class MessagingSubsystem30TestCase method testRejectExpressionsEAP_6_2_0.

@Test
public void testRejectExpressionsEAP_6_2_0() throws Exception {
    KernelServicesBuilder builder = createKernelServicesBuilder(EAP_6_2_0, VERSION_1_3_0, PATH_FIXER, "empty_subsystem_3_0.xml");
    doTestRejectExpressions_1_3_0(builder);
}
Also used : KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder) Test(org.junit.Test)

Example 37 with KernelServicesBuilder

use of org.jboss.as.subsystem.test.KernelServicesBuilder in project wildfly by wildfly.

the class MessagingSubsystem30TestCase method testRejectExpressionsEAP_6_4_0.

@Test
public void testRejectExpressionsEAP_6_4_0() throws Exception {
    KernelServicesBuilder builder = createKernelServicesBuilder(EAP_6_4_0, VERSION_1_4_0, PATH_FIXER, "empty_subsystem_3_0.xml");
    doTestRejectExpressions_1_4_0(builder);
}
Also used : KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder) Test(org.junit.Test)

Example 38 with KernelServicesBuilder

use of org.jboss.as.subsystem.test.KernelServicesBuilder in project wildfly by wildfly.

the class RoleGeneratorDeclarationUnitTestCase method testSubsystem.

@Test
public void testSubsystem() throws Exception {
    System.setProperty("jboss.server.data.dir", System.getProperty("java.io.tmpdir"));
    System.setProperty("jboss.home.dir", System.getProperty("java.io.tmpdir"));
    System.setProperty("jboss.server.server.dir", System.getProperty("java.io.tmpdir"));
    KernelServicesBuilder builder = createKernelServicesBuilder(new AdditionalInitialization() {

        @Override
        protected RunningMode getRunningMode() {
            return RunningMode.NORMAL;
        }

        @Override
        protected void setupController(ControllerInitializer controllerInitializer) {
            super.setupController(controllerInitializer);
            controllerInitializer.addPath("jboss.server.data.dir", System.getProperty("java.io.tmpdir"), null);
        }
    }).setSubsystemXml(getSubsystemXml());
    KernelServices mainServices = builder.build();
    assertFalse(mainServices.isSuccessfulBoot());
}
Also used : KernelServices(org.jboss.as.subsystem.test.KernelServices) ControllerInitializer(org.jboss.as.subsystem.test.ControllerInitializer) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder) AdditionalInitialization(org.jboss.as.subsystem.test.AdditionalInitialization) AbstractSubsystemBaseTest(org.jboss.as.subsystem.test.AbstractSubsystemBaseTest) Test(org.junit.Test)

Example 39 with KernelServicesBuilder

use of org.jboss.as.subsystem.test.KernelServicesBuilder in project wildfly by wildfly.

the class SecurityDomainModelv30UnitTestCase method testTransformers.

private void testTransformers(ModelTestControllerVersion controllerVersion) throws Exception {
    KernelServicesBuilder builder = createKernelServicesBuilder(createAdditionalInitialization());
    ModelVersion version = ModelVersion.create(1, 3, 0);
    final String mavenGavVersion = controllerVersion.getMavenGavVersion();
    final String artifactId;
    if (controllerVersion.isEap() && mavenGavVersion.equals(controllerVersion.getCoreVersion())) {
        /* EAP 6 */
        artifactId = "jboss-as-security";
    } else {
        artifactId = "wildfly-security";
    }
    builder.createLegacyKernelServicesBuilder(AdditionalInitialization.MANAGEMENT, controllerVersion, version).addMavenResourceURL(controllerVersion.getMavenGroupId() + ":" + artifactId + ":" + mavenGavVersion);
    KernelServices mainServices = builder.build();
    assertTrue(mainServices.isSuccessfulBoot());
    KernelServices legacyServices = mainServices.getLegacyServices(version);
    assertNotNull(legacyServices);
    assertTrue(legacyServices.isSuccessfulBoot());
    // any elytron-related resources in the model should get rejected as those are not supported in model version 1.3.0.
    PathAddress subsystemAddress = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, getMainSubsystemName()));
    ModelTestUtils.checkFailedTransformedBootOperations(mainServices, version, builder.parseXmlResource("securitysubsystemv30.xml"), new FailedOperationTransformationConfig().addFailedAttribute(PathAddress.pathAddress(subsystemAddress, PathElement.pathElement(Constants.ELYTRON_REALM)), FailedOperationTransformationConfig.REJECTED_RESOURCE).addFailedAttribute(PathAddress.pathAddress(subsystemAddress, PathElement.pathElement(Constants.ELYTRON_KEY_STORE)), FailedOperationTransformationConfig.REJECTED_RESOURCE).addFailedAttribute(PathAddress.pathAddress(subsystemAddress, PathElement.pathElement(Constants.ELYTRON_TRUST_STORE)), FailedOperationTransformationConfig.REJECTED_RESOURCE).addFailedAttribute(PathAddress.pathAddress(subsystemAddress, PathElement.pathElement(Constants.ELYTRON_KEY_MANAGER)), FailedOperationTransformationConfig.REJECTED_RESOURCE).addFailedAttribute(PathAddress.pathAddress(subsystemAddress, PathElement.pathElement(Constants.ELYTRON_TRUST_MANAGER)), FailedOperationTransformationConfig.REJECTED_RESOURCE).addFailedAttribute(PathAddress.pathAddress(subsystemAddress, PathElement.pathElement(Constants.SECURITY_DOMAIN, "domain-with-custom-audit-provider"), SecurityExtension.PATH_AUDIT_CLASSIC, PathElement.pathElement(Constants.PROVIDER_MODULE, "org.myorg.security.MyCustomLogAuditProvider")), new FailedOperationTransformationConfig.NewAttributesConfig(Constants.MODULE)).addFailedAttribute(PathAddress.pathAddress(subsystemAddress, PathElement.pathElement(Constants.SECURITY_MANAGEMENT)), new FailedOperationTransformationConfig.NewAttributesConfig(Constants.INITIALIZE_JACC)));
}
Also used : FailedOperationTransformationConfig(org.jboss.as.model.test.FailedOperationTransformationConfig) PathAddress(org.jboss.as.controller.PathAddress) KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelVersion(org.jboss.as.controller.ModelVersion) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder)

Example 40 with KernelServicesBuilder

use of org.jboss.as.subsystem.test.KernelServicesBuilder in project wildfly by wildfly.

the class MailSubsystem21TestCase method testOperations.

@Test
public void testOperations() throws Exception {
    KernelServicesBuilder builder = createKernelServicesBuilder(new MailSubsystem10TestCase.Initializer()).setSubsystemXml(getSubsystemXml());
    KernelServices mainServices = builder.build();
    if (!mainServices.isSuccessfulBoot()) {
        Assert.fail(mainServices.getBootError().toString());
    }
    PathAddress sessionAddress = PathAddress.pathAddress(MailExtension.SUBSYSTEM_PATH, PathElement.pathElement(MailExtension.MAIL_SESSION_PATH.getKey(), "defaultMail"));
    ModelNode result;
    ModelNode removeServerOp = Util.createRemoveOperation(sessionAddress.append("server", "imap"));
    removeServerOp.get(OPERATION_HEADERS).get(ALLOW_RESOURCE_SERVICE_RESTART).set(true);
    result = mainServices.executeOperation(removeServerOp);
    checkResult(result);
    ModelNode addServerOp = Util.createAddOperation(sessionAddress.append("server", "imap"));
    addServerOp.get(OPERATION_HEADERS).get(ALLOW_RESOURCE_SERVICE_RESTART).set(true);
    addServerOp.get("outbound-socket-binding-ref").set("mail-imap");
    addServerOp.get("username").set("user");
    addServerOp.get("password").set("pswd");
    result = mainServices.executeOperation(addServerOp);
    checkResult(result);
    //to make sure noting is left behind
    checkResult(mainServices.executeOperation(removeServerOp));
    checkResult(mainServices.executeOperation(addServerOp));
    ModelNode writeOp = Util.createEmptyOperation(WRITE_ATTRIBUTE_OPERATION, sessionAddress);
    writeOp.get(OPERATION_HEADERS).get(ALLOW_RESOURCE_SERVICE_RESTART).set(true);
    writeOp.get("name").set("debug");
    writeOp.get("value").set(false);
    result = mainServices.executeOperation(writeOp);
    checkResult(result);
    ServiceController<?> javaMailService = mainServices.getContainer().getService(MailSessionAdd.MAIL_SESSION_SERVICE_NAME.append("defaultMail"));
    javaMailService.setMode(ServiceController.Mode.ACTIVE);
    Session session = (Session) javaMailService.getValue();
    Assert.assertNotNull("session should not be null", session);
    Properties properties = session.getProperties();
    Assert.assertNotNull("smtp host should be set", properties.getProperty("mail.smtp.host"));
    Assert.assertNotNull("imap host should be set", properties.getProperty("mail.imap.host"));
    PathAddress nonExisting = PathAddress.pathAddress(MailExtension.SUBSYSTEM_PATH, PathElement.pathElement(MailExtension.MAIL_SESSION_PATH.getKey(), "non-existing-session"));
    ModelNode addSession = Util.createAddOperation(nonExisting);
    addSession.get("jndi-name").set("java:/bah");
    checkResult(mainServices.executeOperation(addSession));
    removeServerOp = Util.createRemoveOperation(nonExisting.append("server", "imap"));
    //removeServerOp.get(OPERATION_HEADERS).get(ALLOW_RESOURCE_SERVICE_RESTART).set(true);
    result = mainServices.executeOperation(removeServerOp);
    checkForFailure(result);
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) KernelServices(org.jboss.as.subsystem.test.KernelServices) ModelNode(org.jboss.dmr.ModelNode) Properties(java.util.Properties) KernelServicesBuilder(org.jboss.as.subsystem.test.KernelServicesBuilder) Session(javax.mail.Session) AbstractSubsystemBaseTest(org.jboss.as.subsystem.test.AbstractSubsystemBaseTest) Test(org.junit.Test)

Aggregations

KernelServicesBuilder (org.jboss.as.subsystem.test.KernelServicesBuilder)73 KernelServices (org.jboss.as.subsystem.test.KernelServices)69 ModelNode (org.jboss.dmr.ModelNode)33 ModelVersion (org.jboss.as.controller.ModelVersion)28 Test (org.junit.Test)25 FailedOperationTransformationConfig (org.jboss.as.model.test.FailedOperationTransformationConfig)20 PathAddress (org.jboss.as.controller.PathAddress)13 AbstractSubsystemBaseTest (org.jboss.as.subsystem.test.AbstractSubsystemBaseTest)13 ModelFixer (org.jboss.as.model.test.ModelFixer)7 AdditionalInitialization (org.jboss.as.subsystem.test.AdditionalInitialization)6 ModelTestControllerVersion (org.jboss.as.model.test.ModelTestControllerVersion)5 ControllerInitializer (org.jboss.as.subsystem.test.ControllerInitializer)5 Properties (java.util.Properties)4 Session (javax.mail.Session)4 NewAttributesConfig (org.jboss.as.model.test.FailedOperationTransformationConfig.NewAttributesConfig)2 TransactionLogger (org.jboss.as.txn.logging.TransactionLogger)2 HttpHandler (io.undertow.server.HttpHandler)1 PathHandler (io.undertow.server.handlers.PathHandler)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1