public Property Updates_Bundled_MessageUnits_For_Forwarding() { return(Prop.ForAll( CreateUserReceiptArb(), messageUnits => { // Before Assert.All( messageUnits, u => GetDataStoreContext.InsertInMessage(new InMessage(u.MessageId))); // Arrange AS4Message received = AS4Message.Create(messageUnits); // Act ExerciseUpdateReceivedMessage( received, CreateNotifyAllSendingPMode(), CreateForwardingReceivingPMode()) .GetAwaiter() .GetResult(); // Assert IEnumerable <InMessage> updates = GetDataStoreContext.GetInMessages( m => received.MessageIds.Contains(m.EbmsMessageId)); Assert.All(updates, u => Assert.True(u.Intermediary)); InMessage primaryUpdate = updates.First(u => u.EbmsMessageId == received.GetPrimaryMessageId()); Assert.Equal(Operation.ToBeForwarded, primaryUpdate.Operation); })); }
public async Task ThenInMessageOperationIsToBeForwarded() { const string messageId = "forwarding_message_id"; var as4Message = AS4Message.Create( new UserMessage( messageId, new CollaborationInfo( agreement: new AgreementReference( value: "forwarding/agreement", type: "forwarding", // Make sure that the forwarding receiving pmode is used; therefore // explicitly set the Id of the PMode that must be used by the receive-agent. pmodeId: "Forward_Push"), service: new Service( value: "Forward_Push_Service", type: "eu:europa:services"), action: "Forward_Push_Action", conversationId: "eu:europe:conversation"))); // Act HttpResponseMessage response = await StubSender.SendAS4Message(_receiveAgentUrl, as4Message); // Assert Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); Assert.True(String.IsNullOrWhiteSpace(await response.Content.ReadAsStringAsync())); InMessage receivedUserMessage = _databaseSpy.GetInMessageFor(m => m.EbmsMessageId == messageId); Assert.NotNull(receivedUserMessage); Assert.Equal(Operation.ToBeForwarded, receivedUserMessage.Operation); }
public async Task SignalMessage_Gets_Saved_As_Duplicate_When_InMessage_Exists_With_Same_EbmsRefToMessageId() { // Arrange string ebmsMessageId = $"receipt-{Guid.NewGuid()}"; string ebmsRefToMessageId = $"user-{Guid.NewGuid()}"; GetDataStoreContext.InsertInMessage( new InMessage(ebmsMessageId) { EbmsRefToMessageId = ebmsRefToMessageId }); var receipt = new Receipt(ebmsMessageId, ebmsRefToMessageId); var context = new MessagingContext( AS4Message.Create(receipt), new ReceivedMessage(Stream.Null), MessagingContextMode.Receive); // Act await Step.ExecuteAsync(context); // Assert InMessage actual = GetDataStoreContext.GetInMessage( m => m.EbmsMessageId == ebmsMessageId && m.EbmsRefToMessageId == ebmsRefToMessageId && m.IsDuplicate); Assert.True(actual != null, "Saved Receipt should be marked as duplicate"); }
private static AS4Message UserMessageWithAttachment(string argRefPModeId) { var user = new UserMessage( Guid.NewGuid().ToString(), HolodeckCollaboration(argRefPModeId), new Party(Constants.Namespaces.EbmsDefaultFrom, new PartyId(Constants.Namespaces.EbmsDefaultFrom)), new Party(HolodeckPartyRole, new PartyId(HolodeckBId, HolodeckBId)), new[] { new PartInfo( href: "cid:earth", properties: new Dictionary <string, string> { ["Part Property"] = "Some Holodeck required Part Property" }, schemas: new Schema[0]) }, new Model.Core.MessageProperty[0]); AS4Message userMessage = AS4Message.Create(user, new SendingProcessingMode { MessagePackaging = { IsMultiHop = true } }); userMessage.AddAttachment(ImageAttachment(id: "earth")); return(userMessage); }
private void InsertUserMessage(string mpc, MessageExchangePattern pattern, Operation operation) { var sendingPMode = new SendingProcessingMode() { Id = "SomePModeId", MessagePackaging = { Mpc = mpc } }; UserMessage userMessage = SendingPModeMap.CreateUserMessage(sendingPMode); AS4Message as4Message = AS4Message.Create(userMessage, sendingPMode); var om = new OutMessage(userMessage.MessageId) { MEP = pattern, Mpc = mpc, ContentType = as4Message.ContentType, EbmsMessageType = MessageType.UserMessage, Operation = operation, MessageLocation = InMemoryMessageBodyStore.Default.SaveAS4Message(location: "some-location", message: as4Message) }; om.SetPModeInformation(sendingPMode); GetDataStoreContext.InsertOutMessage(om); }
public async Task ForwardingWithPushOnPull() { // Arrange const string messageId = "user-message-id"; var tobeForwarded = AS4Message.Create(CreateForwardPushUserMessage(messageId)); // Act InsertToBeForwardedInMessage( pmodeId: "Forward_Push", mep: MessageExchangePattern.Pull, tobeForwarded: tobeForwarded); // Assert: if an OutMessage is created with the correct status and operation await PollUntilPresent( () => _databaseSpy.GetInMessageFor(m => m.EbmsMessageId == messageId && m.Operation == Operation.Forwarded), TimeSpan.FromSeconds(20)); OutMessage outMessage = await PollUntilPresent( () => _databaseSpy.GetOutMessageFor(m => m.EbmsMessageId == messageId), TimeSpan.FromSeconds(5)); var sendingPMode = AS4XmlSerializer.FromString <SendingProcessingMode>(outMessage.PMode); Assert.NotNull(sendingPMode); Assert.Equal(Operation.ToBeProcessed, outMessage.Operation); Assert.Equal(MessageExchangePattern.Push, outMessage.MEP); Assert.Equal(sendingPMode.MessagePackaging.Mpc, outMessage.Mpc); }
public Property Creates_Receipt_For_Each_UserMessage() { return(Prop.ForAll( Gen.Fresh(() => new UserMessage($"user-{Guid.NewGuid()}")) .NonEmptyListOf() .ToArbitrary(), userMessages => { // Arrange AS4Message fixture = AS4Message.Create(userMessages); IEnumerable <string> fixtureMessageIds = fixture.MessageIds; var ctx = new MessagingContext(fixture, MessagingContextMode.Receive) { ReceivingPMode = new ReceivingProcessingMode() }; // Act AS4Message result = ExerciseCreateReceiptAsync(ctx) .GetAwaiter() .GetResult(); // Assert Assert.All( result.MessageUnits, messageUnit => { Assert.IsType <Receipt>(messageUnit); var receipt = (Receipt)messageUnit; Assert.Contains(receipt.RefToMessageId, fixtureMessageIds); Assert.Equal(receipt.RefToMessageId, receipt.UserMessage.MessageId); }); })); }
private static async Task <ReceivingProcessingMode> ExerciseScoringSystemAsync( UserMessage um, params ReceivingProcessingMode[] availablePModes) { var stub = new Mock <IConfig>(); stub.Setup(c => c.GetReceivingPModes()) .Returns(availablePModes); var sut = new DeterminePModesStep(stub.Object, createContext: () => null); var ctx = new MessagingContext(AS4Message.Create(um), MessagingContextMode.Receive); StepResult result = await sut.ExecuteAsync(ctx); string exception = result.MessagingContext?.Exception != null ? $"Exception: {result.MessagingContext.Exception.Message}" : null; string error = result.MessagingContext?.ErrorResult != null ? $"Error: {result.MessagingContext.ErrorResult.Description}" : null; Assert.True( result.MessagingContext?.ReceivingPMode != null, $"Step result's ReceivingPMode != null, {String.Join(", ", exception, error)}"); return(result.MessagingContext?.ReceivingPMode); }
public async Task Fails_To_Create_NonRepudiation_Unsigned_Receipt() { // Arrange var as4Message = AS4Message.Create(new UserMessage($"user-{Guid.NewGuid()}")); var fixture = new MessagingContext( as4Message, MessagingContextMode.Receive) { ReceivingPMode = new ReceivingProcessingMode { ReplyHandling = { ReceiptHandling = { UseNRRFormat = true }, ResponseSigning = { IsEnabled = false } } } }; var sut = new CreateAS4ReceiptStep(); // Act StepResult result = await sut.ExecuteAsync(fixture); // Assert Assert.False(result.Succeeded); Assert.NotNull(result.MessagingContext.ErrorResult); }
public async Task Fallback_To_Regular_Receipt_When_Referenced_UserMessage_Isnt_Signed() { // Arrange var as4Message = AS4Message.Create( new UserMessage($"user-{Guid.NewGuid()}")); var certRepo = new CertificateRepository(StubConfig.Default); as4Message.Encrypt( new KeyEncryptionConfiguration( certRepo.GetCertificate(X509FindType.FindBySubjectName, "AccessPointB")), DataEncryptionConfiguration.Default); var fixture = new MessagingContext(as4Message, MessagingContextMode.Receive) { ReceivingPMode = new ReceivingProcessingMode() }; // Act AS4Message result = await ExerciseCreateReceiptAsync(fixture); // Assert var receipt = Assert.IsType <Receipt>(result.FirstSignalMessage); Assert.Null(receipt.NonRepudiationInformation); Assert.NotNull(receipt.UserMessage); }
public Property Redeserialize_Result_In_Same_MessageUnits_Order( NonEmptyArray <MessageUnit> messageUnits) { // Arrange AS4Message start = AS4Message.Create(messageUnits.Get); string ToName(MessageUnit u) { return(u is SignalMessage ? "SignalMessage" : u is UserMessage ? "UserMessage" : "Unknown"); } IEnumerable <string> expected = messageUnits.Get.Select(ToName); // Act AS4Message end = AS4MessageUtils.SerializeDeserializeAsync(start) .GetAwaiter() .GetResult(); // Assert IEnumerable <string> actual = end.MessageUnits.Select(ToName); return(expected .SequenceEqual(actual) .Label($"{String.Join(", ", expected)} != {String.Join(", ", actual)}")); }
private static AS4Message CreateAS4Message(SendingProcessingMode sendPMode) { var sender = new Party("sender", new PartyId("senderId")); var receiver = new Party("rcv", new PartyId("receiverId")); return(AS4Message.Create(new UserMessage(Guid.NewGuid().ToString(), sender, receiver), sendPMode)); }
public void Then_Error_Detail_Is_Present_When_Defined() { // Arrange var error = new Error( $"error-{Guid.NewGuid()}", $"user-{Guid.NewGuid()}", ErrorLine.FromErrorResult(new ErrorResult("sample error", ErrorAlias.ConnectionFailure))); // Act XmlDocument doc = SerializeSoapMessage(AS4Message.Create(error)); // Assert XmlNode errorTag = doc.SelectEbmsNode( "/s12:Envelope/s12:Header/eb:Messaging/eb:SignalMessage/eb:Error"); const string expected = "<eb:Error " + "category=\"Communication\" " + "errorCode=\"EBMS:0005\" " + "severity=\"FAILURE\" " + "shortDescription=\"ConnectionFailure\" " + "xmlns:eb=\"http://docs.oasis-open.org/ebxml-msg/ebms/v3.0/ns/core/200704/\">" + "<eb:ErrorDetail>sample error</eb:ErrorDetail>" + "</eb:Error>"; Assert.Equal(expected, errorTag.OuterXml); }
public Property Then_Service_Has_Only_Type_When_Defined( Guid value, Maybe <Guid> type) { // Arrange var user = new UserMessage( $"user-{Guid.NewGuid()}", new AS4.Model.Core.CollaborationInfo( agreement: new AgreementReference("agreement"), service: new Service( value.ToString(), type.Select(t => t.ToString())), action: "action", conversationId: "conversation")); // Act XmlDocument doc = SerializeSoapMessage(AS4Message.Create(user)); // Assert XmlNode serviceNode = doc.UnsafeSelectEbmsNode( "/s12:Envelope/s12:Header/eb:Messaging/eb:UserMessage/eb:CollaborationInfo/eb:Service"); XmlAttribute serviceTypeAttr = serviceNode?.Attributes?["type"]; return((serviceNode?.FirstChild?.Value == value.ToString()) .Label("Equal value") .And(serviceTypeAttr == null && type == Maybe <Guid> .Nothing) .Label("No service type present") .Or(type.Select(t => t.ToString() == serviceTypeAttr?.Value).GetOrElse(false)) .Label("Equal service type")); }
public async Task Agent_Returns_Error_When_ReceivingPMode_Cannot_Be_Found() { OverrideTransformerReceivingPModeSetting( StaticReceiveSettings, pmodeId: "non-existing-pmode-id"); await TestStaticReceive( StaticReceiveSettings, async (url, _) => { AS4Message userMessage = AS4Message.Create(new UserMessage("user-" + Guid.NewGuid())); // Act HttpResponseMessage response = await StubSender.SendAS4Message(url, userMessage); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); AS4Message error = await response.DeserializeToAS4Message(); Assert.Collection( error.MessageUnits, m => { Assert.IsType <Error>(m); var e = (Error)m; Assert.Equal( ErrorAlias.ProcessingModeMismatch, e.ErrorLines.First().ShortDescription); }); }); }
public async Task ThenMultiHopSignalMessageIsToBeForwarded() { // Arrange SignalMessage signal = CreateMultihopSignalMessage( refToMessageId: "someusermessageid", pmodeId: "Forward_Push"); // Act await StubSender.SendAS4Message(_receiveAgentUrl, AS4Message.Create(signal)); // Assert InMessage inMessage = _databaseSpy.GetInMessageFor(m => m.EbmsMessageId == signal.MessageId); Assert.NotNull(inMessage); Assert.True(inMessage.Intermediary); Assert.Equal(Operation.ToBeForwarded, inMessage.Operation); Stream messageBody = await Registry.Instance .MessageBodyStore .LoadMessageBodyAsync(inMessage.MessageLocation); AS4Message savedMessage = await SerializerProvider.Default .Get(inMessage.ContentType) .DeserializeAsync(messageBody, inMessage.ContentType); Assert.NotNull(savedMessage.EnvelopeDocument.SelectSingleNode("//*[local-name()='RoutingInput']")); }
private DeliverMessageEnvelope CreateDeliverMessageEnvelope(AS4Message as4Message, bool includeAttachments) { UserMessage deliverMessage = CreateMinderDeliverMessage(as4Message); // The Minder Deliver Message should be an AS4-Message. AS4Message msg = AS4Message.Create(deliverMessage); if (includeAttachments) { msg.AddAttachments(as4Message.Attachments); } byte[] content = SerializeAS4Message(msg); return(new DeliverMessageEnvelope( message: new DeliverMessage { MessageInfo = new MessageInfo { MessageId = deliverMessage.MessageId, RefToMessageId = deliverMessage.RefToMessageId }, Payloads = msg.FirstUserMessage.PayloadInfo.Select(CreateDeliverPayload).ToArray() }, deliverMessage: content, contentType: msg.ContentType, attachments: as4Message.UserMessages.SelectMany(um => as4Message.Attachments.Where(a => a.MatchesAny(um.PayloadInfo))))); }
private static AS4Message CreateBundledMultipleUserMessagesWithRefTo() { var userMessage1 = new UserMessage( messageId: "user1-" + Guid.NewGuid(), collaboration: new CollaborationInfo( agreement: new AgreementReference( value: "http://agreements.europa.org/agreement", pmodeId: "pullreceive_bundled_pmode"), service: new Service( value: "bundling", type: "as4:net:pullreceive:bundling"), action: "as4:net:pullreceive:bundling", conversationId: "as4:net:pullreceive:conversation")); var userMessage2 = new UserMessage( messageId: "user2-" + Guid.NewGuid(), collaboration: new CollaborationInfo( agreement: new AgreementReference( value: "http://agreements.europa.org/agreement", pmodeId: "some-other-pmode-id"), service: new Service( value: "bundling", type: "as4:net:pullreceive:bundling"), action: "as4:net:pullreceive:bundling", conversationId: "as4:net:pullreceive:conversation")); var bundled = AS4Message.Create(userMessage1); bundled.AddMessageUnit(userMessage2); return(bundled); }
public async Task Updates_ToBeNotified_When_Specified_SendingPMode_And_Reference_InMessage() { // Arrange string ebmsMessageId = Guid.NewGuid().ToString(); GetDataStoreContext.InsertOutMessage(new OutMessage(ebmsMessageId)); AS4Message receivedAS4Message = AS4Message.Create(new Receipt($"receipt-{Guid.NewGuid()}", ebmsMessageId)); // Act await ExerciseUpdateReceivedMessage( receivedAS4Message, CreateNotifyAllSendingPMode(), receivePMode : null); // Assert GetDataStoreContext.AssertInMessageWithRefToMessageId( ebmsMessageId, m => { Assert.NotNull(m); Assert.Equal(Operation.ToBeNotified, m.Operation); }); GetDataStoreContext.AssertOutMessage( ebmsMessageId, m => { Assert.NotNull(m); Assert.Equal(OutStatus.Ack, m.Status.ToEnum <OutStatus>()); }); }
/// <summary> /// Execute the step for a given <paramref name="messagingContext" />. /// </summary> /// <param name="messagingContext">Message used during the step execution.</param> /// <returns></returns> public async Task <StepResult> ExecuteAsync(MessagingContext messagingContext) { var pullRequest = messagingContext?.AS4Message?.FirstSignalMessage as PullRequest; if (pullRequest == null) { throw new InvalidMessageException( "The received message is not a PullRequest message, " + "therefore no UserMessage can be selected to return to the sender"); } (bool hasMatch, OutMessage match) = RetrieveUserMessageForPullRequest(pullRequest); if (hasMatch) { // Retrieve the existing MessageBody and put that stream in the MessagingContext. // The HttpReceiver processor will make sure that it gets serialized to the http response stream. Stream messageBody = await match.RetrieveMessageBody(_messageBodyStore).ConfigureAwait(false); messagingContext.ModifyContext( new ReceivedMessage(messageBody, match.ContentType), MessagingContextMode.Send); messagingContext.SendingPMode = AS4XmlSerializer.FromString <SendingProcessingMode>(match.PMode); return(StepResult.Success(messagingContext)); } AS4Message pullRequestWarning = AS4Message.Create(Error.CreatePullRequestWarning(IdentifierFactory.Instance.Create())); messagingContext.ModifyContext(pullRequestWarning); return(StepResult.Success(messagingContext).AndStopExecution()); }
public async Task Doesnt_Update_OutMessage_If_No_MessageLocation_Can_Be_Found() { // Arrange string knownId = "known-id-" + Guid.NewGuid(); GetDataStoreContext.InsertOutMessage( new OutMessage(knownId) { MessageLocation = null }); var ctx = new MessagingContext( AS4Message.Create(new FilledUserMessage(knownId)), MessagingContextMode.Unknown) { SendingPMode = CreateNotifyAllSendingPMode() }; var sut = new UpdateReceivedAS4MessageBodyStep(StubConfig.Default, GetDataStoreContext, _messageBodyStore); // Act await sut.ExecuteAsync(ctx); // Assert GetDataStoreContext.AssertOutMessage(knownId, m => Assert.Null(m.MessageLocation)); }
public async Task OutMessageIsCreatedForToBeForwardedMessage() { // Arrange const string messageId = "message-id"; var as4Message = AS4Message.Create(CreateForwardPushUserMessage(messageId)); // Act InsertToBeForwardedInMessage( pmodeId: "Forward_Push", mep: MessageExchangePattern.Push, tobeForwarded: as4Message); // Assert: if an OutMessage is created with the correct status and operation. InMessage inMessage = await PollUntilPresent( () => _databaseSpy.GetInMessageFor( m => m.EbmsMessageId == messageId && m.Operation == Operation.Forwarded), TimeSpan.FromSeconds(15)); Assert.NotNull(AS4XmlSerializer.FromString <ReceivingProcessingMode>(inMessage.PMode)); OutMessage outMessage = await PollUntilPresent( () => _databaseSpy.GetOutMessageFor(m => m.EbmsMessageId == messageId), timeout : TimeSpan.FromSeconds(5)); Assert.True(outMessage.Intermediary); Assert.Equal(Operation.ToBeProcessed, outMessage.Operation); Assert.NotNull(AS4XmlSerializer.FromString <SendingProcessingMode>(outMessage.PMode)); }
public async Task Updates_Status_Nack_Related_UserMessage_OutMessage() { // Arrange string ebmsMessageId = "error-" + Guid.NewGuid(); GetDataStoreContext.InsertOutMessage(CreateOutMessage(ebmsMessageId)); var error = Error.FromErrorResult( $"error-{Guid.NewGuid()}", ebmsMessageId, new ErrorResult("Some Error", ErrorAlias.ConnectionFailure)); // Act await ExerciseUpdateReceivedMessage( AS4Message.Create(error), CreateNotifyAllSendingPMode(), receivePMode : null); // Assert GetDataStoreContext.AssertOutMessage( ebmsMessageId, m => { Assert.NotNull(m); Assert.Equal(OutStatus.Nack, m.Status.ToEnum <OutStatus>()); }); }
public async Task ThenExecuteStepUpdatesDuplicateReceiptMessage() { // Arrange SignalMessage signalMessage = new Receipt($"receipt-{Guid.NewGuid()}", "ref-to-message-id"); signalMessage.IsDuplicate = false; using (MessagingContext messagingContext = CreateReceivedMessagingContext(AS4Message.Create(signalMessage), null)) { // Act // Execute the step twice. StepResult stepResult = await Step.ExecuteAsync(messagingContext); Assert.False(stepResult.MessagingContext.AS4Message.FirstSignalMessage.IsDuplicate); } using (MessagingContext messagingContext = CreateReceivedMessagingContext(AS4Message.Create(signalMessage), null)) { StepResult stepResult = await Step.ExecuteAsync(messagingContext); // Assert Assert.True(stepResult.MessagingContext.AS4Message.FirstSignalMessage.IsDuplicate); } }
public async Task ThenReceivedMultihopUserMessageIsSetAsIntermediaryAndForwarded() { // Arrange var userMessage = new UserMessage( "test-" + Guid.NewGuid(), new CollaborationInfo( agreement: new AgreementReference( value: "http://agreements.europa.org/agreement", pmodeId: "Forward_Push_Multihop"), service: new Service( value: "Forward_Push_Multihop_Service", type: "eu:europa:services"), action: "Forward_Push_Multihop_Action", conversationId: "eu:europe:conversation")); var multihopPMode = new SendingProcessingMode { MessagePackaging = { IsMultiHop = true } }; AS4Message multihopMessage = AS4Message.Create(userMessage, multihopPMode); // Act HttpResponseMessage response = await StubSender.SendAS4Message(_receiveAgentUrl, multihopMessage); // Assert Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); InMessage inUserMessage = _databaseSpy.GetInMessageFor(m => m.EbmsMessageId == userMessage.MessageId); Assert.NotNull(inUserMessage); Assert.True(inUserMessage.Intermediary); Assert.Equal(Operation.ToBeForwarded, inUserMessage.Operation); }
public async Task Fails_To_Store_SignalMessage_When_ReplyPattern_Response_For_Pulled_UserMessage() { // Arrange string userMessageId = $"user-{Guid.NewGuid()}"; GetDataStoreContext.InsertInMessage( new InMessage(userMessageId) { MEP = MessageExchangePattern.Pull }); var receipt = new Receipt($"receipt-{Guid.NewGuid()}", userMessageId); var context = new MessagingContext( AS4Message.Create(receipt), MessagingContextMode.Receive) { SendingPMode = new SendingProcessingMode { Id = "shortcut-send-pmode-retrieval" }, ReceivingPMode = new ReceivingProcessingMode { ReplyHandling = { ReplyPattern = ReplyPattern.Response } } }; // Act / Assert await Assert.ThrowsAsync <InvalidOperationException>( () => ExerciseStoreSignalMessageAsync(context)); }
public Property Then_MessageUnits_Are_Serialized_In_Correct_Order( NonEmptyArray <MessageUnit> messageUnits) { // Arrange var as4 = AS4Message.Create(messageUnits.Get); // Act XmlDocument doc = SerializeSoapMessage(as4); //Assert IEnumerable <string> actual = doc.SelectEbmsNode("/s12:Envelope/s12:Header/eb:Messaging") .ChildNodes .Cast <XmlNode>() .Select(n => n.LocalName); IEnumerable <string> expected = messageUnits.Get.Select( u => u is AS4.Model.Core.SignalMessage ? "SignalMessage" : u is UserMessage ? "UserMessage" : "Unknown"); return(expected .SequenceEqual(actual) .Label($"{String.Join(", ", expected)} != {String.Join(", ", actual)}")); }
public async Task Takes_Sending_PMode_Into_Account_When_Verifies_Non_Multihop_Signal() { // Arrange var as4Msg = AS4Message.Create(new Receipt($"receipt-{Guid.NewGuid()}", $"reftoid-{Guid.NewGuid()}")); as4Msg.AddMessageUnit(new UserMessage(messageId: $"user-{Guid.NewGuid()}")); var ctx = new MessagingContext(as4Msg, MessagingContextMode.Receive) { ReceivingPMode = new ReceivingProcessingMode { Security = { SigningVerification = { Signature = Limit.Required } } }, SendingPMode = new SendingProcessingMode { Security = { SigningVerification = { Signature = Limit.Ignored } } } }; // Act StepResult result = await ExerciseVerify(ctx); // Assert Assert.True(result.CanProceed); }
public async Task ThenAgreementRefIsNotEnoughAsync(string name, string type) { // Arrange var agreementRef = new AS4.Model.PMode.AgreementReference { Value = name, Type = type, PModeId = "pmode-id" }; ArrangePModeThenAgreementRefIsNotEnough(agreementRef); var userMessage = new UserMessage( Guid.NewGuid().ToString(), new AS4.Model.Core.CollaborationInfo( agreement: new AgreementReference(name, type, "pmode-id"), service: new Service("service"), action: "action", conversationId: "1")); var messagingContext = new MessagingContext(AS4Message.Create(userMessage), MessagingContextMode.Receive); // Act StepResult result = await _step.ExecuteAsync(messagingContext); // Assert Assert.False(result.Succeeded); ErrorResult errorResult = result.MessagingContext.ErrorResult; Assert.Equal(ErrorCode.Ebms0010, errorResult.Code); }
private static MessagingContext AS4UserMessageWithAttachment() { var as4Message = AS4Message.Create(new FilledUserMessage()); as4Message.AddAttachment(new FilledAttachment()); return(new MessagingContext(as4Message, MessagingContextMode.Unknown)); }