Esempio n. 1
0
        public async Task Test_8_3_16_Pulled_AS4Message_Gets_Delivered()
        {
            // Arrange
            AS4Component.OverrideSettings("8.3.16-settings.xml");
            AS4Component.Start();

            Holodeck.CopyPModeToHolodeckB("8.3.16-pmode.xml");

            // Act
            Holodeck.PutMessageSinglePayloadToHolodeckB("ex-pm-pull-ut");

            // Assert
            await PollingService.PollUntilPresentAsync(
                AS4Component.FullInputPath,
                fs => fs.Count() == 2,
                timeout : TimeSpan.FromSeconds(50));

            var deliverDir = new DirectoryInfo(AS4Component.FullInputPath);

            FileInfo[] deliverables = deliverDir.GetFiles();

            Assert.NotNull(deliverables.FirstOrDefault(f => f.Extension == ".xml"));
            Assert.NotNull(deliverables.FirstOrDefault(f => f.Extension == ".jpg" &&
                                                       f.Length == Holodeck.HolodeckAJpegPayload.Length));
        }
        public void AS4ComponentDoesntAlterEncryptedDataFromOriginalHolodeckMessage()
        {
            // Arrange
            Holodeck.CopyPModeToHolodeckB("8.1.22-pmode.xml");

            AS4Component.OverrideSettings(DynamicDiscoverySettings);
            AS4Component.Start();

            InsertSmpConfigurationForAS4Component(ReceiveAgentEndpoint, enableEncryption: false);

            var str = VirtualStream.Create();

            str.Write(Properties.Resources._8_1_22_message, 0, Properties.Resources._8_1_22_message.Length);
            str.Position = 0;

            const string contentType =
                "multipart/related; boundary= \"MIMEBoundary_4ac2a25e8a3af891754f9f7316ac08062c50de1368ddfada\"; type=\"application/soap+xml\";";

            // Act
            new StubSender().SendMessage(str, contentType);

            // Assert
            Assert.True(
                PollingAt(AS4ReceiptsPath),
                "No Receipt found at AS4.NET Component for Encrypted Dynamic Forwarding Test");
        }
        public async Task Test_8_1_16_Respond_With_UserMessage_When_Receive_PullRequest_Result_In_Notified_Receipt()
        {
            // Arrange
            AS4Component.OverrideSettings("8.1.16-settings.xml");
            AS4Component.Start();

            AS4Component.PutSubmitMessage(
                "8.1.16-pmode",
                submit => submit.MessageInfo = new MessageInfo {
                Mpc = "http://example.holodeckb2b.org/mpc/1"
            },
                AS4Component.SubmitPayloadImage);

            // Act
            Holodeck.CopyPModeToHolodeckB("8.1.16-receive-pmode.xml");
            Holodeck.CopyPModeToHolodeckB("8.1.16-pmode.xml");

            // Assert
            await PollingService.PollUntilPresentAsync(
                AS4Component.ReceiptsPath,
                fs => fs.Any(f => f.Extension == ".xml"),
                timeout : TimeSpan.FromMinutes(1).Add(TimeSpan.FromSeconds(30)));

            Holodeck.AssertDeliverMessageOnHolodeckB();
            AS4Component.AssertReceipt();
        }
        public async Task Test_8_1_18_Respond_With_Error_When_Receive_PullRequest_Is_Not_Authorized()
        {
            // Arrange
            AS4Component.OverrideSettings("8.1.18-settings.xml");
            AS4Component.Start();

            // Act
            Holodeck.CopyPModeToHolodeckB("8.1.18-receive-pmode.xml");
            Holodeck.CopyPModeToHolodeckB("8.1.18-pmode.xml");

            // Assert
            await PollingService.PollUntilPresentAsync(Holodeck.HolodeckBLocations.InputPath);
        }
Esempio n. 5
0
        public async Task Test_8_1_1_AS4Message_With_Single_Payload_Result_In_Notified_Receipt()
        {
            // Arrange
            AS4Component.Start();
            Holodeck.CopyPModeToHolodeckB("8.1.1-pmode.xml");

            // Act
            AS4Component.PutSubmitMessageSinglePayload("8.1.1-pmode");

            // Assert
            await PollingService.PollUntilPresentAsync(AS4Component.ReceiptsPath);

            Holodeck.AssertSinglePayloadOnHolodeckB();
            AS4Component.AssertReceipt();
        }
