Search in sources :

Example 76 with FaultMessage

use of com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage in project midpoint by Evolveum.

the class TestSanityLegacy method test004Capabilities.

@Test
public void test004Capabilities() throws ObjectNotFoundException, CommunicationException, SchemaException, FaultMessage {
    TestUtil.displayTestTile("test004Capabilities");
    // GIVEN
    checkRepoOpenDjResource();
    assertNoRepoCache();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    Holder<ObjectType> objectHolder = new Holder<ObjectType>();
    SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType();
    // WHEN
    modelWeb.getObject(ObjectTypes.RESOURCE.getTypeQName(), RESOURCE_OPENDJ_OID, options, objectHolder, resultHolder);
    ResourceType resource = (ResourceType) objectHolder.value;
    // THEN
    display("Resource", resource);
    assertNoRepoCache();
    CapabilityCollectionType nativeCapabilities = resource.getCapabilities().getNative();
    List<Object> capabilities = nativeCapabilities.getAny();
    assertFalse("Empty capabilities returned", capabilities.isEmpty());
    for (Object capability : nativeCapabilities.getAny()) {
        System.out.println("Native Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability);
    }
    if (resource.getCapabilities() != null) {
        for (Object capability : resource.getCapabilities().getConfigured().getAny()) {
            System.out.println("Configured Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability);
        }
    }
    List<Object> effectiveCapabilities = ResourceTypeUtil.getEffectiveCapabilities(resource);
    for (Object capability : effectiveCapabilities) {
        System.out.println("Efective Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability);
    }
    CredentialsCapabilityType capCred = CapabilityUtil.getCapability(capabilities, CredentialsCapabilityType.class);
    assertNotNull("password capability not present", capCred.getPassword());
    // Connector cannot do activation, this should be null
    ActivationCapabilityType capAct = CapabilityUtil.getCapability(capabilities, ActivationCapabilityType.class);
    assertNull("Found activation capability while not expecting it", capAct);
    capCred = ResourceTypeUtil.getEffectiveCapability(resource, CredentialsCapabilityType.class);
    assertNotNull("password capability not found", capCred.getPassword());
    // Although connector does not support activation, the resource specifies a way how to simulate it.
    // Therefore the following should succeed
    capAct = ResourceTypeUtil.getEffectiveCapability(resource, ActivationCapabilityType.class);
    assertNotNull("activation capability not found", capAct);
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) GenericObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType) CapabilityCollectionType(com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) ActivationCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType) Holder(javax.xml.ws.Holder) CredentialsCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 77 with FaultMessage

use of com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage in project midpoint by Evolveum.

the class AbstractWebserviceTest method assertFaultMessage.

protected <F extends FaultType> void assertFaultMessage(FaultMessage fault, Class<F> expectedFaultInfoClass, String expectedMessage) {
    FaultType faultInfo = fault.getFaultInfo();
    assertNotNull("No fault info in " + fault);
    if (expectedFaultInfoClass != null && !expectedFaultInfoClass.isAssignableFrom(faultInfo.getClass())) {
        AssertJUnit.fail("Expected that faultInfo will be of type " + expectedFaultInfoClass + ", but it was " + faultInfo.getClass());
    }
    if (expectedMessage != null) {
        assertTrue("Wrong message in fault: " + fault.getMessage(), fault.getMessage().contains(expectedMessage));
        assertTrue("Wrong message in fault info: " + faultInfo.getMessage(), faultInfo.getMessage().contains(expectedMessage));
    }
    OperationResultType result = faultInfo.getOperationResult();
    assertNotNull("No result in faultInfo in " + fault, result);
    assertEquals("Expected that resut in FaultInfo will be fatal error, but it was " + result.getStatus(), OperationResultStatusType.FATAL_ERROR, result.getStatus());
}
Also used : FaultType(com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultType)

Example 78 with FaultMessage

use of com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage in project midpoint by Evolveum.

the class AbstractWebserviceTest method checkAuditEnabled.

private void checkAuditEnabled(SystemConfigurationType configurationType) throws FaultMessage {
    LoggingConfigurationType loggingConfig = configurationType.getLogging();
    AuditingConfigurationType auditConfig = loggingConfig.getAuditing();
    if (auditConfig == null) {
        auditConfig = new AuditingConfigurationType();
        auditConfig.setEnabled(true);
        loggingConfig.setAuditing(auditConfig);
    } else {
        if (BooleanUtils.isTrue(auditConfig.isEnabled())) {
            return;
        }
        auditConfig.setEnabled(true);
    }
    ObjectDeltaListType deltaList = ModelClientUtil.createModificationDeltaList(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), "logging", ModificationTypeType.REPLACE, loggingConfig);
    ObjectDeltaOperationListType deltaOpList = modelPort.executeChanges(deltaList, null);
    assertSuccess(deltaOpList);
}
Also used : ObjectDeltaOperationListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)

