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
97 lines
2.6 KiB
C#
97 lines
2.6 KiB
C#
using System.Linq.Expressions;
|
|
using Centron.Host.Messages;
|
|
using Centron.Host.RestRequests;
|
|
using Centron.Interfaces.Administration.Connections;
|
|
using CentronSoftware.Centron.WebServices.Connections;
|
|
|
|
namespace Centron.Tests.Integration;
|
|
|
|
public class IntegrationTestHelper
|
|
{
|
|
private static string? LoginToken { get; set; }
|
|
|
|
private static readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1);
|
|
|
|
public static async Task<string> Login(CentronWebService connection, string? username = null, string? password = null, string? device = null)
|
|
{
|
|
await _semaphore.WaitAsync();
|
|
if (LoginToken != null)
|
|
{
|
|
_semaphore.Release();
|
|
return LoginToken;
|
|
}
|
|
|
|
var request = GetRequest(new LoginRequest
|
|
{
|
|
Username = username ?? "admin",
|
|
Password = password ?? "1",
|
|
Application = "{7880B678-989E-4405-B570-F7FC34D25367}",
|
|
Device = device ?? "test",
|
|
AppVersion = "1.0.2502",
|
|
LoginKind = WebLoginType.User,
|
|
});
|
|
|
|
Expression<Func<ICentronRestService, Response<string>>> execute= f => f.Login(request);
|
|
|
|
try
|
|
{
|
|
var response = await connection.CallAsync(execute);
|
|
var result = response.Result.FirstOrDefault();
|
|
Assert.NotNull(result);
|
|
Assert.NotEmpty(result);
|
|
LoginToken = result;
|
|
return result;
|
|
}
|
|
finally
|
|
{
|
|
_semaphore.Release();
|
|
}
|
|
}
|
|
|
|
public static async Task Logout(CentronWebService connection)
|
|
{
|
|
await _semaphore.WaitAsync();
|
|
if (LoginToken == null)
|
|
{
|
|
_semaphore.Release();
|
|
return;
|
|
}
|
|
|
|
var request = GetRequest(LoginToken!);
|
|
Expression<Func<ICentronRestService, Response>> execute = f => f.Logout(request);
|
|
|
|
try
|
|
{
|
|
var response = await connection.CallAsync(execute);
|
|
Assert.Equal(StatusCode.Success, response.Status);
|
|
LoginToken = null;
|
|
}
|
|
finally
|
|
{
|
|
_semaphore.Release();
|
|
}
|
|
}
|
|
|
|
public static Request GetRequest(string ticket = "")
|
|
{
|
|
return new Request
|
|
{
|
|
Ticket = ticket
|
|
};
|
|
}
|
|
|
|
public static Request<T> GetRequest<T>(T data, string ticket = "")
|
|
{
|
|
return new Request<T>
|
|
{
|
|
Data = data,
|
|
Ticket = ticket,
|
|
};
|
|
}
|
|
|
|
public static CentronWebService GetConnection()
|
|
{
|
|
var url = "http://localhost:1234/CentronService";
|
|
return new CentronWebService(url);
|
|
}
|
|
} |