Search in sources :

Example 1 with AuditEvent

use of cz.metacentrum.perun.audit.events.AuditEvent in project perun by CESNET.

the class AuditMessagesManagerEntryIntegrationTest method testLocalDate.

@Test
public void testLocalDate() throws Exception {
    System.out.println(CLASS_NAME + "testLocalDate");
    AuditMessagesManagerImpl auditMessagesManagerImpl = (AuditMessagesManagerImpl) ReflectionTestUtils.getField(perun.getAuditMessagesManagerBl(), "auditMessagesManagerImpl");
    assertThat(auditMessagesManagerImpl).isNotNull();
    ObjectMapper mapper = (ObjectMapper) ReflectionTestUtils.getField(auditMessagesManagerImpl, "mapper");
    assertThat(mapper).isNotNull();
    AuditEvent event = new SponsorshipEstablished(null, null, LocalDate.MIN);
    testAuditEventMapper(mapper, event);
    EnrichedSponsorship enrichedSponsorship = new EnrichedSponsorship();
    enrichedSponsorship.setValidityTo(LocalDate.MAX);
    AuditEvent event2 = new SponsorshipExpired();
    testAuditEventMapper(mapper, event2);
}
Also used : SponsorshipEstablished(cz.metacentrum.perun.audit.events.MembersManagerEvents.SponsorshipEstablished) EnrichedSponsorship(cz.metacentrum.perun.core.api.EnrichedSponsorship) SponsorshipExpired(cz.metacentrum.perun.audit.events.ExpirationNotifScheduler.SponsorshipExpired) AuditMessagesManagerImpl(cz.metacentrum.perun.core.impl.AuditMessagesManagerImpl) AuditEvent(cz.metacentrum.perun.audit.events.AuditEvent) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 2 with AuditEvent

use of cz.metacentrum.perun.audit.events.AuditEvent in project perun by CESNET.

the class AuditMessagesManagerEntryIntegrationTest method testAuditEventMapper.

private void testAuditEventMapper(ObjectMapper mapper, AuditEvent event) throws Exception {
    String value = mapper.writeValueAsString(event);
    AuditEvent deserializedEvent = mapper.readValue(value, AuditEvent.class);
    assertThat(deserializedEvent).isEqualTo(event);
}
Also used : AuditEvent(cz.metacentrum.perun.audit.events.AuditEvent)

Example 3 with AuditEvent

use of cz.metacentrum.perun.audit.events.AuditEvent in project perun by CESNET.

the class urn_perun_user_attribute_def_virt_eduPersonScopedAffiliationsTest method resolveAttributeValueChangeTest.

@Test
public void resolveAttributeValueChangeTest() throws Exception {
    when(session.getPerunBl().getUsersManagerBl().getUserById(session, 1)).thenReturn(user);
    AuditEvent event = new AllAttributesRemovedForUserExtSource(ues1);
    List<AuditEvent> auditEvents = classInstance.resolveVirtualAttributeValueChange(session, event);
    assertEquals(auditEvents.get(0).getClass(), AttributeChangedForUser.class);
    event = new AllAttributesRemovedForUser(user);
    auditEvents = classInstance.resolveVirtualAttributeValueChange(session, event);
    assertEquals(auditEvents.get(0).getClass(), AttributeChangedForUser.class);
    Attribute attribute = new Attribute();
    attribute.setFriendlyName("eduPersonScopedAffiliationsManuallyAssigned");
    event = new AttributeSetForUser(attribute, user);
    auditEvents = classInstance.resolveVirtualAttributeValueChange(session, event);
    assertEquals(auditEvents.get(0).getClass(), AttributeChangedForUser.class);
    when(session.getPerunBl().getAttributesManagerBl().getAttribute(session, user, AttributesManager.NS_USER_ATTR_VIRT + ":" + "eduPersonScopedAffiliations")).thenReturn(attribute);
    auditEvents = classInstance.resolveVirtualAttributeValueChange(session, event);
    assertEquals(auditEvents.get(0).getClass(), AttributeChangedForUser.class);
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) AllAttributesRemovedForUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForUser) AuditEvent(cz.metacentrum.perun.audit.events.AuditEvent) AllAttributesRemovedForUserExtSource(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForUserExtSource) AttributeSetForUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForUser) Test(org.junit.Test)

Example 4 with AuditEvent

use of cz.metacentrum.perun.audit.events.AuditEvent in project perun by CESNET.

the class urn_perun_user_attribute_def_virt_institutionsCountriesTest method resolveVirtualAttributeValueChange.

@Test
public void resolveVirtualAttributeValueChange() throws Exception {
    setSchacHomeOrgs("muni.cz;cesnet.cz");
    AttributeDefinition countries = classInstance.getAttributeDefinition();
    when(sess.getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, "urn:perun:user:attribute-def:virt:institutionsCountries")).thenReturn(countries);
    when(sess.getPerunBl().getUsersManagerBl().getUserById(sess, userExtSource.getUserId())).thenReturn(user);
    AuditEvent uesSet = new AttributeSetForUes(schacHomeOrg, userExtSource);
    List<AuditEvent> msgs = classInstance.resolveVirtualAttributeValueChange(sess, uesSet);
    assertTrue("audit should contain change of institutionsCountries", msgs.get(0).getMessage().contains("friendlyName=<institutionsCountries>"));
}
Also used : AttributeDefinition(cz.metacentrum.perun.core.api.AttributeDefinition) AuditEvent(cz.metacentrum.perun.audit.events.AuditEvent) AttributeSetForUes(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForUes) Test(org.junit.Test)

Example 5 with AuditEvent

use of cz.metacentrum.perun.audit.events.AuditEvent in project perun by CESNET.

the class urn_perun_user_attribute_def_virt_tcsMails_muTest method resolveVirtualAttributeValueChangeRemoved5.

@Test
public void resolveVirtualAttributeValueChangeRemoved5() throws Exception {
    AuditEvent userRem = new AttributeRemovedForUser(o365MailsAttr, user);
    List<AuditEvent> msgs = classInstance.resolveVirtualAttributeValueChange(sess, userRem);
    assertTrue("audit should contain change of tcsMails", msgs.get(0).getMessage().contains(expectedTestOfMessage));
}
Also used : AuditEvent(cz.metacentrum.perun.audit.events.AuditEvent) AttributeRemovedForUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForUser) Test(org.junit.Test)

Aggregations

AuditEvent (cz.metacentrum.perun.audit.events.AuditEvent)33 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)11 Attribute (cz.metacentrum.perun.core.api.Attribute)9 AttributeDefinition (cz.metacentrum.perun.core.api.AttributeDefinition)9 AttributeSetForUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForUser)8 AttributeRemovedForUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeRemovedForUser)7 User (cz.metacentrum.perun.core.api.User)7 AttributeChangedForUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeChangedForUser)5 AllAttributesRemovedForUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AllAttributesRemovedForUser)4 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)4 UserNotExistsException (cz.metacentrum.perun.core.api.exceptions.UserNotExistsException)4 EnrichedSponsorship (cz.metacentrum.perun.core.api.EnrichedSponsorship)3 Facility (cz.metacentrum.perun.core.api.Facility)3 Member (cz.metacentrum.perun.core.api.Member)3 AttributeNotExistsException (cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException)3 JsonParseException (com.fasterxml.jackson.core.JsonParseException)2 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)2 AttributeChangedForFacility (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeChangedForFacility)2 AttributeChangedForResourceAndMember (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeChangedForResourceAndMember)2