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
57 lines
1.8 KiB
C#
57 lines
1.8 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using Centron.Common.TextCoding;
|
|
using Centron.Tests.EndToEnd.Infrastructure;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Centron.Tests.EndToEnd.Tests.CryptoControls;
|
|
|
|
public class CryptoControlTests : CentronTest
|
|
{
|
|
public CryptoControlTests(ITestOutputHelper testOutputHelper)
|
|
: base(testOutputHelper)
|
|
{
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(0, "Irgendein Text den ich verschlüsseln will, zB ein Connection-String!")]
|
|
[InlineData(1, "")]
|
|
[InlineData(2, " ")]
|
|
[InlineData(3, "\t")]
|
|
[InlineData(4, "\r\n")]
|
|
[InlineData(5, null)]
|
|
[InlineData(6, "245050016053193207141108203017074108161195181234")]
|
|
public void Encrypt_Decrypt_Text(int counter, string input)
|
|
{
|
|
var encryptedText = CryptoControl.EncryptToString(input);
|
|
this.Verifier.Verify($"EncryptedText_{counter}", encryptedText);
|
|
|
|
var decryptedText = CryptoControl.DecryptString(encryptedText);
|
|
var expectedText = input is null
|
|
? "" // The Encrypt-Decrypt-Dance will return "" for NULL input instead
|
|
: input;
|
|
Assert.Equal(expectedText, decryptedText);
|
|
}
|
|
|
|
[Fact]
|
|
public void Decrypt_Text_InvalidDataReturnsEmptyString()
|
|
{
|
|
var ex = Assert.Throws<FormatException>(() => CryptoControl.DecryptString("Haha"));
|
|
Assert.Equal("The input string 'Hah' was not in a correct format.", ex.Message);
|
|
}
|
|
|
|
[Fact]
|
|
public void Multi_Threading_Test()
|
|
{
|
|
Parallel.For(0, 10000, i =>
|
|
{
|
|
var input = "Hallo";
|
|
|
|
var encrypted = CryptoControl.EncryptToString(input);
|
|
var decrypted = CryptoControl.DecryptString(encrypted);
|
|
|
|
Assert.Equal(input, decrypted);
|
|
});
|
|
}
|
|
} |