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