OrionLedger.Conformance
0.5.0
dotnet add package OrionLedger.Conformance --version 0.5.0
NuGet\Install-Package OrionLedger.Conformance -Version 0.5.0
<PackageReference Include="OrionLedger.Conformance" Version="0.5.0" />
<PackageVersion Include="OrionLedger.Conformance" Version="0.5.0" />
<PackageReference Include="OrionLedger.Conformance" />
paket add OrionLedger.Conformance --version 0.5.0
#r "nuget: OrionLedger.Conformance, 0.5.0"
#:package OrionLedger.Conformance@0.5.0
#addin nuget:?package=OrionLedger.Conformance&version=0.5.0
#tool nuget:?package=OrionLedger.Conformance&version=0.5.0
OrionLedger.Conformance
A reusable xUnit conformance suite for
OrionLedger IApiKeyStore implementations. Write a
custom store over your database, derive one test class from ApiKeyStoreConformanceTests, supply a
factory that returns a fresh store, and inherit the full battery of contract tests.
Part of the Orion family.
What it checks
Deriving from ApiKeyStoreConformanceTests runs facts that assert your store:
- stores a record and finds it again by hash and by id, and returns null on a miss (not an error);
- round-trips scopes exactly, including the empty set;
- persists revocation, the rotation timestamps (
SupersededAt,SupersededById,RetiresAt), and the last-used stamp and counter throughUpdateAsync; - accumulates the last-used counter under sequential updates and, critically, does not lose counts under concurrent updates (50 parallel verifies must land a count of 50);
- returns every record for a subject (including revoked ones) from
FindBySubjectAsync, matches the subject case-sensitively, and returns an empty list for an unknown or empty subject.
Install
dotnet add package OrionLedger.Conformance
Add it to a test project alongside the xUnit runner packages
(Microsoft.NET.Test.Sdk, xunit.runner.visualstudio).
Usage
using Moongazing.OrionLedger.Conformance;
using Moongazing.OrionLedger.Storage;
public sealed class MyStoreConformanceTests : ApiKeyStoreConformanceTests
{
// Return a fresh, empty store per test. xUnit constructs the class once per fact, so each
// test is isolated.
protected override Task<IApiKeyStore> CreateStoreAsync()
=> Task.FromResult<IApiKeyStore>(new MyApiKeyStore(/* fresh backing store */));
// Optional: release per-test resources (a connection, a temporary database, a dropped schema).
protected override Task DisposeStoreAsync(IApiKeyStore store)
=> ((MyApiKeyStore)store).DisposeAsync().AsTask();
}
That single class gives you the whole contract suite. Use the protected NewRecord(...) helper if
you want to add store-specific tests in the same class; it builds a valid ApiKeyRecord with a
unique id and hash on each call.
Note on FindBySubjectAsync
FindBySubjectAsync is an optional part of the IApiKeyStore contract (it has a throwing default).
The subject facts in this suite expect your store to override it. If your store intentionally
does not support lookup by subject, do not derive the whole suite blindly; compose only the facts you
support, or override the subject tests to assert NotSupportedException.
License
Licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- OrionLedger (>= 0.5.0)
- xunit (>= 2.9.2)
-
net8.0
- OrionLedger (>= 0.5.0)
- xunit (>= 2.9.2)
-
net9.0
- OrionLedger (>= 0.5.0)
- xunit (>= 2.9.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.