Search in sources :

Example 41 with LogfileTestTailer

use of com.evolveum.midpoint.test.util.LogfileTestTailer in project midpoint by Evolveum.

the class TestWSSecurity method test161ChangeDarthAdderPasswordSatisfiesPolicyStrict.

@Test
public void test161ChangeDarthAdderPasswordSatisfiesPolicyStrict() throws Exception {
    final String TEST_NAME = "test160ChangeDarthAdderPasswordSatisfiesPolicyShortcut";
    displayTestTitle(TEST_NAME);
    LogfileTestTailer tailer = createLogTailer();
    ProtectedStringType protectedString = ModelClientUtil.createProtectedString(USER_DARTHADDER_PASSWORD_NEW2);
    ObjectDeltaListType deltaList = ModelClientUtil.createModificationDeltaList(UserType.class, USER_DARTHADDER_OID, "credentials/password/value", ModificationTypeType.REPLACE, protectedString);
    dartAdderLastPasswordChangeStartTs = TestUtil.currentTime();
    // WHEN
    ObjectDeltaOperationListType deltaOpList = modelPort.executeChanges(deltaList, null);
    // THEN
    assertSuccess(deltaOpList);
    dartAdderLastPasswordChangeEndTs = TestUtil.currentTime();
    tailer.tail();
    displayAudit(tailer);
    assertAuditLoginLogout(tailer);
    assertAuditIds(tailer);
    assertAuditOperation(tailer, "MODIFY_OBJECT");
    tailer.assertAudit(4);
    modelPort = createModelPort(USER_DARTHADDER_USERNAME, USER_DARTHADDER_PASSWORD_NEW2, WSConstants.PW_DIGEST);
    UserType user = getObject(UserType.class, USER_DARTHADDER_OID);
    display(user);
    dartAdderLastPassword = user.getCredentials().getPassword();
    assertNotNull("No password for DarthAdder", dartAdderLastPassword);
    assertPasswordModifyMetadata(user, USER_DARTHADDER_OID, dartAdderLastPasswordChangeStartTs, dartAdderLastPasswordChangeEndTs);
}
Also used : LogfileTestTailer(com.evolveum.midpoint.test.util.LogfileTestTailer) ObjectDeltaOperationListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType) 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) Test(org.testng.annotations.Test)

Example 42 with LogfileTestTailer

use of com.evolveum.midpoint.test.util.LogfileTestTailer in project midpoint by Evolveum.

the class TestWSSecurity method test135ModifyConfigAsDarthAdder.

@Test
public void test135ModifyConfigAsDarthAdder() throws Exception {
    final String TEST_NAME = "test135ModifyConfigAsDarthAdder";
    displayTestTitle(TEST_NAME);
    LogfileTestTailer tailer = createLogTailer();
    ObjectReferenceType ref = new ObjectReferenceType();
    // fake
    ref.setOid("c4e998e6-d903-11e4-9aaf-001e8c717e5b");
    ObjectDeltaListType deltaList = ModelClientUtil.createModificationDeltaList(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), "globalSecurityPolicyRef", ModificationTypeType.REPLACE, ref);
    try {
        // WHEN
        modelPort.executeChanges(deltaList, null);
        AssertJUnit.fail("Unexpected success");
    } catch (SOAPFaultException e) {
        assertSoapFault(e, "FailedAuthentication", "could not be authenticated or authorized");
    }
    // THEN
    tailer.tail();
    displayAudit(tailer);
    assertAuditLoginLogout(tailer);
    assertAuditIds(tailer);
    assertAuditOperation(tailer, "MODIFY_OBJECT", OperationResultStatusType.FATAL_ERROR, "not authorized");
    tailer.assertAudit(4);
}
Also used : LogfileTestTailer(com.evolveum.midpoint.test.util.LogfileTestTailer) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType) Test(org.testng.annotations.Test)

Example 43 with LogfileTestTailer

use of com.evolveum.midpoint.test.util.LogfileTestTailer in project midpoint by Evolveum.

the class TestCleanStartup method test001Logfiles.

// work in progress
@Test
public void test001Logfiles() throws Exception {
    TestUtil.displayTestTile("test001Logfiles");
    // GIVEN - system startup and initialization that has already happened
    LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME, false);
    // THEN
    display("Tailing ...");
    tailer.tail();
    display("... done");
    display("Errors", tailer.getErrors());
    display("Warnings", tailer.getWarnings());
    assertMessages("Error", tailer.getErrors(), "Unable to find file com/../../keystore.jceks", "Provided Icf connector path /C:/tmp is not a directory", "Provided Icf connector path C:\\tmp is not a directory", "Provided Icf connector path C:\\var\\tmp is not a directory", "Provided Icf connector path D:\\var\\tmp is not a directory");
    assertMessages("Warning", tailer.getWarnings());
    tailer.close();
}
Also used : LogfileTestTailer(com.evolveum.midpoint.test.util.LogfileTestTailer) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 44 with LogfileTestTailer

use of com.evolveum.midpoint.test.util.LogfileTestTailer in project midpoint by Evolveum.

