-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RabbitService Comcrypt and Decomcrypt refactoring.
- Loading branch information
1 parent
d7c9790
commit 96ae993
Showing
6 changed files
with
111 additions
and
57 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using HouseofCat.Compression; | ||
using HouseofCat.Encryption; | ||
using HouseofCat.Hashing; | ||
using HouseofCat.RabbitMQ; | ||
using HouseofCat.RabbitMQ.Services; | ||
using HouseofCat.Serialization; | ||
using System.Text; | ||
|
||
namespace RabbitMQ; | ||
|
||
public class RabbitServiceTests | ||
{ | ||
private readonly IRabbitService _rabbitService; | ||
|
||
public RabbitServiceTests() | ||
{ | ||
var options = new RabbitOptions(); | ||
var hashingProvider = new ArgonHashingProvider(); | ||
|
||
var hashKey = hashingProvider.GetHashKey("Sega", "Nintendo", 32); | ||
|
||
_rabbitService = new RabbitService( | ||
options, | ||
new JsonProvider(), | ||
new AesGcmEncryptionProvider(hashKey), | ||
new GzipProvider()); | ||
} | ||
|
||
[Fact] | ||
public async Task ComcryptTestAsync() | ||
{ | ||
var message = new Message("", "TestQueue", Encoding.UTF8.GetBytes("Hello World")); | ||
|
||
await _rabbitService.ComcryptAsync(message); | ||
|
||
Assert.True(message.Metadata.Encrypted()); | ||
Assert.True(message.Metadata.Compressed()); | ||
} | ||
|
||
[Fact] | ||
public async Task ComcryptDecomcryptTestAsync() | ||
{ | ||
var messageAsString = "Hello World"; | ||
var message = new Message("", "TestQueue", Encoding.UTF8.GetBytes(messageAsString)); | ||
|
||
await _rabbitService.ComcryptAsync(message); | ||
|
||
Assert.True(message.Metadata.Encrypted()); | ||
Assert.True(message.Metadata.Compressed()); | ||
|
||
await _rabbitService.DecomcryptAsync(message); | ||
|
||
Assert.False(message.Metadata.Encrypted()); | ||
Assert.False(message.Metadata.Compressed()); | ||
|
||
var bodyAsString = Encoding.UTF8.GetString(message.Body.Span); | ||
|
||
Assert.Equal(messageAsString, bodyAsString); | ||
} | ||
} |
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