use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project cas by apereo.
the class SamlIdPSaml1ArtifactResolutionProfileHandlerControllerTests method verifyFault.
@Test
@Order(2)
public void verifyFault() throws Exception {
val response = new MockHttpServletResponse();
val request = new MockHttpServletRequest();
request.setMethod("POST");
request.setContentType(MediaType.TEXT_XML_VALUE);
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();
val artifactResolve = getArtifactResolve();
body.getUnknownXMLObjects().add(artifactResolve);
envelope.setBody(body);
val xml = SamlUtils.transformSamlObject(openSamlConfigBean, envelope).toString();
request.setContent(xml.getBytes(StandardCharsets.UTF_8));
controller.handlePostRequest(response, request);
assertEquals(HttpStatus.SC_OK, response.getStatus());
assertNotNull(request.getAttribute(FaultString.class.getSimpleName()));
}
use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project ddf by codice.
the class AttributeQueryClient method createSoapMessage.
/**
* Creates a SOAP message of the AttributeQuery request.
*
* @param attributeQuery is added to the SOAP message
* @return soapElement is the Element of the SOAP message
*/
private Element createSoapMessage(AttributeQuery attributeQuery) throws AttributeQueryException {
LOGGER.debug("Creating SOAP message from the SAML AttributeQuery.");
Envelope envelope = SamlProtocol.createSoapMessage(attributeQuery);
LOGGER.debug("SOAP message from the SAML AttributeQuery created.");
try {
return new EnvelopeMarshaller().marshall(envelope);
} catch (MarshallingException e) {
throw new AttributeQueryException("Cannot marshall SOAP object to an Element.", e);
}
}
use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project pac4j by pac4j.
the class Pac4jHTTPPostDecoder method doDecode.
@Override
protected void doDecode() throws MessageDecodingException {
final var messageContext = new SAML2MessageContext();
if (WebContextHelper.isPost(context)) {
final var relayState = this.context.getRequestParameter("RelayState").orElse(null);
logger.debug("Decoded SAML relay state of: {}", relayState);
SAMLBindingSupport.setRelayState(messageContext.getMessageContext(), relayState);
final var base64DecodedMessage = this.getBase64DecodedMessage();
final var xmlObject = this.unmarshallMessage(new ByteArrayInputStream(base64DecodedMessage));
SAML2Utils.logProtocolMessage(xmlObject);
final SAMLObject inboundMessage;
if (xmlObject instanceof Envelope) {
final var soapMessage = (Envelope) xmlObject;
messageContext.getSOAP11Context().setEnvelope(soapMessage);
try {
new SAMLSOAPDecoderBodyHandler().invoke(messageContext.getMessageContext());
} catch (final MessageHandlerException e) {
throw new MessageDecodingException("Cannot decode SOAP envelope", e);
}
} else {
inboundMessage = (SAMLObject) xmlObject;
messageContext.getMessageContext().setMessage(inboundMessage);
}
logger.debug("Decoded SAML message");
this.populateBindingContext(messageContext);
this.setMessageContext(messageContext.getMessageContext());
} else {
throw new MessageDecodingException("This message decoder only supports the HTTP POST method");
}
}
use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project ApplicationInsights-Java by microsoft.
the class AiSmokeTest method waitForHealthCheckTelemetryIfNeeded.
private static void waitForHealthCheckTelemetryIfNeeded(String contextRootUrl) throws InterruptedException, ExecutionException {
if (!requestCaptureEnabled) {
return;
}
Stopwatch receivedTelemetryTimer = Stopwatch.createStarted();
int requestTelemetryFromHealthCheckTimeout;
if (currentImageName.startsWith("javase_")) {
requestTelemetryFromHealthCheckTimeout = APPLICATION_READY_TIMEOUT_SECONDS;
} else {
requestTelemetryFromHealthCheckTimeout = TELEMETRY_RECEIVE_TIMEOUT_SECONDS;
}
try {
mockedIngestion.waitForItem(new Predicate<Envelope>() {
@Override
public boolean test(Envelope input) {
if (!"RequestData".equals(input.getData().getBaseType())) {
return false;
}
RequestData data = (RequestData) ((Data<?>) input.getData()).getBaseData();
return contextRootUrl.equals(data.getUrl()) && "200".equals(data.getResponseCode());
}
}, requestTelemetryFromHealthCheckTimeout, TimeUnit.SECONDS);
System.out.printf("Received request telemetry after %.3f seconds...%n", receivedTelemetryTimer.elapsed(TimeUnit.MILLISECONDS) / 1000.0);
System.out.println("Clearing any RequestData from health check.");
} catch (java.util.concurrent.TimeoutException e) {
throw new TimeoutException("request telemetry from application health check", requestTelemetryFromHealthCheckTimeout, TimeUnit.SECONDS, e);
}
}
use of com.microsoft.applicationinsights.smoketest.schemav2.Envelope in project ApplicationInsights-Java by microsoft.
the class CoreAndFilterTests method testHttpRequest.
@Test
@TargetUri("/trackHttpRequest")
public void testHttpRequest() throws Exception {
mockedIngestion.waitForItems("RequestData", 5);
int totalItems = mockedIngestion.getItemCount();
int expectedItems = 5;
assertEquals(String.format("There were %d extra telemetry items received.", totalItems - expectedItems), expectedItems, totalItems);
// TODO get HttpRequest data envelope and verify value
List<Domain> requests = mockedIngestion.getTelemetryDataByType("RequestData");
// true
assertThat(requests, hasItem(allOf(hasName("HttpRequestDataTest"), hasResponseCode("200"), hasDuration(new Duration(4711)), hasSuccess(true))));
assertThat(requests, hasItem(allOf(hasName("PingTest"), hasResponseCode("200"), hasDuration(new Duration(1)), hasSuccess(true), hasUrl("http://tempuri.org/ping"))));
// false
assertThat(requests, hasItem(allOf(hasName("FailedHttpRequest"), hasResponseCode("404"), hasDuration(new Duration(6666)), hasSuccess(false))));
assertThat(requests, hasItem(allOf(hasName("FailedHttpRequest2"), hasResponseCode("505"), hasDuration(new Duration(8888)), hasSuccess(false), hasUrl("https://www.bingasdasdasdasda.com/"))));
}
Aggregations