the class TestLoggingConfiguration method test004OverwriteInitialConfiguration.

/**
	 * Overwrite initial system configuration by itself. Check that everything
	 * still works.
	 */
@Test
public void test004OverwriteInitialConfiguration() throws Exception {
    final String TEST_NAME = "test004OverwriteInitialConfiguration";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME);
    Task task = taskManager.createTaskInstance(TestLoggingConfiguration.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    PrismObject<SystemConfigurationType> systemConfiguration = getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value());
    String previousVersion = systemConfiguration.getVersion();
    systemConfiguration.setVersion(null);
    // precondition
    tailer.logAndTail();
    assertBasicLogging(tailer);
    tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_TRACE, ProfilingDataManager.Subsystem.PROVISIONING.name());
    ObjectDelta<SystemConfigurationType> delta = ObjectDelta.createAddDelta(systemConfiguration);
    ModelExecuteOptions options = ModelExecuteOptions.createOverwrite();
    // WHEN
    modelService.executeChanges(MiscSchemaUtil.createCollection(delta), options, task, result);
    // THEN
    result.computeStatus();
    TestUtil.assertSuccess(result);
    tailer.logAndTail();
    assertBasicLogging(tailer);
    tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_TRACE, ProfilingDataManager.Subsystem.PROVISIONING.name());
    tailer.close();
    PrismObject<SystemConfigurationType> systemConfigurationNew = getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value());
    String newVersion = systemConfigurationNew.getVersion();
    assertTrue("Versions do not follow: " + previousVersion + " -> " + newVersion, Integer.parseInt(previousVersion) < Integer.parseInt(newVersion));
}
Also used : LogfileTestTailer(com.evolveum.midpoint.test.util.LogfileTestTailer) Task(com.evolveum.midpoint.task.api.Task) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) Test(org.testng.annotations.Test)

Example 45 with LogfileTestTailer

use of com.evolveum.midpoint.test.util.LogfileTestTailer in project midpoint by Evolveum.

the class TestLoggingConfiguration method test101EnableBasicAudit.

@Test
public void test101EnableBasicAudit() throws Exception {
    TestUtil.displayTestTile("test101EnableBasicAudit");
    // GIVEN
    LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME);
    Task task = taskManager.createTaskInstance(TestLoggingConfiguration.class.getName() + ".test101EnableBasicAudit");
    OperationResult result = task.getResult();
    // Precondition
    tailer.tail();
    tailer.assertNoAudit();
    // Setup
    PrismObject<SystemConfigurationType> systemConfiguration = PrismTestUtil.parseObject(AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_FILE);
    LoggingConfigurationType logging = systemConfiguration.asObjectable().getLogging();
    applyTestLoggingConfig(logging);
    AuditingConfigurationType auditingConfigurationType = logging.getAuditing();
    if (auditingConfigurationType == null) {
        auditingConfigurationType = new AuditingConfigurationType();
        logging.setAuditing(auditingConfigurationType);
    }
    auditingConfigurationType.setEnabled(true);
    auditingConfigurationType.setDetails(false);
    ObjectDelta<SystemConfigurationType> systemConfigDelta = ObjectDelta.createModificationReplaceProperty(SystemConfigurationType.class, AbstractInitializedModelIntegrationTest.SYSTEM_CONFIGURATION_OID, SystemConfigurationType.F_LOGGING, prismContext, logging);
    Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(systemConfigDelta);
    // WHEN
    modelService.executeChanges(deltas, null, task, result);
    // Make sure that the (optional) audit message from the above change will not get into the way
    tailer.tail();
    tailer.reset();
    // This message will appear in the log and will help diagnose problems
    display("TEST: Applied audit config, going to execute test change");
    // try do execute some change (add user object), it should be audited
    PrismObject<UserType> user = PrismTestUtil.parseObject(AbstractInitializedModelIntegrationTest.USER_JACK_FILE);
    deltas = MiscSchemaUtil.createCollection(ObjectDelta.createAddDelta(user));
    modelService.executeChanges(deltas, null, task, result);
    // This message will appear in the log and will help diagnose problems
    display("TEST: Executed test change");
    // THEN
    tailer.tail();
    tailer.assertAudit(2);
    tailer.assertAuditRequest();
    tailer.assertAuditExecution();
    tailer.close();
}
Also used : LogfileTestTailer(com.evolveum.midpoint.test.util.LogfileTestTailer) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) AuditingConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.AuditingConfigurationType) LoggingConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Aggregations

LogfileTestTailer (com.evolveum.midpoint.test.util.LogfileTestTailer)48 Test (org.testng.annotations.Test)48 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)28 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)26 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)21 Holder (javax.xml.ws.Holder)21 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)21 ObjectDeltaListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)13 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)11 ObjectDeltaOperationListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType)9 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)8 Task (com.evolveum.midpoint.task.api.Task)8 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)5 LoggingConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingConfigurationType)5 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)5 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)3 ProtectedStringType (com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)3 ClassLoggerConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ClassLoggerConfigurationType)2 SubSystemLoggerConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SubSystemLoggerConfigurationType)2 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)2