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);
}
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");
}
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");
}
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");
}
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");
}
Aggregations