-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5d0f0c6
commit e085e7f
Showing
17 changed files
with
704 additions
and
721 deletions.
There are no files selected for viewing
487 changes: 243 additions & 244 deletions
487
Crypto_Shredding/.NET/src/CryptoShredding.IntegrationTests/EventStoreTests/GetEventsTests.cs
Large diffs are not rendered by default.
Oops, something went wrong.
41 changes: 20 additions & 21 deletions
41
Crypto_Shredding/.NET/src/CryptoShredding.IntegrationTests/TestSupport/Given_When_Then.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 |
---|---|---|
@@ -1,33 +1,32 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace CryptoShredding.IntegrationTests.TestSupport | ||
namespace CryptoShredding.IntegrationTests.TestSupport; | ||
|
||
public abstract class Given_WhenAsync_Then_Test | ||
: IDisposable | ||
{ | ||
public abstract class Given_WhenAsync_Then_Test | ||
: IDisposable | ||
protected Given_WhenAsync_Then_Test() | ||
{ | ||
protected Given_WhenAsync_Then_Test() | ||
{ | ||
Task.Run((Func<Task>) (async () => await this.SetupAsync())).Wait(); | ||
} | ||
Task.Run((Func<Task>) (async () => await this.SetupAsync())).Wait(); | ||
} | ||
|
||
private async Task SetupAsync() | ||
{ | ||
await Given(); | ||
await When(); | ||
} | ||
private async Task SetupAsync() | ||
{ | ||
await Given(); | ||
await When(); | ||
} | ||
|
||
protected abstract Task Given(); | ||
protected abstract Task Given(); | ||
|
||
protected abstract Task When(); | ||
protected abstract Task When(); | ||
|
||
public void Dispose() | ||
{ | ||
Cleanup(); | ||
} | ||
public void Dispose() | ||
{ | ||
Cleanup(); | ||
} | ||
|
||
protected virtual void Cleanup() | ||
{ | ||
} | ||
protected virtual void Cleanup() | ||
{ | ||
} | ||
} |
13 changes: 6 additions & 7 deletions
13
Crypto_Shredding/.NET/src/CryptoShredding/Attributes/DataSubjectIdAttribute.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 |
---|---|---|
@@ -1,12 +1,11 @@ | ||
using System; | ||
|
||
namespace CryptoShredding.Attributes | ||
{ | ||
/** | ||
namespace CryptoShredding.Attributes; | ||
|
||
/** | ||
* Specifies the PII owner (e.g: the person Id) | ||
*/ | ||
public class DataSubjectIdAttribute | ||
: Attribute | ||
{ | ||
} | ||
public class DataSubjectIdAttribute | ||
: Attribute | ||
{ | ||
} |
13 changes: 6 additions & 7 deletions
13
Crypto_Shredding/.NET/src/CryptoShredding/Attributes/PersonalDataAttribute.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 |
---|---|---|
@@ -1,12 +1,11 @@ | ||
using System; | ||
|
||
namespace CryptoShredding.Attributes | ||
{ | ||
/** | ||
namespace CryptoShredding.Attributes; | ||
|
||
/** | ||
* Specifies the property that holds PII | ||
*/ | ||
public class PersonalDataAttribute | ||
: Attribute | ||
{ | ||
} | ||
public class PersonalDataAttribute | ||
: Attribute | ||
{ | ||
} |
7 changes: 3 additions & 4 deletions
7
Crypto_Shredding/.NET/src/CryptoShredding/Contracts/IEvent.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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
namespace CryptoShredding.Contracts | ||
namespace CryptoShredding.Contracts; | ||
|
||
public interface IEvent | ||
{ | ||
public interface IEvent | ||
{ | ||
} | ||
} |
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
57 changes: 28 additions & 29 deletions
57
Crypto_Shredding/.NET/src/CryptoShredding/Repository/CryptoRepository.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 |
---|---|---|
@@ -1,44 +1,43 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace CryptoShredding.Repository | ||
namespace CryptoShredding.Repository; | ||
|
||
public class CryptoRepository | ||
{ | ||
public class CryptoRepository | ||
private readonly IDictionary<string, EncryptionKey> _cryptoStore; | ||
|
||
public CryptoRepository() | ||
{ | ||
private readonly IDictionary<string, EncryptionKey> _cryptoStore; | ||
_cryptoStore = new Dictionary<string, EncryptionKey>(); | ||
} | ||
|
||
public CryptoRepository() | ||
public EncryptionKey GetExistingOrNew(string id, Func<EncryptionKey> keyGenerator) | ||
{ | ||
var isExisting = _cryptoStore.TryGetValue(id, out var keyStored); | ||
if (isExisting) | ||
{ | ||
_cryptoStore = new Dictionary<string, EncryptionKey>(); | ||
return keyStored; | ||
} | ||
|
||
public EncryptionKey GetExistingOrNew(string id, Func<EncryptionKey> keyGenerator) | ||
{ | ||
var isExisting = _cryptoStore.TryGetValue(id, out var keyStored); | ||
if (isExisting) | ||
{ | ||
return keyStored; | ||
} | ||
|
||
var newEncryptionKey = keyGenerator.Invoke(); | ||
_cryptoStore.Add(id, newEncryptionKey); | ||
return newEncryptionKey; | ||
} | ||
var newEncryptionKey = keyGenerator.Invoke(); | ||
_cryptoStore.Add(id, newEncryptionKey); | ||
return newEncryptionKey; | ||
} | ||
|
||
public EncryptionKey GetExistingOrDefault(string id) | ||
public EncryptionKey GetExistingOrDefault(string id) | ||
{ | ||
var isExisting = _cryptoStore.TryGetValue(id, out var keyStored); | ||
if (isExisting) | ||
{ | ||
var isExisting = _cryptoStore.TryGetValue(id, out var keyStored); | ||
if (isExisting) | ||
{ | ||
return keyStored; | ||
} | ||
|
||
return default; | ||
return keyStored; | ||
} | ||
|
||
public void DeleteEncryptionKey(string id) | ||
{ | ||
_cryptoStore.Remove(id); | ||
} | ||
return default; | ||
} | ||
|
||
public void DeleteEncryptionKey(string id) | ||
{ | ||
_cryptoStore.Remove(id); | ||
} | ||
} |
23 changes: 11 additions & 12 deletions
23
Crypto_Shredding/.NET/src/CryptoShredding/Repository/EncryptionKey.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 |
---|---|---|
@@ -1,16 +1,15 @@ | ||
namespace CryptoShredding.Repository | ||
namespace CryptoShredding.Repository; | ||
|
||
public class EncryptionKey | ||
{ | ||
public class EncryptionKey | ||
{ | ||
public byte[] Key { get; } | ||
public byte[] Nonce { get; } | ||
public byte[] Key { get; } | ||
public byte[] Nonce { get; } | ||
|
||
public EncryptionKey( | ||
byte[] key, | ||
byte[] nonce) | ||
{ | ||
Key = key; | ||
Nonce = nonce; | ||
} | ||
public EncryptionKey( | ||
byte[] key, | ||
byte[] nonce) | ||
{ | ||
Key = key; | ||
Nonce = nonce; | ||
} | ||
} |
Oops, something went wrong.