Search in sources :

Example 31 with LogfileTestTailer

use of com.evolveum.midpoint.test.util.LogfileTestTailer 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)

Example 32 with LogfileTestTailer

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

the class TestWSSecurity method test145ModifyConfigAsDarthAdder.

@Test
public void test145ModifyConfigAsDarthAdder() throws Exception {
    final String TEST_NAME = "test145ModifyConfigAsDarthAdder";
    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) {
        assertSoapSecurityFault(e, "FailedAuthentication", "could not be authenticated or authorized");
    }
    // THEN
    tailer.tail();
    assertAuditLoginFailed(tailer, "user disabled");
}
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 33 with LogfileTestTailer

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

the class TestWSSecurity method test103GetConfigEmptyPasswordDigest.

@Test
public void test103GetConfigEmptyPasswordDigest() throws Exception {
    final String TEST_NAME = "test103GetConfigEmptyPasswordDigest";
    displayTestTitle(TEST_NAME);
    LogfileTestTailer tailer = createLogTailer();
    modelPort = createModelPort(USER_ADMINISTRATOR_USERNAME, "", WSConstants.PW_DIGEST);
    Holder<ObjectType> objectHolder = new Holder<ObjectType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    // WHEN
    try {
        modelPort.getObject(getTypeQName(SystemConfigurationType.class), SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, objectHolder, resultHolder);
        AssertJUnit.fail("Unexpected success");
    } catch (SOAPFaultException e) {
        assertSoapSecurityFault(e, "FailedAuthentication", "could not be authenticated or authorized");
    }
    tailer.tail();
    assertAuditLoginFailed(tailer, "could not be authenticated or authorized");
}
Also used : LogfileTestTailer(com.evolveum.midpoint.test.util.LogfileTestTailer) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) Holder(javax.xml.ws.Holder) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Test(org.testng.annotations.Test)

Example 34 with LogfileTestTailer

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

the class TestWSSanity method test110AssignOpenDJAccountToJack.

@Test
public void test110AssignOpenDJAccountToJack() throws Exception {
    final String TEST_NAME = "test110AssignOpenDJAccountToJack";
    displayTestTitle(TEST_NAME);
    LogfileTestTailer tailer = createLogTailer();
    XMLGregorianCalendar startTs = TestUtil.currentTime();
    ObjectDeltaType delta = ModelClientUtil.createConstructionAssignDelta(UserType.class, USER_JACK_OID, RESOURCE_OPENDJ_OID);
    // WHEN
    ObjectDeltaOperationListType executedDeltas = modelPort.executeChanges(ModelClientUtil.createDeltaList(delta), null);
    // THEN
    XMLGregorianCalendar endTs = TestUtil.currentTime();
    assertSuccess(executedDeltas);
    tailer.tail();
    displayAudit(tailer);
    assertAuditLoginLogout(tailer);
    assertAuditIds(tailer);
    assertAuditOperation(tailer, "MODIFY_OBJECT");
    tailer.assertAudit(4);
    // GET user
    UserType userAfter = getObject(UserType.class, USER_JACK_OID);
    display(userAfter);
    assertUser(userAfter, USER_JACK_OID, USER_JACK_USERNAME, USER_JACK_GIVEN_NAME, USER_JACK_FAMILY_NAME);
    assertModifyMetadata(userAfter, USER_ADMINISTRATOR_OID, startTs, endTs);
    accountJackOid = getSingleLinkOid(userAfter);
    assertNotNull(accountJackOid);
    Entry ldapEntry = openDJController.fetchEntry("uid=" + USER_JACK_USERNAME + "," + openDJController.getSuffixPeople());
    display(ldapEntry.toLDIFString());
    OpenDJController.assertAttribute(ldapEntry, "uid", "jack");
    OpenDJController.assertAttribute(ldapEntry, "givenName", "Jack");
    OpenDJController.assertAttribute(ldapEntry, "sn", "Sparrow");
    OpenDJController.assertAttribute(ldapEntry, "cn", "Jack Sparrow");
    OpenDJController.assertAttribute(ldapEntry, "displayName", "Jack Sparrow");
}
Also used : LogfileTestTailer(com.evolveum.midpoint.test.util.LogfileTestTailer) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) Entry(org.opends.server.types.Entry) SearchResultEntry(org.opends.server.types.SearchResultEntry) ObjectDeltaOperationListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 35 with LogfileTestTailer

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

the class TestWSSecurity method test146EnableDarthAdder.

@Test
public void test146EnableDarthAdder() throws Exception {
    final String TEST_NAME = "test146EnableDarthAdder";
    displayTestTitle(TEST_NAME);
    LogfileTestTailer tailer = createLogTailer();
    modelPort = createModelPort();
    ObjectDeltaListType deltaList = ModelClientUtil.createModificationDeltaList(UserType.class, USER_DARTHADDER_OID, "activation/administrativeStatus", ModificationTypeType.REPLACE, ActivationStatusType.ENABLED);
    // WHEN
    ObjectDeltaOperationListType deltaOpList = modelPort.executeChanges(deltaList, null);
    // THEN
    assertSuccess(deltaOpList);
    tailer.tail();
    displayAudit(tailer);
    assertAuditLoginLogout(tailer);
    assertAuditIds(tailer);
    assertAuditOperation(tailer, "MODIFY_OBJECT");
    tailer.assertAudit(4);
    modelPort = createModelPort(USER_DARTHADDER_USERNAME, USER_DARTHADDER_PASSWORD, WSConstants.PW_DIGEST);
    UserType user = getObject(UserType.class, USER_DARTHADDER_OID);
    display(user);
    assertEquals("Wrong administrative status in " + ModelClientUtil.toString(user), ActivationStatusType.ENABLED, user.getActivation().getAdministrativeStatus());
}
Also used : LogfileTestTailer(com.evolveum.midpoint.test.util.LogfileTestTailer) ObjectDeltaOperationListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType) 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)

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