void Invoke(IncomingContext context, bool shouldAbort = false)
 {
     behavior.Invoke(context, () =>
     {
         if (shouldAbort)
         {
             Assert.Fail("Pipeline should be aborted");
         }
     });
 }
Ejemplo n.º 2
0
        public object MutateIncoming(object message, IncomingContext incomingContext)
        {
            this.incomingContext = incomingContext;

            ForEachMember(
                message,
                DecryptMember,
                IsEncryptedMember
                );

            return message;
        }
        public void Should_shortcut_the_pipeline_if_existing_message_is_found()
        {
            var incomingTransportMessage = new TransportMessage();

            fakeOutbox.ExistingMessage = new OutboxMessage(incomingTransportMessage.Id);

            var context = new IncomingContext(null, incomingTransportMessage);

            Invoke(context);

            Assert.Null(fakeOutbox.StoredMessage);
        }
        public string Decrypt(EncryptedValue encryptedValue, IncomingContext incomingContext)
        {
            string keyIdentifier;

            if (TryGetKeyIdentifierHeader(out keyIdentifier, incomingContext))
            {
                return DecryptUsingKeyIdentifier(encryptedValue, keyIdentifier);
            }
            else
            {
                Log.WarnFormat("Encrypted message has no '" + Headers.RijndaelKeyIdentifier + "' header. Possibility of data corruption. Please upgrade endpoints that send message with encrypted properties.");
                return DecryptUsingAllKeys(encryptedValue);
            }
        }
        public void Should_not_dispatch_the_message_if_handle_current_message_later_was_called()
        {
            var incomingTransportMessage = new TransportMessage();


            var context = new IncomingContext(null, incomingTransportMessage)
            {
                handleCurrentMessageLaterWasCalled = true
            };

            Invoke(context);

            Assert.False(fakeOutbox.WasDispatched);
        }
        public void Should_not_store_the_message_if_handle_current_message_later_was_called()
        {
            var incomingTransportMessage = new TransportMessage();

            var context = new IncomingContext(null, incomingTransportMessage)
            {
                handleCurrentMessageLaterWasCalled = true
            };

            context.Set(new OutboxMessage("SomeId"));

            Invoke(context);

            Assert.Null(fakeOutbox.StoredMessage);
        }
 protected virtual bool TryGetKeyIdentifierHeader(out string keyIdentifier, IncomingContext incomingContext)
 {
     var headers = incomingContext.IncomingLogicalMessage.Headers;
     return headers.TryGetValue(Headers.RijndaelKeyIdentifier, out keyIdentifier);
 }
 protected override bool TryGetKeyIdentifierHeader(out string keyIdentifier, IncomingContext incomingContext)
 {
     keyIdentifier = IncomingKeyIdentifier;
     return IncomingKeyIdentifier != null;
 }