Search in sources :

Example 26 with EventPayload

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

the class ProxyAdjacentPeerAddressHandlerTest method shouldObtainRightMostAddressFromChain.

@Test
public void shouldObtainRightMostAddressFromChain() 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 27 with EventPayload

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

the class RequestChecksumTest method shouldFlagIncorrectChecksumAsCorrupted.

@Test
public void shouldFlagIncorrectChecksumAsCorrupted() throws IOException, InterruptedException {
    request(URL_QUERY_CHECKSUM_BAD);
    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 28 with EventPayload

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

the class RequestChecksumTest method shouldFlagCorrectChecksumAsNotCorrupted.

@Test
public void shouldFlagCorrectChecksumAsNotCorrupted() throws IOException, InterruptedException {
    request(URL_QUERY_CHECKSUM_GOOD);
    Preconditions.checkState(null != server);
    final EventPayload payload = server.waitForEvent();
    assertFalse(payload.event.corruptEvent);
}
Also used : EventPayload(io.divolte.server.ServerTestUtils.EventPayload) Test(org.junit.Test)

Example 29 with EventPayload

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

the class RequestChecksumTest method shouldDiscardCorruptedEventsIfConfigured.

@Test
public void shouldDiscardCorruptedEventsIfConfigured() throws InterruptedException, IOException {
    discardCorruptEvents = true;
    request(URL_QUERY_CHECKSUM_BAD);
    request(URL_QUERY_SENTINEL);
    Preconditions.checkState(null != server);
    final EventPayload payload = server.waitForEvent();
    // The first request should be missing, and we should now have the sentinel event.
    assertEquals(Optional.of("sentinelEvent"), payload.event.eventType);
}
Also used : EventPayload(io.divolte.server.ServerTestUtils.EventPayload) Test(org.junit.Test)

Example 30 with EventPayload

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

the class SeleniumDisabledAutoPageViewEventTest method shouldFireOnlyCustomPageViewEvent.

@Test
public void shouldFireOnlyCustomPageViewEvent() throws InterruptedException {
    Preconditions.checkState(null != server);
    gotoPage(CUSTOM_PAGE_VIEW);
    final EventPayload payload = server.waitForEvent();
    final DivolteEvent eventData = payload.event;
    final Optional<String> eventParameters = eventData.eventParametersProducer.get().map(Object::toString);
    assertTrue(eventParameters.isPresent());
    assertEquals("{\"foo\":\"moo\",\"bar\":\"baz\"}", eventParameters.get());
    assertFalse(server.eventsRemaining());
}
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