QuellCode/CentronERP war nur als Gitlink (Submodul-Referenz auf 79c1142) getrackt, ohne .gitmodules und ohne erreichbares Remote. Der Untersuchungsgegenstand der Versuchsreihe war damit nicht reproduzierbar gesichert: Ein Klon haette ein leeres Verzeichnis erhalten, und die Belege der 3.287 Anforderungen waeren nicht ueberpruefbar gewesen. Umstellung: - Historie nach c:\DEV\CentronERP_git_snapshot_79c1142 ausgelagert (vollstaendig lesbar, enthaelt 79c1142 und Vorgaenger 89ccfd6) - Gitlink aus dem Index entfernt - Dateiinhalt aufgenommen: 24.557 Dateien, rund 333 MB Die verschachtelte .gitignore der Codebasis gilt weiter, Build-Artefakte bleiben ausgeschlossen. Details in Versuche/Versuch_01/_Codebasis-Nachweis.md
83 lines
2.9 KiB
C#
83 lines
2.9 KiB
C#
using System.Text;
|
|
using Centron.Common.TextCoding;
|
|
using Centron.Tests.EndToEnd.Infrastructure;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Centron.Tests.EndToEnd.Tests.CryptoLogics
|
|
{
|
|
public class CryptoLogicTests : CentronTest
|
|
{
|
|
public CryptoLogicTests(ITestOutputHelper testOutputHelper)
|
|
: base(testOutputHelper)
|
|
{
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null)]
|
|
[InlineData("MySuperSecretPassword")]
|
|
public void Encrypt_Decrypt_Text(string secret)
|
|
{
|
|
var inputText = "Irgendein Text den ich verschlüsseln will, zB ein Connection-String!";
|
|
|
|
var encryptedText = new AESCryptoLogic().EncryptText(inputText, secret);
|
|
this.Verifier.Verify($"EncryptedText_{secret}", encryptedText);
|
|
|
|
var decryptedText = new AESCryptoLogic().DecryptText(encryptedText, secret);
|
|
Assert.Equal(inputText, decryptedText);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null)]
|
|
[InlineData("")]
|
|
[InlineData(" ")]
|
|
[InlineData("\t")]
|
|
[InlineData("\r\n")]
|
|
public void Encrypt_Decrypt_Text_Null(string text)
|
|
{
|
|
var encryptedText = new AESCryptoLogic().EncryptText(text);
|
|
Assert.Equal(string.Empty, encryptedText);
|
|
|
|
var decryptedText = new AESCryptoLogic().DecryptText(text);
|
|
Assert.Equal(string.Empty, decryptedText);
|
|
}
|
|
|
|
[Fact]
|
|
public void Decrypt_Text_InvalidDataReturnsEmptyString()
|
|
{
|
|
var decryptedText = new AESCryptoLogic().DecryptText("Haha");
|
|
Assert.Equal(string.Empty, decryptedText);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(null)]
|
|
[InlineData("MySuperSecretPassword")]
|
|
public void Encrypt_Decrypt_ByteArray(string secret)
|
|
{
|
|
var inputByteArray = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
|
|
|
|
var encryptedByteArray = new AESCryptoLogic().EncryptByteArray(inputByteArray, secret);
|
|
this.Verifier.Verify($"EncryptedByteArray_{secret}", encryptedByteArray);
|
|
|
|
var decryptedByteArray = new AESCryptoLogic().DecryptByteArray(encryptedByteArray, secret);
|
|
Assert.Equal(inputByteArray, decryptedByteArray);
|
|
}
|
|
|
|
[Fact]
|
|
public void Encrypt_Decrypt_ByteArray_Null()
|
|
{
|
|
var encryptedByteArray = new AESCryptoLogic().EncryptByteArray(null);
|
|
Assert.Null(encryptedByteArray);
|
|
|
|
var decryptedByteArray = new AESCryptoLogic().DecryptByteArray(null);
|
|
Assert.Null(decryptedByteArray);
|
|
}
|
|
|
|
[Fact]
|
|
public void Decrypt_ByteArray_InvalidDataReturnsNull()
|
|
{
|
|
var decryptedByteArray = new AESCryptoLogic().DecryptByteArray(new byte[] {1, 2, 3});
|
|
Assert.Null(decryptedByteArray);
|
|
}
|
|
}
|
|
} |