示例#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);
        }
示例#2
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));
        }
示例#3
0
 private static async Task AssertOnSubmitExceptionsAsync()
 {
     await PollingService.PollUntilPresentAsync(
         AS4Component.FullOutputPath,
         fs => fs.Any(f => f.Name.EndsWith(".exception.details")) &&
         fs.Any(f => f.Name.EndsWith(".exception.details")));
 }
        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();
        }
示例#5
0
        public async Task Test_8_2_7_SubmitMessage_With_SendingPMode_Specifying_Non_Existing_Url_Result_In_Send_Exception_On_Disk()
        {
            // Act
            AS4Component.PutSubmitMessage("8.2.7-pmode", AS4Component.SubmitPayloadImage);

            // Assert
            await PollingService.PollUntilPresentAsync(AS4Component.ExceptionsPath);
        }
示例#6
0
        public async Task Test_8_2_6_SubmitMessage_With_SendingPMode_Referencing_Non_Existing_Encryption_Certificate_Result_In_Send_Exception_On_Disk()
        {
            // Act
            AS4Component.PutSubmitMessage("8.2.6-pmode", AS4Component.SubmitPayloadImage);

            // Assert
            await PollingService.PollUntilPresentAsync(AS4Component.ExceptionsPath);
        }
示例#7
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);
        }
示例#9
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"));
        }
示例#10
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));
        }
示例#11
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();
        }
示例#12
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();
        }
        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);
        }
示例#14
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();
        }
示例#15
0
        public async Task Test_8_2_1_SubmitMessage_That_Tries_To_Override_SendingPMode_Values_Result_In_Submit_Exceptions_On_Disk()
        {
            // Act
            AS4Component.PutSubmitMessage(
                "8.2.1-pmode",
                submit => submit.MessageInfo = new MessageInfo {
                Mpc = "Some other than pmode mpc"
            },
                AS4Component.SubmitPayloadImage);

            // Assert
            await PollingService.PollUntilPresentAsync(
                AS4Component.FullOutputPath,
                fs => fs.Any(f => f.Name.EndsWith(".exception.details")) &&
                fs.Any(f => f.Name.EndsWith(".exception.details")));
        }
示例#16
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();
        }
示例#17
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();
        }
示例#18
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}");
        }
示例#19
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_2_8_Send_AS4Message_To_Receiving_MSH_That_Cant_Find_PMode_Result_In_Notification_Error()
        {
            // Arrange
            AS4Component.Start();

            // Act
            AS4Component.PutSubmitMessage("8.2.8-pmode", AS4Component.SubmitPayloadImage);

            // Assert
            IEnumerable <FileInfo> errors =
                await PollingService.PollUntilPresentAsync(AS4Component.ErrorsPath);

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

            Assert.True(notification != null, "Found Error notification cannot be deserialized to a 'NotifyMessage'");
            Assert.True(notification.StatusInfo != null, "Found Error notification doesn't hava a <StatusInfo/> element");

            Assert.Equal(Status.Error, notification.StatusInfo.Status);
            Assert.True(
                notification.StatusInfo.Any.First().SelectSingleNode("//*[local-name()='ErrorDetail']")?.InnerText != null,
                "Found Error notification doesn't have a <SignalMessage/> included");
        }
        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);
        }
示例#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);
        }