コード例 #1
0
  @Test
  public void successIsLoggedIfAceRequiresSuccessAudit() throws Exception {
    when(ace.isAuditSuccess()).thenReturn(true);

    logger.logIfNeeded(true, ace);
    assertThat(bytes.toString().startsWith("GRANTED due to ACE")).isTrue();
  }
コード例 #2
0
 @Test
 public void failureIsLoggedIfAceRequiresFailureAudit() throws Exception {
   when(ace.isAuditFailure()).thenReturn(true);
   logger.logIfNeeded(false, ace);
   assertThat(bytes.toString().startsWith("DENIED due to ACE")).isTrue();
 }
コード例 #3
0
 @Test
 public void failureIsntLoggedIfAceDoesntRequireFailureAudit() throws Exception {
   when(ace.isAuditFailure()).thenReturn(false);
   logger.logIfNeeded(false, ace);
   assertThat(bytes.size()).isEqualTo(0);
 }
コード例 #4
0
 @Test
 public void successIsNotLoggedIfAceDoesntRequireSuccessAudit() throws Exception {
   when(ace.isAuditSuccess()).thenReturn(false);
   logger.logIfNeeded(true, ace);
   assertThat(bytes.size()).isEqualTo(0);
 }
コード例 #5
0
 @Test
 public void nonAuditableAceIsIgnored() {
   AccessControlEntry ace = mock(AccessControlEntry.class);
   logger.logIfNeeded(true, ace);
   assertThat(bytes.size()).isEqualTo(0);
 }