Search in sources :

Example 6 with Envelope

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()));
}
Also used : lombok.val(lombok.val) SOAPObjectBuilder(org.opensaml.soap.common.SOAPObjectBuilder) Header(org.opensaml.soap.soap11.Header) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Envelope(org.opensaml.soap.soap11.Envelope) Body(org.opensaml.soap.soap11.Body) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Order(org.junit.jupiter.api.Order) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Test(org.junit.jupiter.api.Test)

Example 7 with Envelope

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);
    }
}
Also used : EnvelopeMarshaller(org.opensaml.soap.soap11.impl.EnvelopeMarshaller) MarshallingException(org.opensaml.core.xml.io.MarshallingException) Envelope(org.opensaml.soap.soap11.Envelope)

Example 8 with Envelope

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");
    }
}
Also used : SAMLSOAPDecoderBodyHandler(org.opensaml.saml.common.binding.impl.SAMLSOAPDecoderBodyHandler) SAML2MessageContext(org.pac4j.saml.context.SAML2MessageContext) MessageDecodingException(org.opensaml.messaging.decoder.MessageDecodingException) ByteArrayInputStream(java.io.ByteArrayInputStream) SAMLObject(org.opensaml.saml.common.SAMLObject) MessageHandlerException(org.opensaml.messaging.handler.MessageHandlerException) Envelope(org.opensaml.soap.soap11.Envelope)

Example 9 with Envelope

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);
    }
}
Also used : RequestData(com.microsoft.applicationinsights.smoketest.schemav2.RequestData) Stopwatch(com.google.common.base.Stopwatch) 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) TimeoutException(com.microsoft.applicationinsights.smoketest.exceptions.TimeoutException)

Example 10 with Envelope

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/"))));
}
Also used : RequestDataMatchers.hasDuration(com.microsoft.applicationinsights.smoketest.matchers.RequestDataMatchers.hasDuration) Duration(com.microsoft.applicationinsights.smoketest.telemetry.Duration) Domain(com.microsoft.applicationinsights.smoketest.schemav2.Domain) DataPoint(com.microsoft.applicationinsights.smoketest.schemav2.DataPoint) Test(org.junit.Test)

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