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 ThenUpdateReceiptWithReceived_IfNRReceiptHasValidHashes() { // Arrange string ebmsMessageId = Guid.NewGuid().ToString(); // Act TestReceiveNRReceiptWith(ebmsMessageId, hash => hash); // Assert InMessage receipt = await PollUntilPresent( () => _databaseSpy.GetInMessageFor(m => m.EbmsRefToMessageId == ebmsMessageId), timeout : TimeSpan.FromSeconds(5)); Assert.Equal(InStatus.Received, receipt.Status.ToEnum <InStatus>()); }
public async Task Agent_Processes_Signed_Encrypted_UserMessage_With_Static_ReceivingPMode() { await TestStaticReceive( StaticReceiveSettings, async (url, msh) => { // Arrange string ebmsMessageId = $"user-{Guid.NewGuid()}"; AS4Message m = SignedEncryptedAS4UserMessage(msh, ebmsMessageId); // Act HttpResponseMessage response = await StubSender.SendAS4Message(url, m); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); var spy = new DatabaseSpy(msh.GetConfiguration()); InMessage actual = await PollUntilPresent( () => spy.GetInMessageFor(im => im.EbmsMessageId == ebmsMessageId), timeout: TimeSpan.FromSeconds(15)); Assert.Equal(Operation.ToBeDelivered, actual.Operation); Assert.Equal(InStatus.Received, actual.Status.ToEnum <InStatus>()); Assert.Equal(DefaultPModeId, actual.PModeId); }); }
public async Task InMessage_Is_Set_To_Notified_When_Retry_Happen_Within_Allowed_MaxRetry( HttpStatusCode secondAttemptStatusCode, Operation expected) { await TestComponentWithSettings( "inmessage_notify_reliability_settings.xml", async (settings, as4Msh) => { // Arrange const string url = "http://localhost:7071/business/inmessage/"; string ebmsMessageId = $"receipt-{Guid.NewGuid()}"; var store = new AS4MessageBodyFileStore(); var im = new InMessage(ebmsMessageId) { EbmsMessageType = MessageType.Receipt, ContentType = Constants.ContentTypes.Soap, MessageLocation = store.SaveAS4Message( as4Msh.GetConfiguration().InMessageStoreLocation, AS4Message.Create( new Receipt( ebmsMessageId, $"reftoid-{Guid.NewGuid()}"))) }; SendingProcessingMode pmode = NotifySendingPMode(url); Entities.RetryReliability CreateRetry(long id) => Entities.RetryReliability.CreateForInMessage( refToInMessageId: id, maxRetryCount: pmode.ReceiptHandling.Reliability.RetryCount, retryInterval: pmode.ReceiptHandling.Reliability.RetryInterval.AsTimeSpan(), type: RetryType.Notification); // Act InsertMessageEntityWithRetry(im, as4Msh.GetConfiguration(), pmode, CreateRetry); // Assert SimulateNotifyFailureOnFirstAttempt(url, secondAttemptStatusCode); var spy = new DatabaseSpy(as4Msh.GetConfiguration()); InMessage notified = await PollUntilPresent( () => spy.GetInMessageFor( m => m.Operation == expected), timeout: TimeSpan.FromSeconds(10)); Assert.Equal(ebmsMessageId, notified.EbmsMessageId); Entities.RetryReliability referenced = await PollUntilPresent( () => spy.GetRetryReliabilityFor(r => r.RefToInMessageId == notified.Id), timeout: TimeSpan.FromSeconds(5)); Assert.Equal(RetryStatus.Completed, referenced.Status); }); }
public async Task Message_Is_Set_To_Delivered_After_Its_Being_Retried() { // Arrang AS4Message as4Message = CreateAS4Message(); // Act await TestDeliverRetryByBlockingDeliveryLocationFor(as4Message, TimeSpan.FromSeconds(1)); // Assert InMessage actual = await PollUntilPresent( () => _databaseSpy.GetInMessageFor(m => m.Operation == Operation.Delivered), timeout : TimeSpan.FromSeconds(10)); // Assert Assert.Equal(InStatus.Delivered, actual.Status.ToEnum <InStatus>()); Assert.Equal(Operation.Delivered, actual.Operation); RetryReliability rr = _databaseSpy.GetRetryReliabilityFor(r => r.RefToInMessageId == actual.Id); Assert.True(0 < rr.CurrentRetryCount, "0 < actualMessage.CurrentRetryCount"); Assert.Equal(RetryStatus.Completed, rr.Status); }
private async Task <HttpResponseMessage> PiggyBacked_PullRequest_With_Bundled_Signal( Func <string, SignalMessage> createSignal, OutStatus expStatus) { // Arrange OverridePullAuthorizationMap( @".\config\componenttest-settings\security\pull_authorizationmap_allowed_facts.xml"); string userMessageId = $"user-{Guid.NewGuid()}"; StoreToBeAckOutMessage(userMessageId, CreateSendingPMode()); AS4Message pullRequest = CreateAllowedPullRequest(); SignalMessage extraSignalMessage = createSignal(userMessageId); pullRequest.AddMessageUnit(extraSignalMessage); AS4Message signedBundled = SignAS4MessageWithPullRequestCert(pullRequest); // Act HttpResponseMessage response = await StubSender.SendAS4Message(PullSendUrl, signedBundled); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); OutMessage storedUserMesage = _databaseSpy.GetOutMessageFor(m => m.EbmsMessageId == userMessageId); Assert.Equal(expStatus, storedUserMesage.Status.ToEnum <OutStatus>()); InMessage storedSignalMessage = _databaseSpy.GetInMessageFor(m => m.EbmsMessageId == extraSignalMessage.MessageId); Assert.Equal(InStatus.Received, storedSignalMessage.Status.ToEnum <InStatus>()); return(response); }
public async Task PiggyBack_Receipt_On_Next_PullRequest_Result_In_Acked_UserMessage() { // Arrange OverrideServiceSettings("piggyback_service_settings.xml"); _windowsService.EnsureServiceIsStarted(); // Act await SubmitMessageToSubmitAgent(pullsendagent_piggyback); // Assert var spy = new DatabaseSpy(_consoleHost.GetConfiguration()); InMessage receipt = await PollUntilPresent( () => spy.GetInMessageFor( m => m.EbmsMessageType == MessageType.Receipt), timeout : TimeSpan.FromSeconds(30)); await PollUntilPresent( () => spy.GetOutMessageFor( m => m.EbmsMessageType == MessageType.UserMessage && m.EbmsMessageId == receipt.EbmsRefToMessageId && m.Status.ToEnum(OutStatus.NotApplicable) == OutStatus.Ack), timeout : TimeSpan.FromSeconds(10)); }
public async Task ThenAgentReturnsError_IfReceivingPModeIsNotValid() { const string messageId = "some-message-id"; // Arrange var message = AS4Message.Create( new UserMessage( messageId: messageId, collaboration: new CollaborationInfo( agreement: new AgreementReference("http://agreements.europa.org/agreement"), service: new Model.Core.Service( value: "Invalid_PMode_Test_Service", type: "eu:europa:services"), action: "Invalid_PMode_Test_Action", conversationId: CollaborationInfo.DefaultConversationId), sender: new Model.Core.Party("Sender", new PartyId("org:eu:europa:as4:example:accesspoint:A")), receiver: new Model.Core.Party("Receiver", new PartyId("org:eu:europa:as4:example:accesspoint:B")), partInfos: new Model.Core.PartInfo[0], messageProperties: new Model.Core.MessageProperty[0])); // Act HttpResponseMessage response = await StubSender.SendAS4Message(_receiveAgentUrl, message); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); AS4Message result = await SerializerProvider.Default .Get(Constants.ContentTypes.Soap) .DeserializeAsync(await response.Content.ReadAsStreamAsync(), Constants.ContentTypes.Soap); var errorMsg = result.FirstSignalMessage as Error; Assert.NotNull(errorMsg); Assert.Collection( errorMsg.ErrorLines, e => Assert.Equal(ErrorCode.Ebms0010, e.ErrorCode)); InMessage inMessageRecord = _databaseSpy.GetInMessageFor(m => m.EbmsMessageId == messageId); Assert.Equal(InStatus.Received, inMessageRecord.Status.ToEnum <InStatus>()); }