Beispiel #1
0
        public async Task Test_8_3_17_AS4Message_Gets_Delivered_To_Payload_Service()
        {
            // Arrange
            AS4Component.OverrideSettings("8.3.17-settings.xml");

            Holodeck.CopyPModeToHolodeckA("8.3.17-pmode.xml");
            Holodeck.PutMessageSinglePayloadToHolodeckA("8.3.16-pmode");

            // Act
            AS4Component.Start();

            // Assert
            IEnumerable <FileInfo> deliverables =
                await PollingService.PollUntilPresentAsync(
                    AS4Component.FullInputPath,
                    fs => fs.Any(f => f.Extension == ".xml"));

            var doc = new XmlDocument();

            doc.LoadXml(File.ReadAllText(deliverables.First().FullName));
            XmlElement locationElement = doc["DeliverMessage"]?["Payloads"]?["Payload"]?["Location"];

            Assert.True(locationElement != null, "No payload location found in delivered DeliverMessage");

            HttpResponseMessage downloadResponse = await PayloadServiceClient.GetAsync(locationElement.InnerText);

            Assert.Equal(HttpStatusCode.OK, downloadResponse.StatusCode);
        }
        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");
        }
Beispiel #3
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));
        }
Beispiel #4
0
        public void Test_8_3_18_AS4Message_Gets_Delivered_To_Http_Target()
        {
            // Before
            const string location = "http://localhost:4001/";

            using (SpyHttpDeliverTarget deliverTarget = SpyHttpDeliverTarget.AtLocation(location))
            {
                // Arrange
                Holodeck.CopyPModeToHolodeckA("8.3.18-pmode.xml");
                Holodeck.PutMessageSinglePayloadToHolodeckA("8.3.17-pmode");

                // Act
                AS4Component.Start();

                // Assert
                Assert.True(deliverTarget.IsCalled, "Receive Single Payload Deliver HTTP Integration Test failed");
                string deliverContent = deliverTarget.DeliveredMessage;
                Assert.False(String.IsNullOrEmpty(deliverContent), "Delivered Message was empty");

                var doc = new XmlDocument();
                doc.LoadXml(deliverContent);
                XmlNode deliverMessageNode = doc.SelectSingleNode("//*[local-name()='DeliverMessage']");
                Assert.NotNull(deliverMessageNode);
            }
        }
        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();
        }
Beispiel #6
0
        public async Task Test_8_3_11_AS4Message_Gets_Responded_With_Non_Repudiation_Receipt()
        {
            // Arrange
            AS4Component.Start();
            Holodeck.CopyPModeToHolodeckA("8.3.11-pmode.xml");

            // Act
            Holodeck.PutMessageSinglePayloadToHolodeckA("8.3.11-pmode");

            // Assert
            await PollingService.PollUntilPresentAsync(Holodeck.HolodeckALocations.InputPath);
        }
        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);
        }
Beispiel #8
0
        public async Task Test_8_3_14_AS4Message_Test_Message_Gets_Responded_But_Not_Delivered()
        {
            // Arrange
            AS4Component.Start();
            Holodeck.CopyPModeToHolodeckA("8.3.14-pmode.xml");

            // Act
            Holodeck.PutMessageSinglePayloadToHolodeckA("8.3.14-pmode");

            // Assert
            await PollingService.PollUntilPresentAsync(Holodeck.HolodeckALocations.InputPath);

            Assert.Empty(Directory.GetFiles(AS4Component.FullInputPath, "*.xml"));
        }
        public async Task Test_8_4_1_Received_AS4Message_That_Cant_Be_Linked_To_ReceivingPMode_Result_In_Processing_Error()
        {
            // Arrange
            Holodeck.CopyPModeToHolodeckA("8.4.1-pmode.xml");

            // Act
            Holodeck.PutMessageSinglePayloadToHolodeckA("8.4.1-pmode");

            // Assert
            await PollingService.PollUntilPresentAsync(
                Holodeck.HolodeckALocations.InputPath,
                fs => fs.Any(f => f.Extension == ".xml"));

            Holodeck.AssertErrorOnHolodeckA(ErrorCode.Ebms0001);
        }
Beispiel #10
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();
        }
Beispiel #11
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();
        }
Beispiel #12
0
        public async Task Test_8_3_13_AS4Message_With_Single_Payload_Gets_Responded_With_Signed_NonRepudiation_Receipt()
        {
            // Arrange
            AS4Component.Start();
            Holodeck.CopyPModeToHolodeckA("8.3.13-pmode.xml");

            // Act
            Holodeck.PutMessageSinglePayloadToHolodeckA("8.3.13-pmode");

            // Assert
            await PollingService.PollUntilPresentAsync(
                Holodeck.HolodeckALocations.InputPath,
                fs => fs.Any(f => f.Extension == ".xml"),
                timeout : TimeSpan.FromSeconds(50));
        }
