use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project ApplicationInsights-Java by microsoft.
the class TraceLog4j2Test method testTraceLog4j2.
@Test
@TargetUri("/traceLog4j2")
public void testTraceLog4j2() throws Exception {
List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
List<Envelope> mdList = mockedIngestion.waitForMessageItemsInRequest(3);
Envelope rdEnvelope = rdList.get(0);
Envelope mdEnvelope1 = mdList.get(0);
Envelope mdEnvelope2 = mdList.get(1);
Envelope mdEnvelope3 = mdList.get(2);
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
List<MessageData> logs = mockedIngestion.getMessageDataInRequest();
logs.sort(Comparator.comparing(MessageData::getSeverityLevel));
MessageData md1 = logs.get(0);
MessageData md2 = logs.get(1);
MessageData md3 = logs.get(2);
assertEquals("This is log4j2 warn.", md1.getMessage());
assertEquals(SeverityLevel.Warning, md1.getSeverityLevel());
assertEquals("Logger", md1.getProperties().get("SourceType"));
assertEquals("WARN", md1.getProperties().get("LoggingLevel"));
assertEquals("smoketestapp", md1.getProperties().get("LoggerName"));
assertNotNull(md1.getProperties().get("ThreadName"));
assertEquals("MDC value", md1.getProperties().get("MDC key"));
assertEquals(5, md1.getProperties().size());
assertEquals("This is log4j2 error.", md2.getMessage());
assertEquals(SeverityLevel.Error, md2.getSeverityLevel());
assertEquals("Logger", md2.getProperties().get("SourceType"));
assertEquals("ERROR", md2.getProperties().get("LoggingLevel"));
assertEquals("smoketestapp", md1.getProperties().get("LoggerName"));
assertNotNull(md1.getProperties().get("ThreadName"));
assertEquals(4, md2.getProperties().size());
assertEquals("This is log4j2 fatal.", md3.getMessage());
assertEquals(SeverityLevel.Critical, md3.getSeverityLevel());
assertEquals("Logger", md3.getProperties().get("SourceType"));
assertEquals("FATAL", md3.getProperties().get("LoggingLevel"));
assertEquals("smoketestapp", md3.getProperties().get("LoggerName"));
assertNotNull(md3.getProperties().get("ThreadName"));
assertEquals(4, md3.getProperties().size());
assertParentChild(rd, rdEnvelope, mdEnvelope1, "GET /TraceLog4j2UsingAgent/traceLog4j2");
assertParentChild(rd, rdEnvelope, mdEnvelope2, "GET /TraceLog4j2UsingAgent/traceLog4j2");
assertParentChild(rd, rdEnvelope, mdEnvelope3, "GET /TraceLog4j2UsingAgent/traceLog4j2");
}
use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project ApplicationInsights-Java by microsoft.
the class TraceLog4j12Test method testTraceLog4j12.
@Test
@TargetUri("/traceLog4j12")
public void testTraceLog4j12() throws Exception {
List<Envelope> rdList = mockedIngestion.waitForItems("RequestData", 1);
List<Envelope> mdList = mockedIngestion.waitForMessageItemsInRequest(3);
Envelope rdEnvelope = rdList.get(0);
Envelope mdEnvelope1 = mdList.get(0);
Envelope mdEnvelope2 = mdList.get(1);
Envelope mdEnvelope3 = mdList.get(2);
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData();
List<MessageData> logs = mockedIngestion.getMessageDataInRequest();
logs.sort(Comparator.comparing(MessageData::getSeverityLevel));
MessageData md1 = logs.get(0);
MessageData md2 = logs.get(1);
MessageData md3 = logs.get(2);
assertEquals("This is log4j1.2 warn.", md1.getMessage());
assertEquals(SeverityLevel.Warning, md1.getSeverityLevel());
assertEquals("Logger", md1.getProperties().get("SourceType"));
assertEquals("WARN", md1.getProperties().get("LoggingLevel"));
assertEquals("smoketestapp", md1.getProperties().get("LoggerName"));
assertNotNull(md1.getProperties().get("ThreadName"));
assertEquals("MDC value", md1.getProperties().get("MDC key"));
assertEquals(5, md1.getProperties().size());
assertEquals("This is log4j1.2 error.", md2.getMessage());
assertEquals(SeverityLevel.Error, md2.getSeverityLevel());
assertEquals("Logger", md2.getProperties().get("SourceType"));
assertEquals("ERROR", md2.getProperties().get("LoggingLevel"));
assertEquals("smoketestapp", md2.getProperties().get("LoggerName"));
assertNotNull(md2.getProperties().get("ThreadName"));
assertEquals(4, md2.getProperties().size());
assertEquals("This is log4j1.2 fatal.", md3.getMessage());
assertEquals(SeverityLevel.Critical, md3.getSeverityLevel());
assertEquals("Logger", md3.getProperties().get("SourceType"));
assertEquals("FATAL", md3.getProperties().get("LoggingLevel"));
assertEquals("smoketestapp", md3.getProperties().get("LoggerName"));
assertNotNull(md3.getProperties().get("ThreadName"));
assertEquals(4, md3.getProperties().size());
assertParentChild(rd, rdEnvelope, mdEnvelope1, "GET /TraceLog4j1_2UsingAgent/traceLog4j12");
assertParentChild(rd, rdEnvelope, mdEnvelope2, "GET /TraceLog4j1_2UsingAgent/traceLog4j12");
assertParentChild(rd, rdEnvelope, mdEnvelope3, "GET /TraceLog4j1_2UsingAgent/traceLog4j12");
}
use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project entcore by opendigitaleducation.
the class SamlValidator method executeSoapSloRequest.
private void executeSoapSloRequest(JsonObject responseAssertionInfos) throws Exception {
NameID nameId = SamlUtils.buildSAMLObjectWithDefaultName(NameID.class);
nameId.setFormat("urn:oasis:names:tc:SAML:2.0:nameid-format:transient");
nameId.setValue(responseAssertionInfos.getString("nameId"));
LogoutRequest logoutRequest = SamlUtils.buildSAMLObjectWithDefaultName(LogoutRequest.class);
logoutRequest.setID("ENT_" + UUID.randomUUID().toString());
final String sloUri = getLogoutUri(responseAssertionInfos.getString("sp"), SAMLConstants.SAML2_SOAP11_BINDING_URI);
logoutRequest.setDestination(sloUri);
logoutRequest.setIssueInstant(new DateTime());
Issuer issuer = SamlUtils.buildSAMLObjectWithDefaultName(Issuer.class);
issuer.setValue(responseAssertionInfos.getString("idp"));
logoutRequest.setIssuer(issuer);
SessionIndex sessionIndexElement = SamlUtils.buildSAMLObjectWithDefaultName(SessionIndex.class);
sessionIndexElement.setSessionIndex(responseAssertionInfos.getString("sessionIndex"));
logoutRequest.getSessionIndexes().add(sessionIndexElement);
logoutRequest.setNameID(nameId);
Signature signature;
try {
signature = createSignature(true);
} catch (Throwable e) {
throw new Exception("create signature exception", e);
}
logoutRequest.setSignature(signature);
SamlUtils.marshallLogoutRequest(logoutRequest);
if (signature != null) {
Signer.signObject(signature);
}
Body body = SamlUtils.buildSAMLObjectWithDefaultName(Body.class);
body.getUnknownXMLObjects().add(logoutRequest);
Envelope envelope = SamlUtils.buildSAMLObjectWithDefaultName(Envelope.class);
envelope.setBody(body);
final String envlop = SamlUtils.marshallEnvelope(envelope);
HttpClientRequest req = httpClient.postAbs(sloUri, resp -> {
if (resp.statusCode() != 200 && resp.statusCode() != 302) {
resp.bodyHandler(buff -> {
logger.error("Slo error : " + envlop + " - " + buff.toString());
});
} else {
idpAssertionsStore.delete(responseAssertionInfos.getString("_id"), ar -> {
if (ar.failed()) {
logger.error("Error deleting old idp assertion.", ar.cause());
}
});
}
});
req.putHeader("Content-Type", "text/xml");
req.end(envlop);
}
use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project ddf by codice.
the class SamlProtocol method createSoapMessage.
public static Envelope createSoapMessage(SignableSAMLObject signableSAMLObject) {
Body body = soapBodyBuilder.buildObject();
body.getUnknownXMLObjects().add(signableSAMLObject);
Envelope envelope = soapEnvelopeBuilder.buildObject();
envelope.setBody(body);
Header header = soapHeaderBuilder.buildObject();
envelope.setHeader(header);
return envelope;
}
use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project cas by apereo.
the class ECPSamlIdPProfileHandlerControllerTests method getEnvelope.
private Envelope getEnvelope(final String entityId) {
var builder = (SOAPObjectBuilder) openSamlConfigBean.getBuilderFactory().getBuilder(Envelope.DEFAULT_ELEMENT_NAME);
var envelope = (Envelope) builder.buildObject();
builder = (SOAPObjectBuilder) openSamlConfigBean.getBuilderFactory().getBuilder(Header.DEFAULT_ELEMENT_NAME);
val header = (Header) builder.buildObject();
envelope.setHeader(header);
builder = (SOAPObjectBuilder) openSamlConfigBean.getBuilderFactory().getBuilder(Body.DEFAULT_ELEMENT_NAME);
val body = (Body) builder.buildObject();
body.getUnknownXMLObjects().add(getAuthnRequest(entityId));
envelope.setBody(body);
return envelope;
}
Aggregations