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