Beispiel #13
0
        public async Task Test_8_3_1_AS4Message_With_Single_Payload_Result_In_File_Deliver()
        {
            // Arrange
            AS4Component.Start();
            Holodeck.CopyPModeToHolodeckA("8.3.1-pmode.xml");

            // Act
            Holodeck.PutMessageSinglePayloadToHolodeckA("8.3.1-pmode");

            // Assert
            await PollingService.PollUntilPresentAsync(
                AS4Component.FullInputPath,
                fs => fs.Any(f => f.Extension == ".xml"));

            Holodeck.AssertSinglePayloadOnHolodeckA();
        }
Beispiel #14
0
        private async Task TestAS4MessageWithMultiplePayloadsUsingPModeAsync(string pmodeId)
        {
            // Arrange
            AS4Component.Start();
            Holodeck.CopyPModeToHolodeckA($"{pmodeId}.xml");

            // Act
            Holodeck.PutMessageTwoPayloadsToHolodeckA(pmodeId);

            // Assert
            await PollingService.PollUntilPresentAsync(
                AS4Component.FullInputPath,
                fs => fs.Count() == 3 &&
                fs.Count(f => f.Extension == ".jpg") == 1 &&
                fs.Count(f => f.Extension == ".xml") == 2);

            Holodeck.AssertSinglePayloadOnHolodeckA();
        }
        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");
        }
Beispiel #16
0
        /// <summary>
        /// Compares the given resources with the given log entries
        /// -- Might throw a System.ArgumentNullException
        /// -- Might throw a System.ArgumentException
        /// </summary>
        /// <param name="resources">array of resources; [0] contains the file resources, [1] contains the registry resources</param>
        /// <param name="log">a log entry; the first dimension is the row, the second is the column</param>
        /// <returns>an ArrayList containing strings of error messages produced during the comparison</returns>
        public static string[] CompareIncludedResources(Holodeck.Resource[][] resources, Hashtable[] knownResources)
        {
            Hashtable fileResources = CreateHashtable (resources[0]);
            Hashtable registryResouces = CreateHashtable (resources[1]);

            System.Collections.ArrayList[] diff = new System.Collections.ArrayList[2];
            diff[0] = CompareResourceTables (knownResources[0], fileResources, false);
            diff[1] = CompareResourceTables (knownResources[1], registryResouces, false);

            string[] differences = new string[diff[0].Count + diff[1].Count];
            int i = 0;
            for (int round = 0; round < 2; round++) {
                for (int j = 0; j < diff[round].Count; j++, i++) {
                    differences[i] = (string) diff[round][j];
                }
            }

            return differences;
        }
        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");
        }
Beispiel #18
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();
        }
Beispiel #19
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}");
        }
Beispiel #20
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");
        }
        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);
        }
Beispiel #22
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);
        }
Beispiel #23
0
        /// <summary>
        /// Creates a hash table of resources based on their names
        /// </summary>
        /// <param name="resources">arrray of resources</param>
        /// <returns>the created hash table</returns>
        protected static Hashtable CreateHashtable(Holodeck.Resource[] resources)
        {
            Hashtable retTable = new Hashtable ();
            for (int i = 0; i < resources.Length; i++)
            {
                try {
                    retTable.Add (resources[i].Name, resources[i]);
                } catch (ArgumentNullException e) {
                    Log.printError ("ResourcesPaneTest.Helper.CreateHashtable Error while processing resource No." + i + " - " + e.Message);
                } catch (ArgumentException e) {
                    Log.printError ("ResourcesPaneTest.Helper.CreateHashtable Error while processing resource No." + i + " - " + e.Message);
                    retTable.Remove (resources[i].Name);
                    retTable.Add (resources[i].Name, resources[i]);
                }
            }

            return retTable;
        }
Beispiel #24
0
        /// <summary>
        /// Compares the given resources with the given log entries
        /// -- Might throw a System.ArgumentNullException
        /// -- Might throw a System.ArgumentException
        /// </summary>
        /// <param name="resources">array of resources; [0] contains the file resources, [1] contains the registry resources</param>
        /// <param name="log">a log entry; the first dimension is the row, the second is the column</param>
        /// <returns>a string[] containing strings of error messages produced during the comparison</returns>
        public static string[] CompareResourcesWithLogs(Holodeck.Resource[][] resources, String[][] log)
        {
            Hashtable fileResources = CreateHashtable (resources[0]);
            Hashtable registryResources = CreateHashtable (resources[1]);
            Hashtable[] logResources = ProcessLog (log);

            System.Collections.ArrayList[] diff = new System.Collections.ArrayList[2];
            diff[0] = CompareResourceTables (logResources[0], fileResources, true);
            diff[1] = CompareResourceTables (logResources[1], registryResources, true);

            string[] differences = new string[diff[0].Count + diff[1].Count];
            int i = 0;
            for (int round = 0; round < 2; round++)
            {
                for (int j = 0; j < diff[round].Count; j++, i++)
                {
                    differences[i] = (string) diff[round][j];
                }
            }

            return differences;
        }