Search in sources :

Example 11 with IAccessEvent

use of ch.qos.logback.access.spi.IAccessEvent in project logback-access-spring-boot-starter by akihyro.

the class JettyServerPortUnusingTest method logbackAccessEvent.

/** {@inheritDoc} */
@Override
public void logbackAccessEvent() {
    RequestEntity<Void> request = RequestEntity.get(rest.getRestTemplate().getUriTemplateHandler().expand("/test/text")).header("X-Forwarded-Host", "forwarded-host:12345").build();
    ResponseEntity<String> response = rest.exchange(request, String.class);
    IAccessEvent event = LogbackAccessEventQueuingAppender.appendedEventQueue.pop();
    LogbackAccessEventQueuingListener.appendedEventQueue.pop();
    assertThat(response).hasStatusCode(HttpStatus.OK);
    assertThat(event).hasLocalPort(port);
}
Also used : IAccessEvent(ch.qos.logback.access.spi.IAccessEvent)

Example 12 with IAccessEvent

use of ch.qos.logback.access.spi.IAccessEvent in project logback-access-spring-boot-starter by akihyro.

the class TomcatForwardHeadersUsingTest method logbackAccessEvent.

/** {@inheritDoc} */
@Override
public void logbackAccessEvent() {
    RequestEntity<Void> request = RequestEntity.get(rest.getRestTemplate().getUriTemplateHandler().expand("/test/text")).header("X-Forwarded-Port", "12345").header("X-Forwarded-For", "1.2.3.4").header("X-Forwarded-Proto", "https").build();
    ResponseEntity<String> response = rest.exchange(request, String.class);
    IAccessEvent event = LogbackAccessEventQueuingAppender.appendedEventQueue.pop();
    LogbackAccessEventQueuingListener.appendedEventQueue.pop();
    assertThat(response).hasStatusCode(HttpStatus.OK);
    assertThat(event).hasServerName("localhost").hasLocalPort(12345).hasRemoteAddr("1.2.3.4").hasRemoteHost("1.2.3.4").hasProtocol("HTTP/1.1");
}
Also used : IAccessEvent(ch.qos.logback.access.spi.IAccessEvent)

Example 13 with IAccessEvent

use of ch.qos.logback.access.spi.IAccessEvent in project logback-access-spring-boot-starter by akihyro.

the class TomcatRequestAttributesDisablingTest method logbackAccessEvent.

/**
     * Tests a Logback-access event.
     */
@Test
public void logbackAccessEvent() {
    RequestEntity<Void> request = RequestEntity.get(rest.getRestTemplate().getUriTemplateHandler().expand("/test/text")).header("X-Forwarded-Port", "12345").header("X-Forwarded-For", "1.2.3.4").header("X-Forwarded-Proto", "https").build();
    ResponseEntity<String> response = rest.exchange(request, String.class);
    IAccessEvent event = LogbackAccessEventQueuingAppender.appendedEventQueue.pop();
    LogbackAccessEventQueuingListener.appendedEventQueue.pop();
    assertThat(response).hasStatusCode(HttpStatus.OK);
    assertThat(event).hasServerName("localhost").hasLocalPort(port).hasRemoteAddr("127.0.0.1").hasRemoteHost("127.0.0.1").hasProtocol("HTTP/1.1");
}
Also used : IAccessEvent(ch.qos.logback.access.spi.IAccessEvent) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 14 with IAccessEvent

use of ch.qos.logback.access.spi.IAccessEvent in project logback-access-spring-boot-starter by akihyro.

the class UndertowForwardHeadersUsingTest method logbackAccessEvent.

/** {@inheritDoc} */
@Override
public void logbackAccessEvent() {
    RequestEntity<Void> request = RequestEntity.get(rest.getRestTemplate().getUriTemplateHandler().expand("/test/text")).header("X-Forwarded-Host", "forwarded-host").header("X-Forwarded-Port", "12345").header("X-Forwarded-For", "1.2.3.4").header("X-Forwarded-Proto", "https").build();
    ResponseEntity<String> response = rest.exchange(request, String.class);
    IAccessEvent event = LogbackAccessEventQueuingAppender.appendedEventQueue.pop();
    LogbackAccessEventQueuingListener.appendedEventQueue.pop();
    assertThat(response).hasStatusCode(HttpStatus.OK);
    assertThat(event).hasServerName("forwarded-host").hasLocalPort(12345).hasRemoteAddr("1.2.3.4").hasRemoteHost("1.2.3.4").hasProtocol("HTTP/1.1");
}
Also used : IAccessEvent(ch.qos.logback.access.spi.IAccessEvent)

Example 15 with IAccessEvent

use of ch.qos.logback.access.spi.IAccessEvent in project logback-access-spring-boot-starter by akihyro.

the class AbstractLogbackAccessEventsTest method logbackAccessEventWithRequestParameter.

/**
     * Tests a Logback-access event with a request parameter.
     */
@Test
public void logbackAccessEventWithRequestParameter() {
    ResponseEntity<String> response = rest.getForEntity("/test/text?test-parameter=TEST-PARAMETER", String.class);
    IAccessEvent event = LogbackAccessEventQueuingAppender.appendedEventQueue.pop();
    LogbackAccessEventQueuingListener.appendedEventQueue.pop();
    assertThat(response).hasStatusCode(HttpStatus.OK);
    assertThat(event).hasRequestParameter("test-parameter", "TEST-PARAMETER").hasRequestParameterInMap("test-parameter", "TEST-PARAMETER");
}
Also used : IAccessEvent(ch.qos.logback.access.spi.IAccessEvent) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

IAccessEvent (ch.qos.logback.access.spi.IAccessEvent)18 Test (org.junit.Test)11 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)10 Logger (ch.qos.logback.classic.Logger)1 LoggerContext (ch.qos.logback.classic.LoggerContext)1 NullLevelFilterFactory (io.dropwizard.logging.filter.NullLevelFilterFactory)1 AsyncAccessEventAppenderFactory (io.dropwizard.request.logging.async.AsyncAccessEventAppenderFactory)1 LogbackAccessRequestLayoutFactory (io.dropwizard.request.logging.layout.LogbackAccessRequestLayoutFactory)1 LocalDateTime (java.time.LocalDateTime)1