Esempio n. 6
0
        private async Task TestAS4MessageWithMultiplePayloadsUsingPModeAsync(string pmodeId)
        {
            // Arrange
            AS4Component.Start();
            Holodeck.CopyPModeToHolodeckB($"{pmodeId}.xml");

            // Act
            AS4Component.PutSubmitMessageMultiplePayloads(pmodeId);

            // Assert
            await PollingService.PollUntilPresentAsync(AS4Component.ReceiptsPath);

            AS4Component.AssertMultiplePayloadsOnHolodeckB();
            AS4Component.AssertReceipt();
        }
        public void IntermediateAS4MshCanEncryptSignedMessageAndDoesntAlterSignatureFromOriginalHolodeckMessage()
        {
            // Arrange
            Holodeck.CopyPModeToHolodeckB("8.1.21-pmode.xml");

            AS4Component.OverrideSettings(DynamicDiscoverySettings);
            AS4Component.Start();

            InsertEnabledEncryptionForHolodeck(url: ReceiveAgentEndpoint);

            // Act
            new StubSender().SendMessage(Properties.Resources._8_1_21_message, Constants.ContentTypes.Soap);

            // Assert
            Assert.True(
                PollingAt(AS4ReceiptsPath),
                "No Receipt found at AS4.NET Component for Simple Dynamic Discovery Test");
        }
        public void HolodeckAcceptsEncryptedDynamicForwardedMessage()
        {
            // Arrange
            Holodeck.CopyPModeToHolodeckB("8.1.20-pmode.xml");

            AS4Component.OverrideSettings(DynamicDiscoverySettings);
            AS4Component.Start();

            InsertSmpConfigurationForAS4Component(url: ReceiveAgentEndpoint, enableEncryption: true);

            AS4Message userMessage = UserMessageWithAttachment(argRefPModeId: "dynamic-forwarding-pmode");

            // Act: send the UserMessage to the AS4.NET Component, so it can be made complete by Dynamic Discover the info from the SMP Configuration
            SendMultiHopAS4Message(userMessage);

            // Assert
            Assert.True(
                PollingAt(AS4ReceiptsPath),
                "No Receipt found at AS4.NET Component for Encrypted Dynamic Forwarding Test");
        }
Esempio n. 9
0
        public async Task Test_8_1_15_SubmitMessage_Via_Http_Result_In_Notified_Receipt()
        {
            // Arrange
            AS4Component.OverrideSettings("8.1.15-settings.xml");
            AS4Component.Start();
            const string submitAgentHttpEndpoint = "http://localhost:5001/";

            Holodeck.CopyPModeToHolodeckB("8.1.15-pmode.xml");

            // Act
            await HttpClient.SendMessageAsync(
                submitAgentHttpEndpoint,
                submitmessage_8_1_15_xml,
                "application/xml");

            // Assert
            await PollingService.PollUntilPresentAsync(AS4Component.ReceiptsPath);

            Holodeck.AssertSinglePayloadOnHolodeckB();
            AS4Component.AssertReceipt();
        }
Esempio n. 10
0
        public async Task Test_8_1_10_AS4Message_With_Single_Payload_And_MessageProperties_Result_In_Delivered_UserMessage_With_Same_MessageProperties()
        {
            // Arrange
            AS4Component.Start();
            Holodeck.CopyPModeToHolodeckB("8.1.10-pmode.xml");

            // Act
            AS4Component.PutSubmitMessage(
                "8.1.10-pmode",
                submit => submit.MessageProperties = new []
            {
                new MessageProperty("Important", "Yes"),
                new MessageProperty("OriginalSender", "AS4.NET")
            },
                AS4Component.SubmitPayloadImage);

            // Assert
            await PollingService.PollUntilPresentAsync(AS4Component.ReceiptsPath);

            Holodeck.AssertSinglePayloadOnHolodeckB();
            AS4Component.AssertReceipt();

            FileInfo userMessageFile =
                new DirectoryInfo(Holodeck.HolodeckBLocations.InputPath)
                .GetFiles("*.xml")
                .FirstOrDefault();

            Assert.True(userMessageFile != null, "No UserMessage found at Holodeck B");

            var userMessageXml = new XmlDocument();

            userMessageXml.Load(userMessageFile.FullName);
            XmlNode messagePropertyNode = userMessageXml.SelectSingleNode("//*[local-name()='MessageProperties']");

            Assert.True(messagePropertyNode != null, "UserMessage at Holodeck B doesn't contain <MessageProperties/> element");
            Assert.True(
                messagePropertyNode.ChildNodes?.Count == 2,
                $"UserMessage at Holodeck B doesn't contain 2 MessageProperties but {messagePropertyNode.ChildNodes?.Count}");
        }
