Search in sources :

Example 46 with Envelope

use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project cas by apereo.

the class SamlProfileSamlSoap11ResponseBuilder method buildResponse.

@Override
protected Envelope buildResponse(final Assertion assertion, final Object casAssertion, final RequestAbstractType authnRequest, final SamlRegisteredService service, final SamlRegisteredServiceServiceProviderMetadataFacade adaptor, final HttpServletRequest request, final HttpServletResponse response, final String binding) throws SamlException {
    LOGGER.debug("Locating the assertion consumer service url for binding [{}]", binding);
    @NonNull final AssertionConsumerService acs = adaptor.getAssertionConsumerService(binding);
    LOGGER.debug("Located assertion consumer service url [{}]", acs);
    final Response ecpResponse = newEcpResponse(acs.getLocation());
    final Header header = newSoapObject(Header.class);
    header.getUnknownXMLObjects().add(ecpResponse);
    final Body body = newSoapObject(Body.class);
    final org.opensaml.saml.saml2.core.Response saml2Response = buildSaml2Response(casAssertion, authnRequest, service, adaptor, request, binding);
    body.getUnknownXMLObjects().add(saml2Response);
    final Envelope envelope = newSoapObject(Envelope.class);
    envelope.setHeader(header);
    envelope.setBody(body);
    SamlUtils.logSamlObject(this.configBean, envelope);
    return envelope;
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(org.opensaml.saml.saml2.ecp.Response) Header(org.opensaml.soap.soap11.Header) NonNull(lombok.NonNull) AssertionConsumerService(org.opensaml.saml.saml2.metadata.AssertionConsumerService) Envelope(org.opensaml.soap.soap11.Envelope) Body(org.opensaml.soap.soap11.Body)

Example 47 with Envelope

use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project ApplicationInsights-Java by microsoft.

the class AiSmokeTest method getTelemetry.

protected static Telemetry getTelemetry(int rddCount, Predicate<RemoteDependencyData> condition) throws Exception {
    if (rddCount > 3) {
        throw new IllegalArgumentException("this method currently only supports rddCount up to 3");
    }
    Telemetry telemetry = new Telemetry();
    List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
    telemetry.rdEnvelope = rdList.get(0);
    telemetry.rd = (RequestData) ((Data<?>) telemetry.rdEnvelope.getData()).getBaseData();
    assertEquals(0, mockedIngestion.getCountForType("EventData"));
    if (rddCount == 0) {
        return telemetry;
    }
    String operationId = telemetry.rdEnvelope.getTags().get("ai.operation.id");
    List<Envelope> rddList = mockedIngestion.waitForItemsInOperation("RemoteDependencyData", rddCount, operationId, envelope -> {
        RemoteDependencyData rdd = (RemoteDependencyData) ((Data<?>) envelope.getData()).getBaseData();
        return condition.test(rdd);
    });
    telemetry.rddEnvelope1 = rddList.get(0);
    telemetry.rdd1 = (RemoteDependencyData) ((Data<?>) telemetry.rddEnvelope1.getData()).getBaseData();
    if (rddCount == 1) {
        return telemetry;
    }
    telemetry.rddEnvelope2 = rddList.get(1);
    telemetry.rdd2 = (RemoteDependencyData) ((Data<?>) telemetry.rddEnvelope2.getData()).getBaseData();
    if (rddCount == 2) {
        return telemetry;
    }
    telemetry.rddEnvelope3 = rddList.get(2);
    telemetry.rdd3 = (RemoteDependencyData) ((Data<?>) telemetry.rddEnvelope3.getData()).getBaseData();
    return telemetry;
}
Also used : RemoteDependencyData(com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData) Data(com.microsoft.applicationinsights.smoketest.schemav2.Data) RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) RemoteDependencyData(com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope)

Example 48 with Envelope

use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project ApplicationInsights-Java by microsoft.

the class MockedAppInsightsIngestionServlet method doPost.

