563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste * The contents of this file are subject to the terms of the Common Development and
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste * Distribution License (the License). You may not use this file except in compliance with the
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste * specific language governing permission and limitations under the License.
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste * When distributing Covered Software, include this CDDL Header Notice in each file and include
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste * Header, with the fields enclosed by brackets [] replaced by your own identifying
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste * information: "Portions copyright [year] [name of copyright owner]".
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste * Copyright 2015 ForgeRock AS.
dfa51161ad226f5998270e3becb25817774aa168Tony Bamfordimport org.forgerock.openam.audit.AuditConstants.*;
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Joosteimport com.sun.identity.authentication.service.LoginState;
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Joosteimport org.forgerock.openam.audit.AuditEventFactory;
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Joosteimport org.forgerock.openam.audit.AuditEventPublisher;
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Joosteimport org.forgerock.openam.audit.model.AuthenticationAuditEntry;
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Joostepublic class AuthenticationModuleEventAuditorTest {
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste private AuthenticationModuleEventAuditor auditor;
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste private AuthenticationAuditEntry emptyAuditEntryDetail;
dfa51161ad226f5998270e3becb25817774aa168Tony Bamford when(eventPublisher.isAuditing(anyString(), anyString(), any(EventName.class))).thenReturn(true);
c1218d78f656be3cbe77704bc80bb83b82fdc277Jaco Jooste when(eventFactory.authenticationEvent(anyString())).thenCallRealMethod();
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste auditor = new AuthenticationModuleEventAuditor(eventPublisher, eventFactory);
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste auditor.auditModuleSuccess(emptyState, emptyPrincipal, emptyAuditEntryDetail);
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste verify(eventPublisher, times(2)).tryPublish(anyString(), any(AuditEvent.class));
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste // no exceptions expected
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste auditor.auditModuleFailure(emptyState, emptyPrincipal, emptyAuditEntryDetail);
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste verify(eventPublisher, times(2)).tryPublish(anyString(), any(AuditEvent.class));
563b922249eadd0562ddea89c52ed308c2d31c0aJaco Jooste // no exceptions expected