Esempio n. 11
0
        public async Task Test_8_1_12_AS4Message_With_Single_Payload_Result_In_Notified_Signed_Non_Repudiation_Receipt()
        {
            // Arrange
            AS4Component.Start();
            Holodeck.CopyPModeToHolodeckB("8.1.12-pmode.xml");

            // Act
            AS4Component.PutSubmitMessageSinglePayload("8.1.12-pmode");

            IEnumerable <FileInfo> receipts =
                await PollingService.PollUntilPresentAsync(AS4Component.ReceiptsPath);

            string xml          = File.ReadAllText(receipts.First().FullName);
            var    notification = AS4XmlSerializer.FromString <NotifyMessage>(xml);

            Assert.True(notification != null, "Found Receipt notification cannot be deserialized to a NotifyMessage");
            Assert.True(notification.StatusInfo != null, "Found Receipt notification doesn't have a <StatusInfo/> element");
            Assert.Equal(Status.Delivered, notification.StatusInfo.Status);
            Assert.True(notification.StatusInfo.Any?.Any(), "Found Receipt notification doesn't have a <SignalMessage/> included");
            Assert.True(
                notification.StatusInfo.Any?.First()?.SelectSingleNode("//*[local-name()='NonRepudiationInformation']") != null,
                "Found Receipt notification doesn't have a <NonRepudiationInformation/> element");
        }
Esempio n. 12
0
        public async Task Test_8_1_11_AS4Message_With_Single_Payload_And_MessageIds_Result_In_Notified_Receipt_With_Same_MessageIds()
        {
            // Arrange
            AS4Component.Start();
            Holodeck.CopyPModeToHolodeckB("8.1.11-pmode.xml");

            // Act
            AS4Component.PutSubmitMessage(
                "8.1.11-pmode",
                submit =>
            {
                submit.MessageInfo.MessageId      = Guid.NewGuid().ToString();
                submit.MessageInfo.RefToMessageId = Guid.NewGuid().ToString();
            },
                AS4Component.SubmitPayloadImage);

            // Assert
            await PollingService.PollUntilPresentAsync(AS4Component.ReceiptsPath);

            IEnumerable <FileInfo> deliveredFiles = new DirectoryInfo(Holodeck.HolodeckBLocations.InputPath).GetFiles();

            AS4Component.AssertEarthPayload(deliveredFiles.FirstOrDefault(f => f.Extension == ".jpg"));

            XmlDocument userDoc    = LoadUserMessageDocFrom(deliveredFiles);
            XmlDocument receiptDoc = LoadReceiptDocFrom(AS4ReceiptsPath);

            XmlNode refToMessageIdNode = receiptDoc.SelectSingleNode("//*[local-name()='RefToMessageId']");

            Assert.True(refToMessageIdNode != null, "Cannot find 'RefToMessageId' node in Receipt at AS4.NET component");

            XmlNode messageIdNode = userDoc.SelectSingleNode("//*[local-name()='MessageId']");

            Assert.True(messageIdNode != null, "Cannot find 'MessageId' node in UserMessage at Holodeck B");

            Assert.Equal(messageIdNode.InnerText, refToMessageIdNode.InnerText);
        }
        public async Task Test_8_1_13_Send_AS4Message_Wrongly_Signed_Result_In_Async_Error()
        {
            // Arrange
            AS4Component.Start();
            Holodeck.CopyPModeToHolodeckB("8.1.13-pmode.xml");

            string ebmsMessageId = Guid.NewGuid().ToString();

            AS4Component.PutSubmitMessage(
                "8.1.13-pmode",
                submit => submit.MessageInfo.MessageId = ebmsMessageId,
                AS4Component.SubmitPayloadImage);

            string messageWrongSigned = ReplaceSubmitMessageIdWith(ebmsMessageId);

            // Act
            await HttpClient.SendMessageAsync(
                Holodeck.HolodeckBHttpEndpoint,
                messageWrongSigned,
                Constants.ContentTypes.Soap);

            // Assert
            await PollingService.PollUntilPresentAsync(AS4Component.ErrorsPath);
        }