-
-
Notifications
You must be signed in to change notification settings - Fork 363
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix encryption + 2nd level retries bug
- Loading branch information
1 parent
5dad08e
commit af552a8
Showing
4 changed files
with
65 additions
and
8 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
Rebus.Tests/Bugs/VerifySecondLevelRetriesAndEncryptionAreCool.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
using Rebus.Activation; | ||
using Rebus.Config; | ||
using Rebus.Encryption; | ||
using Rebus.Retry.Simple; | ||
using Rebus.Tests.Contracts; | ||
using Rebus.Tests.Contracts.Extensions; | ||
using Rebus.Transport.InMem; | ||
// ReSharper disable AccessToDisposedClosure | ||
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously | ||
|
||
namespace Rebus.Tests.Bugs; | ||
|
||
[TestFixture] | ||
[Description("Exposed a bug that was caused by not removing the encryption headers from the transport message after descryption. This caused decryption to happen twice, but on un-encrypted contents the 2nd time around")] | ||
public class VerifySecondLevelRetriesAndEncryptionAreCool : FixtureBase | ||
{ | ||
static readonly string SecretKey = FixedRijndaelEncryptionKeyProvider.GenerateNewKey(); | ||
|
||
[Test] | ||
public async Task ItWorks() | ||
{ | ||
using var activator = new BuiltinHandlerActivator(); | ||
using var gotTheFailedMessage = new ManualResetEvent(initialState: false); | ||
|
||
activator.Handle<string>(async _ => throw new IndexOutOfRangeException("it's out of range buddy")); | ||
|
||
activator.Handle<IFailed<string>>(async failed => | ||
{ | ||
gotTheFailedMessage.Set(); | ||
}); | ||
|
||
var bus = Configure.With(activator) | ||
.Transport(t => t.UseInMemoryTransport(new(), "whatever")) | ||
.Options(o => | ||
{ | ||
o.RetryStrategy(secondLevelRetriesEnabled: true); | ||
o.EnableEncryption(SecretKey); | ||
}) | ||
.Start(); | ||
|
||
await bus.SendLocal("HEJ"); | ||
|
||
gotTheFailedMessage.WaitOrDie(TimeSpan.FromSeconds(3)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters