Agentics.MitID.Testing 0.2.6

dotnet add package Agentics.MitID.Testing --version 0.2.6
                    
NuGet\Install-Package Agentics.MitID.Testing -Version 0.2.6
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Agentics.MitID.Testing" Version="0.2.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Agentics.MitID.Testing" Version="0.2.6" />
                    
Directory.Packages.props
<PackageReference Include="Agentics.MitID.Testing" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Agentics.MitID.Testing --version 0.2.6
                    
#r "nuget: Agentics.MitID.Testing, 0.2.6"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Agentics.MitID.Testing@0.2.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Agentics.MitID.Testing&version=0.2.6
                    
Install as a Cake Addin
#tool nuget:?package=Agentics.MitID.Testing&version=0.2.6
                    
Install as a Cake Tool

Agentics.MitID.Testing

Approve a MitID login from a test. No phone, no browser, about a second.

MitID's pre-production environment lets a code app be played over plain REST — every value posted comes out of a previous response, and the test backend signs on the app's behalf. So the moment your Playwright test reaches "Åbn MitID app og godkend", one call finishes the login:

var mitid = MitIdApprover.FromEnvironment();

await page.ClickAsync("#approve-on-another-device-button");   // dispatches the transaction
var approval = await mitid.ApproveAsync("commuteconnects", "Oscar39838", TimeSpan.FromSeconds(30));

Console.WriteLine(approval.Reference);   // Commute Connects (TEST): Log på hos Commute Connects (TEST)

Pre-production only. The identities are invented by MitID's own test-person generator and refer to nobody. The host is a constant, not a setting — this library cannot be pointed at production MitID, by design.

Two ways to name a user

MitIdApprover.Direct() MitIdApprover.ViaService(url, token)
Talks to pp.mitid.dk an agent-mitid instance
Needs nothing — MitID hands its client credentials to any caller a bearer token, and the service up
Names a user by bruger-ID project + bruger-ID, resolved through a registry
PIN the Test Tool default, or yours whatever the registry holds
Survives someone recreating the user no yes

FromEnvironment() uses the service when MITID_SERVICE_URL and MITID_MCP_TOKEN are set and falls back to direct when they are not — the shared registry in CI, a working test on a laptop with no token.

The one thing that breaks tests

"Åbn app på anden enhed" is a choice, not a wait. Nothing is dispatched to any app until that button is pressed, and on the MitID login page it lives inside an about:blank iframe:

foreach (var frame in page.Frames)
{
    if (await frame.QuerySelectorAsync("#approve-on-another-device-button") is not null)
    {
        await frame.ClickAsync("#approve-on-another-device-button");
        break;
    }
}

Approve called before that click finds nothing pending, no matter how long it polls. (The user-ID input has the same trap in reverse: nine of the ten inputs on that page are hidden decoys, so select input.mitid-core-user__user-id:visible.)

Refusal, and unattended approval

RejectAsync is the same protocol call with one bit flipped, so a test can check what the app under test does when the user says no — the relying party gets an OAuth error, not a code.

AutoApproveAsync(project, userId, window) opens a time-boxed window in which the service answers by itself. Reach for it only when the login is triggered somewhere the test cannot call approve — a browser someone is clicking by hand. When the test drives the login, ApproveAsync with a wait is better: it is exact, it arms nothing, and it puts the reference text in your own assertions.

What this is not

Nothing here creates a session in your application. It plays the MitID app; your app still goes through its own broker and its own OIDC exchange. And it is not a MitID client library — there is no production surface in it at all.

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.6 89 9/3/2026
0.2.5 106 8/29/2026