Beispiel #1
0
        private static async Task RespondToPullRequestAsync(string url, Action <HttpListenerResponse> response)
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            var waiter = new ManualResetEvent(false);

            StubHttpServer.StartServer(url, response, waiter);
            waiter.WaitOne(timeout: TimeSpan.FromSeconds(10));

            // Wait till the response is processed correctly.
            await Task.Delay(TimeSpan.FromSeconds(10));
        }
Beispiel #2
0
        private async Task CorrectHandlingOnSynchronouslyReceivedMultiHopReceipt(
            bool actAsIntermediaryMsh,
            string receivePModeId,
            OutStatus expectedOutStatus,
            Operation expectedSignalOperation)
        {
            // Arrange
            SendingProcessingMode pmode             = CreateMultihopPMode(StubListenLocation);
            UserMessage           simpleUserMessage = CreateMultihopUserMessage(receivePModeId, pmode);

            AS4Message as4Message = AS4Message.Create(simpleUserMessage, pmode);

            var signal     = new ManualResetEvent(false);
            var serializer = new SoapEnvelopeSerializer();

            StubHttpServer.StartServer(
                StubListenLocation,
                res =>
            {
                res.StatusCode  = 200;
                res.ContentType = Constants.ContentTypes.Soap;

                var receipt = Receipt.CreateFor(
                    $"receipt-{Guid.NewGuid()}",
                    as4Message.FirstUserMessage,
                    userMessageSendViaMultiHop: true);

                serializer.Serialize(AS4Message.Create(receipt), res.OutputStream);
            },
                signal);

            // Act
            PutMessageToSend(as4Message, pmode, actAsIntermediaryMsh);

            // Assert
            signal.WaitOne();

            OutMessage sentMessage = await PollUntilPresent(
                () => _databaseSpy.GetOutMessageFor(m => m.EbmsMessageId == simpleUserMessage.MessageId),
                timeout : TimeSpan.FromSeconds(10));

            Assert.Equal(expectedOutStatus, sentMessage.Status.ToEnum <OutStatus>());

            InMessage receivedMessage = await PollUntilPresent(
                () => _databaseSpy.GetInMessageFor(m => m.EbmsRefToMessageId == simpleUserMessage.MessageId),
                timeout : TimeSpan.FromSeconds(10));

            Assert.Equal(MessageType.Receipt, receivedMessage.EbmsMessageType);
            Assert.Equal(expectedSignalOperation, receivedMessage.Operation);
        }
Beispiel #3
0
        private void TestReceiveNRReceiptWith(string ebmsMessageId, Func <int, int> selection)
        {
            SendingProcessingMode nrrPMode = VerifyNRReceiptsPMode();
            X509Certificate2      cert     = new StubCertificateRepository().GetStubCertificate();

            AS4Message userMessage = SignedUserMessage(ebmsMessageId, nrrPMode, cert);
            AS4Message nrReceipt   = SignedNRReceipt(cert, userMessage, selection);

            var waitHandle = new ManualResetEvent(initialState: false);

            StubHttpServer.StartServer(StubListenLocation, new AS4MessageResponseHandler(nrReceipt).WriteResponse, waitHandle);

            PutMessageToSend(userMessage, nrrPMode, actAsIntermediaryMsh: false);
            waitHandle.WaitOne();
        }
Beispiel #4
0
        public void NoExceptionsAreLoggedWhenPullSenderIsNotAvailable()
        {
            // Arrange
            string pullSenderUrl = RetrievePullingUrlFromConfig();

            _databaseSpy.ClearDatabase();

            // Act
            var waiter = new ManualResetEvent(false);

            StubHttpServer.StartServer(pullSenderUrl, _ => throw new InvalidOperationException(), waiter);
            waiter.WaitOne(timeout: TimeSpan.FromSeconds(5));

            // Assert
            _as4Msh.Dispose();
            Assert.Empty(_databaseSpy.GetInExceptions(r => true));
        }