Premiere commit - Omika
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Omika.Core\Omika.Core.csproj" />
|
||||
<ProjectReference Include="..\..\src\Omika.Data\Omika.Data.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,60 @@
|
||||
// Probe pour vérifier le status API de l'opération E2E.
|
||||
// Génère un token via ITokenService (même mécanisme que le test E2E),
|
||||
// puis appelle GET /api/sync/status/{operationId}.
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.Json;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Omika.Core.Configuration;
|
||||
using Omika.Core.Interfaces.Mobile;
|
||||
using Omika.Core.Services.Mobile;
|
||||
|
||||
const string operationId = "5b915439-d9d9-44b5-9552-1f8f90db96c3";
|
||||
const string apiBaseUrl = "http://localhost:5097";
|
||||
|
||||
// Construire la configuration avec la clé de signature.
|
||||
var config = new ConfigurationBuilder()
|
||||
.AddInMemoryCollection(new Dictionary<string, string?>
|
||||
{
|
||||
["MobileAuth:SigningKey"] = "test-signing-key-for-integration-tests-only"
|
||||
})
|
||||
.Build();
|
||||
|
||||
var services = new ServiceCollection();
|
||||
services.AddSingleton<IConfiguration>(config);
|
||||
services.AddOptions<MobileAuthOptions>()
|
||||
.Configure<IConfiguration>((options, configuration) =>
|
||||
configuration.GetSection(MobileAuthOptions.SectionName).Bind(options));
|
||||
services.AddSingleton<ITokenService, TokenService>();
|
||||
var provider = services.BuildServiceProvider();
|
||||
|
||||
var tokenService = provider.GetRequiredService<ITokenService>();
|
||||
string token = tokenService.GenerateToken(new MobileTokenIdentity
|
||||
{
|
||||
CodeClient = "E2E_TEST",
|
||||
DeviceId = "e2e-device-001",
|
||||
UserId = "e2e-user-001",
|
||||
CollaborateurId = "1",
|
||||
NumeroLicence = "e2e-licence-test"
|
||||
});
|
||||
|
||||
Console.WriteLine($"Token généré: {token[..Math.Min(40, token.Length)]}...");
|
||||
|
||||
using var client = new HttpClient();
|
||||
client.BaseAddress = new Uri(apiBaseUrl);
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
|
||||
|
||||
Console.WriteLine($"\n=== GET /api/sync/status/{operationId} ===");
|
||||
try
|
||||
{
|
||||
var response = await client.GetAsync($"/api/sync/status/{operationId}");
|
||||
Console.WriteLine($"HTTP {(int)response.StatusCode} {response.StatusCode}");
|
||||
string body = await response.Content.ReadAsStringAsync();
|
||||
Console.WriteLine($"Body: {body}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"ERREUR: {ex.Message}");
|
||||
}
|
||||
|
||||
Console.WriteLine("\nProbe status terminé.");
|
||||
Reference in New Issue
Block a user