Search in sources :

Example 16 with FilterReply

use of ch.qos.logback.core.spi.FilterReply in project qpid-broker-j by apache.

the class PrincipalLogEventFilterTest method testWrongPrincipal.

public void testWrongPrincipal() {
    _subject.getPrincipals().add(mock(Principal.class));
    FilterReply reply = doFilter();
    assertEquals(FilterReply.DENY, reply);
}
Also used : FilterReply(ch.qos.logback.core.spi.FilterReply) Principal(java.security.Principal)

Example 17 with FilterReply

use of ch.qos.logback.core.spi.FilterReply in project qpid-broker-j by apache.

the class VirtualHostLogEventExcludingFilterTest method testDecideOnVirtualHostPrincipalInSubjectAndVirtualHostLogEventExcluded.

public void testDecideOnVirtualHostPrincipalInSubjectAndVirtualHostLogEventExcluded() throws Exception {
    when(_brokerLogger.isVirtualHostLogEventExcluded()).thenReturn(true);
    Subject subject = new Subject();
    subject.getPrincipals().add(mock(VirtualHostPrincipal.class));
    FilterReply reply = doTestDecide(subject);
    assertEquals("Unexpected reply for BrokerLogger#virtualHostLogEventExcluded=true and VH principal in subject", FilterReply.DENY, reply);
}
Also used : FilterReply(ch.qos.logback.core.spi.FilterReply) VirtualHostPrincipal(org.apache.qpid.server.virtualhost.VirtualHostPrincipal) Subject(javax.security.auth.Subject)

Example 18 with FilterReply

use of ch.qos.logback.core.spi.FilterReply in project qpid-broker-j by apache.

the class VirtualHostLogEventExcludingFilterTest method testDecideOnVirtualHostPrincipalInSubjectAndVirtualHostLogEventNotExcluded.

public void testDecideOnVirtualHostPrincipalInSubjectAndVirtualHostLogEventNotExcluded() throws Exception {
    Subject subject = new Subject();
    subject.getPrincipals().add(mock(VirtualHostPrincipal.class));
    FilterReply reply = doTestDecide(subject);
    assertEquals("Unexpected reply for BrokerLogger#virtualHostLogEventExcluded=false and VH principal in subject", FilterReply.NEUTRAL, reply);
}
Also used : FilterReply(ch.qos.logback.core.spi.FilterReply) VirtualHostPrincipal(org.apache.qpid.server.virtualhost.VirtualHostPrincipal) Subject(javax.security.auth.Subject)

Example 19 with FilterReply

use of ch.qos.logback.core.spi.FilterReply in project qpid-broker-j by apache.

the class VirtualHostLogEventExcludingFilterTest method testDecideOnVirtualHostLogEventExcludedAndNullSubject.

public void testDecideOnVirtualHostLogEventExcludedAndNullSubject() throws Exception {
    when(_brokerLogger.isVirtualHostLogEventExcluded()).thenReturn(true);
    FilterReply reply = _filter.decide(_loggingEvent);
    assertEquals(" BrokerLogger#virtualHostLogEventExcluded=true and subject=null", FilterReply.NEUTRAL, reply);
    assertNull("Subject should not be set in test environment", Subject.getSubject(AccessController.getContext()));
}
Also used : FilterReply(ch.qos.logback.core.spi.FilterReply)

Example 20 with FilterReply

use of ch.qos.logback.core.spi.FilterReply in project qpid-broker-j by apache.

the class VirtualHostLogEventExcludingFilterTest method testDecideOnNoVirtualHostPrincipalInSubjectAndVirtualHostLogEventExcluded.

public void testDecideOnNoVirtualHostPrincipalInSubjectAndVirtualHostLogEventExcluded() throws Exception {
    when(_brokerLogger.isVirtualHostLogEventExcluded()).thenReturn(true);
    Subject subject = new Subject();
    subject.getPrincipals().add(mock(Principal.class));
    FilterReply reply = doTestDecide(subject);
    assertEquals("Unexpected reply for BrokerLogger#virtualHostLogEventExcluded=true and no VH principal in subject", FilterReply.NEUTRAL, reply);
}
Also used : FilterReply(ch.qos.logback.core.spi.FilterReply) Subject(javax.security.auth.Subject) VirtualHostPrincipal(org.apache.qpid.server.virtualhost.VirtualHostPrincipal) Principal(java.security.Principal)

Aggregations

FilterReply (ch.qos.logback.core.spi.FilterReply)21 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)8 LogbackException (ch.qos.logback.core.LogbackException)5 CompositeFilter (org.apache.qpid.server.logging.logback.CompositeFilter)5 Subject (javax.security.auth.Subject)4 VirtualHostPrincipal (org.apache.qpid.server.virtualhost.VirtualHostPrincipal)4 Principal (java.security.Principal)3 PatternLayoutEncoder (ch.qos.logback.classic.encoder.PatternLayoutEncoder)1 ConsoleAppender (ch.qos.logback.core.ConsoleAppender)1 Context (ch.qos.logback.core.Context)1 ListAppender (ch.qos.logback.core.read.ListAppender)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 EventLogger (org.apache.qpid.server.logging.EventLogger)1 Logger (org.slf4j.Logger)1