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);
}
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);
}
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);
}
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>"));
}
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));
}
Aggregations