Search in sources :

Example 1 with CrlChecker

use of org.codice.ddf.security.handler.pki.CrlChecker in project ddf by codice.

the class CrlInterceptorTest method testErrorThrownWithFailedCert.

/**
     * Tests that the interceptor will throw an error if the cert fails the CrlChecker
     */
@Test(expected = AccessDeniedException.class)
public void testErrorThrownWithFailedCert() throws CertificateException {
    Message message = createMockMessageWithCert(getTestCertString());
    CrlChecker crlChecker = mock(CrlChecker.class);
    when(crlChecker.passesCrlCheck(anyObject())).thenReturn(false);
    CrlInterceptor crlInterceptor = new CrlInterceptor(crlChecker);
    crlInterceptor.handleMessage(message);
    verify(crlChecker).passesCrlCheck(getTestCerts());
}
Also used : CrlChecker(org.codice.ddf.security.handler.pki.CrlChecker) Message(org.apache.cxf.message.Message) Test(org.junit.Test)

Example 2 with CrlChecker

use of org.codice.ddf.security.handler.pki.CrlChecker in project ddf by codice.

the class CrlInterceptorTest method testErrorNotThrownWithPassingCert.

/**
     * Tests that the interceptor will NOT throw an error if the cert passes the CrlChecker
     */
@Test
public void testErrorNotThrownWithPassingCert() throws CertificateException {
    Message message = createMockMessageWithCert(getTestCertString());
    CrlChecker crlChecker = mock(CrlChecker.class);
    when(crlChecker.passesCrlCheck(anyObject())).thenReturn(true);
    CrlInterceptor crlInterceptor = new CrlInterceptor(crlChecker);
    crlInterceptor.handleMessage(message);
    verify(crlChecker).passesCrlCheck(getTestCerts());
}
Also used : CrlChecker(org.codice.ddf.security.handler.pki.CrlChecker) Message(org.apache.cxf.message.Message) Test(org.junit.Test)

Aggregations

Message (org.apache.cxf.message.Message)2 CrlChecker (org.codice.ddf.security.handler.pki.CrlChecker)2 Test (org.junit.Test)2