@Override
@SuppressWarnings("SystemOut")
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    logit("caught: POST " + req.getPathInfo());
    switch(req.getPathInfo()) {
        case "/v2.1/track":
            StringWriter w = new StringWriter();
            try {
                String contentEncoding = req.getHeader("content-encoding");
                Readable reader;
                if ("gzip".equals(contentEncoding)) {
                    reader = new InputStreamReader(new GZIPInputStream(req.getInputStream()), UTF_8);
                } else {
                    reader = req.getReader();
                }
                CharStreams.copy(reader, w);
                String body = w.toString();
                if (PING.equals(body)) {
                    logit("Ping received for /v2.1/track");
                    resp.getWriter().append(PONG);
                } else {
                    resp.setContentType("application/json");
                    logit("Deserializing payload...");
                    if (config.isLogPayloadsEnabled()) {
                        logit("raw payload:\n\n" + body + "\n");
                    }
                    String[] lines = body.split("\n");
                    for (String line : lines) {
                        Envelope envelope;
                        try {
                            envelope = JsonHelper.GSON.fromJson(line.trim(), Envelope.class);
                        } catch (JsonSyntaxException jse) {
                            logerr("Could not deserialize to Envelope", jse);
                            throw jse;
                        }
                        if (config.isRetainPayloadsEnabled()) {
                            String baseType = envelope.getData().getBaseType();
                            if (filtersAllowItem(envelope)) {
                                logit("Adding telemetry item: " + baseType);
                                synchronized (multimapLock) {
                                    type2envelope.put(baseType, envelope);
                                }
                            } else {
                                logit("Rejected telemetry item by filter: " + baseType);
                            }
                        }
                    }
                }
                return;
            } catch (Exception e) {
                e.printStackTrace();
                resp.sendError(500, e.getLocalizedMessage());
            } finally {
                w.close();
            }
            break;
        default:
            resp.sendError(404, "Unknown URI");
            break;
    }
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) JsonSyntaxException(com.google.gson.JsonSyntaxException) StringWriter(java.io.StringWriter) InputStreamReader(java.io.InputStreamReader) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) ServletException(javax.servlet.ServletException) TimeoutException(java.util.concurrent.TimeoutException) JsonSyntaxException(com.google.gson.JsonSyntaxException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Example 49 with Envelope

use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project ApplicationInsights-Java by microsoft.

the class CustomInstrumentationTest method customInstrumentationTwo.

@Test
@TargetUri("/customInstrumentationTwo")
public void customInstrumentationTwo() throws Exception {
    List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
    List<Envelope> rddList = mockedIngestion.waitForItemsInRequest("RemoteDependencyData", 1);
    Envelope rdEnvelope = rdList.get(0);
    Envelope rddEnvelope = rddList.get(0);
    RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
    RemoteDependencyData rdd = (RemoteDependencyData) ((Data<?>) rddEnvelope.getData()).getBaseData();
    assertTrue(rd.getSuccess());
    assertEquals(rdd.getName(), "com/microsoft/applicationinsights/smoketestapp/TargetObject.two");
    assertEquals(rdd.getType(), "OTHER");
    assertEquals(rdd.getSuccess(), true);
    assertParentChild(rd, rdEnvelope, rddEnvelope, "GET /CustomInstrumentation/*");
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) RemoteDependencyData(com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) AiSmokeTest(com.microsoft.applicationinsights.smoketest.AiSmokeTest) Test(org.junit.Test) TargetUri(com.microsoft.applicationinsights.smoketest.TargetUri)

Example 50 with Envelope

use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project ApplicationInsights-Java by microsoft.

the class CustomInstrumentationTest method customInstrumentationFour.

@Test
@TargetUri("/customInstrumentationFour")
public void customInstrumentationFour() throws Exception {
    List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
    List<Envelope> rddList = mockedIngestion.waitForItemsInRequest("RemoteDependencyData", 1);
    Envelope rdEnvelope = rdList.get(0);
    Envelope rddEnvelope = rddList.get(0);
    RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
    RemoteDependencyData rdd = (RemoteDependencyData) ((Data<?>) rddEnvelope.getData()).getBaseData();
    assertTrue(rd.getSuccess());
    assertEquals(rdd.getName(), "com/microsoft/applicationinsights/smoketestapp/TargetObject$NestedObject.four");
    assertEquals(rdd.getType(), "OTHER");
    assertEquals(rdd.getSuccess(), true);
    assertParentChild(rd, rdEnvelope, rddEnvelope, "GET /CustomInstrumentation/*");
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) RemoteDependencyData(com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData) Envelope(com.microsoft.applicationinsights.smoketest.schemav2.Envelope) AiSmokeTest(com.microsoft.applicationinsights.smoketest.AiSmokeTest) Test(org.junit.Test) TargetUri(com.microsoft.applicationinsights.smoketest.TargetUri)

Aggregations

Envelope (com.microsoft.applicationinsights.smoketest.schemav2.Envelope)57 Test (org.junit.Test)52 RequestData (com.microsoft.applicationinsights.smoketest.schemav2.RequestData)45 RemoteDependencyData (com.microsoft.applicationinsights.smoketest.schemav2.RemoteDependencyData)28 Envelope (org.opensaml.soap.soap11.Envelope)16 Body (org.opensaml.soap.soap11.Body)11 Header (org.opensaml.soap.soap11.Header)11 AiSmokeTest (com.microsoft.applicationinsights.smoketest.AiSmokeTest)10 TargetUri (com.microsoft.applicationinsights.smoketest.TargetUri)10 ExceptionData (com.microsoft.applicationinsights.smoketest.schemav2.ExceptionData)9 MessageData (com.microsoft.applicationinsights.smoketest.schemav2.MessageData)9 Data (com.microsoft.applicationinsights.smoketest.schemav2.Data)8 EventData (com.microsoft.applicationinsights.smoketest.schemav2.EventData)6 MetricData (com.microsoft.applicationinsights.smoketest.schemav2.MetricData)6 RequestDataMatchers.hasDuration (com.microsoft.applicationinsights.smoketest.matchers.RequestDataMatchers.hasDuration)4 DataPoint (com.microsoft.applicationinsights.smoketest.schemav2.DataPoint)4 ExceptionDetails (com.microsoft.applicationinsights.smoketest.schemav2.ExceptionDetails)4 Duration (com.microsoft.applicationinsights.smoketest.telemetry.Duration)4 PageViewData (com.microsoft.applicationinsights.smoketest.schemav2.PageViewData)3 HttpServletResponse (javax.servlet.http.HttpServletResponse)3