mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-23 15:51:14 +00:00
Add TileProvision configuration and gRPC service for tile delivery
- Introduced new TileProvision settings in appsettings.json, including MaxTilesPerBatch and ProgressEmitIntervalSeconds. - Configured TileProvisionConfig in Program.cs to bind the new settings. - Added gRPC service for RouteTileDelivery in Program.cs to handle tile delivery requests. - Updated SatelliteProvider.Api.csproj to include Grpc.AspNetCore package and added protobuf file for tile provision. - Enhanced AuthenticationServiceCollectionExtensions to handle JWT token extraction from the Authorization header. - Registered additional services in RouteManagementServiceCollectionExtensions for tile processing. These changes enhance the API's capability to manage tile provisioning and delivery efficiently.
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
using System.Security.Cryptography;
|
||||
using FluentAssertions;
|
||||
using SatelliteProvider.Services.RouteManagement.TileProvision;
|
||||
|
||||
namespace SatelliteProvider.Tests;
|
||||
|
||||
public class ClientTileCatalogTests
|
||||
{
|
||||
private static readonly byte[] ServerHash = SHA256.HashData("server-tile"u8.ToArray());
|
||||
private static readonly byte[] ClientHash = SHA256.HashData("client-tile"u8.ToArray());
|
||||
|
||||
[Fact]
|
||||
public void ShouldSkipForClient_HashMatch_Skips()
|
||||
{
|
||||
var client = new ClientTileSnapshot(18, 1, 2, 1.0, DateTime.UtcNow.AddDays(-1), ServerHash);
|
||||
var server = new ServerTileProspect(2.0, DateTime.UtcNow, ServerHash);
|
||||
|
||||
ClientTileCatalog.ShouldSkipForClient(client, server).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ShouldSkipForClient_MetadataSufficient_Skips()
|
||||
{
|
||||
var client = new ClientTileSnapshot(18, 1, 2, 0.5, DateTime.UtcNow, null);
|
||||
var server = new ServerTileProspect(1.0, DateTime.UtcNow.AddHours(-1), null);
|
||||
|
||||
ClientTileCatalog.ShouldSkipForClient(client, server).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ShouldSkipForClient_WorseResolution_DoesNotSkip()
|
||||
{
|
||||
var client = new ClientTileSnapshot(18, 1, 2, 2.0, DateTime.UtcNow, null);
|
||||
var server = new ServerTileProspect(1.0, DateTime.UtcNow, null);
|
||||
|
||||
ClientTileCatalog.ShouldSkipForClient(client, server).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ShouldSkipForClient_OlderCapture_DoesNotSkip()
|
||||
{
|
||||
var client = new ClientTileSnapshot(18, 1, 2, 0.5, DateTime.UtcNow.AddDays(-2), null);
|
||||
var server = new ServerTileProspect(1.0, DateTime.UtcNow, null);
|
||||
|
||||
ClientTileCatalog.ShouldSkipForClient(client, server).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ShouldSkipForClient_NoClientRecord_DoesNotSkip()
|
||||
{
|
||||
var server = new ServerTileProspect(1.0, DateTime.UtcNow, ServerHash);
|
||||
|
||||
ClientTileCatalog.ShouldSkipForClient(null, server).Should().BeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ShouldSkipForClient_DifferentHashWithInsufficientMetadata_DoesNotSkip()
|
||||
{
|
||||
var client = new ClientTileSnapshot(18, 1, 2, 2.0, DateTime.UtcNow.AddDays(-2), ClientHash);
|
||||
var server = new ServerTileProspect(1.0, DateTime.UtcNow, ServerHash);
|
||||
|
||||
ClientTileCatalog.ShouldSkipForClient(client, server).Should().BeFalse();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user