Example 79 with FaultMessage

use of com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage in project midpoint by Evolveum.

the class AbstractWebserviceTest method addObject.

protected <O extends ObjectType> String addObject(O object) throws FaultMessage {
    ObjectDeltaListType deltaList = new ObjectDeltaListType();
    ObjectDeltaType delta = new ObjectDeltaType();
    delta.setObjectType(getTypeQName(object.getClass()));
    delta.setChangeType(ChangeTypeType.ADD);
    delta.setObjectToAdd(object);
    deltaList.getDelta().add(delta);
    ObjectDeltaOperationListType deltaOpList = modelPort.executeChanges(deltaList, null);
    assertSuccess(deltaOpList);
    return deltaOpList.getDeltaOperation().get(0).getObjectDelta().getOid();
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) ObjectDeltaOperationListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)

Example 80 with FaultMessage

use of com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage in project midpoint by Evolveum.

the class TestWSSecurity method test162ChangeDarthAdderPasswordViolatesPolicy.

@Test
public void test162ChangeDarthAdderPasswordViolatesPolicy() throws Exception {
    final String TEST_NAME = "test162ChangeDarthAdderPasswordViolatesPolicy";
    displayTestTitle(TEST_NAME);
    LogfileTestTailer tailer = createLogTailer();
    ProtectedStringType protectedString = ModelClientUtil.createProtectedString("x");
    ObjectDeltaListType deltaList = ModelClientUtil.createModificationDeltaList(UserType.class, USER_DARTHADDER_OID, "credentials/password/value", ModificationTypeType.REPLACE, protectedString);
    try {
        // WHEN
        modelPort.executeChanges(deltaList, null);
        AssertJUnit.fail("Unexpected success");
    } catch (FaultMessage e) {
        assertFaultMessage(e, PolicyViolationFaultType.class, "password does not satisfy password policies");
    }
    // THEN
    tailer.tail();
    displayAudit(tailer);
    assertAuditLoginLogout(tailer);
    assertAuditIds(tailer);
    assertAuditOperation(tailer, "MODIFY_OBJECT", OperationResultStatusType.FATAL_ERROR, "password does not satisfy password policies");
    tailer.assertAudit(4);
    UserType user = getObject(UserType.class, USER_DARTHADDER_OID);
    display(user);
    PasswordType dartAdderPassword = user.getCredentials().getPassword();
    assertEquals("Password of DarthAdder has changed", ModelClientUtil.marshallToSting(new QName("http://whatever/", "fake"), dartAdderLastPassword, false), ModelClientUtil.marshallToSting(new QName("http://whatever/", "fake"), dartAdderPassword, false));
    assertPasswordModifyMetadata(user, USER_DARTHADDER_OID, dartAdderLastPasswordChangeStartTs, dartAdderLastPasswordChangeEndTs);
}
Also used : LogfileTestTailer(com.evolveum.midpoint.test.util.LogfileTestTailer) FaultMessage(com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage) QName(javax.xml.namespace.QName) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) PasswordType(com.evolveum.midpoint.xml.ns._public.common.common_3.PasswordType) PolicyViolationFaultType(com.evolveum.midpoint.xml.ns._public.common.fault_3.PolicyViolationFaultType) Test(org.testng.annotations.Test)

Aggregations

OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)46 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)36 ObjectDeltaListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)33 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)32 Holder (javax.xml.ws.Holder)32 SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)25 ObjectDeltaOperationListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType)22 FaultMessage (com.evolveum.midpoint.xml.ns._public.common.fault_3.FaultMessage)22 Test (org.testng.annotations.Test)22 ObjectListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)21 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)17 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)16 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)16 QName (javax.xml.namespace.QName)15 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)13 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)13 Document (org.w3c.dom.Document)13 ModelExecuteOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.ModelExecuteOptionsType)10 QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)10 ItemDeltaType (com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)10