Search in sources :

Example 1 with EventPayload

use of io.divolte.server.ServerTestUtils.EventPayload in project divolte-collector by divolte.

the class ProxyAdjacentPeerAddressHandlerTest method shouldObtainSingleValueWithoutCommas.

@Test
public void shouldObtainSingleValueWithoutCommas() throws IOException, InterruptedException {
    final URL url = new URL(String.format(URL_STRING, server.host, server.port) + URL_QUERY_STRING);
    final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.addRequestProperty("X-Forwarded-For", "127.0.0.1");
    conn.setRequestMethod("GET");
    assertEquals(200, conn.getResponseCode());
    final EventPayload payload = server.waitForEvent();
    assertEquals("127.0.0.1", payload.event.exchange.getSourceAddress().getHostString());
}
Also used : HttpURLConnection(java.net.HttpURLConnection) URL(java.net.URL) EventPayload(io.divolte.server.ServerTestUtils.EventPayload) Test(org.junit.Test)

Example 2 with EventPayload

use of io.divolte.server.ServerTestUtils.EventPayload in project divolte-collector by divolte.

the class ProxyAdjacentPeerAddressHandlerTest method shouldAllowWhitespaceAfterComma.

@Test
public void shouldAllowWhitespaceAfterComma() throws IOException, InterruptedException {
    final URL url = new URL(String.format(URL_STRING, server.host, server.port) + URL_QUERY_STRING);
    final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.addRequestProperty("X-Forwarded-For", "127.0.0.1, 192.168.13.23");
    conn.setRequestMethod("GET");
    assertEquals(200, conn.getResponseCode());
    final EventPayload payload = server.waitForEvent();
    assertEquals("192.168.13.23", payload.event.exchange.getSourceAddress().getHostString());
}
Also used : HttpURLConnection(java.net.HttpURLConnection) URL(java.net.URL) EventPayload(io.divolte.server.ServerTestUtils.EventPayload) Test(org.junit.Test)

Example 3 with EventPayload

use of io.divolte.server.ServerTestUtils.EventPayload in project divolte-collector by divolte.

the class ProxyAdjacentPeerAddressHandlerTest method shouldAllowMultipleXffHeaders.

@Test
public void shouldAllowMultipleXffHeaders() throws IOException, InterruptedException {
    final URL url = new URL(String.format(URL_STRING, server.host, server.port) + URL_QUERY_STRING);
    final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.addRequestProperty("X-Forwarded-For", "127.0.0.1, 8.8.8.8");
    conn.addRequestProperty("X-Forwarded-For", "192.168.13.23");
    conn.setRequestMethod("GET");
    assertEquals(200, conn.getResponseCode());
    final EventPayload payload = server.waitForEvent();
    assertEquals("192.168.13.23", payload.event.exchange.getSourceAddress().getHostString());
}
Also used : HttpURLConnection(java.net.HttpURLConnection) URL(java.net.URL) EventPayload(io.divolte.server.ServerTestUtils.EventPayload) Test(org.junit.Test)

Example 4 with EventPayload

use of io.divolte.server.ServerTestUtils.EventPayload in project divolte-collector by divolte.

the class RequestChecksumTest method shouldFlagPartialChecksumAsCorrupted.

@Test
public void shouldFlagPartialChecksumAsCorrupted() throws IOException, InterruptedException {
    for (final String urlQueryChecksumPartial : URL_QUERY_CHECKSUM_PARTIALS) {
        request(urlQueryChecksumPartial);
        Preconditions.checkState(null != server);
        final EventPayload payload = server.waitForEvent();
        assertTrue(payload.event.corruptEvent);
    }
}
Also used : EventPayload(io.divolte.server.ServerTestUtils.EventPayload) Test(org.junit.Test)

Example 5 with EventPayload

use of io.divolte.server.ServerTestUtils.EventPayload in project divolte-collector by divolte.

the class RequestChecksumTest method shouldChecksumCorrectlyWithNonAsciiParameters.

@Test
public void shouldChecksumCorrectlyWithNonAsciiParameters() throws IOException, InterruptedException {
    request(URL_QUERY_CHECKSUM_UNICODE);
    Preconditions.checkState(null != server);
    final EventPayload payload = server.waitForEvent();
    final DivolteEvent eventData = payload.event;
    assertFalse(eventData.corruptEvent);
    assertEquals(Optional.of("ụñ⚕©ºḌℨ"), eventData.eventType);
}
Also used : EventPayload(io.divolte.server.ServerTestUtils.EventPayload) Test(org.junit.Test)

Aggregations

EventPayload (io.divolte.server.ServerTestUtils.EventPayload)46 Test (org.junit.Test)46 HttpURLConnection (java.net.HttpURLConnection)5 URL (java.net.URL)5 GenericRecord (org.apache.avro.generic.GenericRecord)3 Utf8 (org.apache.avro.util.Utf8)3 JsonParser (com.fasterxml.jackson.core.JsonParser)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 CityResponse (com.maxmind.geoip2.model.CityResponse)2 Config (com.typesafe.config.Config)2 ValidatedConfiguration (io.divolte.server.config.ValidatedConfiguration)2 LookupService (io.divolte.server.ip2geo.LookupService)2 DslRecordMapper (io.divolte.server.recordmapping.DslRecordMapper)2 Instant (java.time.Instant)2 Optional (java.util.Optional)2 Stream (java.util.stream.Stream)2 ParametersAreNonnullByDefault (javax.annotation.ParametersAreNonnullByDefault)2 Assert (org.junit.Assert)2 WebElement (org.openqa.selenium.WebElement)2 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)2