using System.Security.Cryptography;
using DodoSSH.Domain;
namespace DodoSSH.Api.Tests;
/// Directly-inserted rows, for tests whose subject is not enrollment itself.
///
/// Sync tests seed a current key rather than driving the enrollment endpoint. Going through the
/// endpoint would make every sync failure ambiguous between the two features, and would make the
/// sync suite fail whenever enrollment changed.
///
internal static class Seed
{
///
/// A minimal current identity key, enough to satisfy the enrolled policy.
///
///
/// The keys and fingerprint are random because user_key has a global unique index on the
/// fingerprint: fixed bytes would make the second seeded user in the shared database collide.
///
internal static UserKey CurrentKey(Guid userId, DateTimeOffset now) =>
new()
{
Id = Guid.CreateVersion7(),
UserId = userId,
Generation = 1,
EncryptionPublicKey = RandomNumberGenerator.GetBytes(32),
SigningPublicKey = RandomNumberGenerator.GetBytes(32),
FingerprintSha256 = RandomNumberGenerator.GetBytes(32),
Statement = "{}",
StatementSignature = RandomNumberGenerator.GetBytes(64),
IsCurrent = true,
CreatedAtUtc = now,
};
}