TestEnvironment
Seeds a realistic identity test environment in Entra ID, Active Directory, Okta,
Authentik, FreeIPA, PingOne SSO or OneLogin, and tears it down again cleanly, proving ownership of every object
before deleting it.
π Purpose
TestEnvironment seeds a realistic identity environment you can point scripts at, and tears
it down again cleanly. One module, several directories: you name the provider once, at connect
time, and everything afterwards reads the connection rather than being told again.
Connect-TestEnvironment -Provider Entra -TenantId <tenant-guid> -CertificateThumbprint <thumb>
New-TestEnvironment
Get-TestEnvironmentReport
Test-TestEnvironment
Remove-TestEnvironment -Force
Seven providers.
| Provider |
Connecting needs |
Seeds |
Entra |
a certificate, or a one-off device-code bootstrap |
~1,180 objects across thirteen types, held in administrative units |
AD |
nothing β the caller's own Windows identity |
~1,160 objects across nine types, held in OU=TestData, resolving in DNS zones of their own |
Okta |
an OAuth service app, bootstrapped once from an API token |
~65 objects across eleven types, seed-tagged |
Authentik |
a service account token, bootstrapped once from an API token |
~490 objects across seventeen types, under a user path of their own |
FreeIPA |
a service account password, bootstrapped once from an administrator's credential |
~1,010 objects across thirty-three types, seed-tagged, in DNS zones of their own |
PingOne |
a worker application's client id and secret |
~350 PingOne SSO objects: populations, users, groups, custom user attributes, resources and applications, held in populations of their own |
OneLogin |
an API credential's client id and secret |
~350 objects: users in every lifecycle state OneLogin keeps, roles, groups, policies, apps, app rules, API authorizations, user mappings, a Smart Hook, a sign-up profile and custom user fields, proved by what they hold |
Each provider has its own README, linked above, covering what it seeds, how it connects, what it
needs, and the things about that directory that are only learnable by running against it. This
page covers what every provider shares.
What every provider guarantees:
- β
Ownership is proven β teardown asks the container it created, or the tag it wrote, and nothing is deleted for merely looking like test data
- β
Safe in a directory you care about β a seeded Conditional Access policy is never enforcing, a seeded role eligibility is never active, a seeded Authentik flow is never anyone's default, a FreeIPA rule the realm shipped with is never touched, a seeded OneLogin mapping can act on seeded people only and its hook and sign-up page are always off, and none of those states is a parameter
- β
-WhatIf beats -Force β on every destructive command, pinned by tests
- β
Idempotent β a re-run reuses what exists rather than duplicating it
- β
One prefix and one tag everywhere β
ZZ-TEST- on names and ZZ-TEST-seed where the directory can store it, so seeded objects can be found across a hybrid estate with one filter
- β
No dependencies β no SDKs, no gallery installs, works on a stock 5.1 host; the AD provider imports RSAT at connect time and says so when it is absent
- β
Shared people β the AD, Entra, Authentik, FreeIPA, PingOne and OneLogin providers seed the same people, so hybrid identity matching is testable, and
Compare-TestEnvironment proves two of them agree
- β
Verifiable β
Test-TestEnvironment checks the seeded estate against the seed data and names what is missing, what is extra and which name came back wrong
π¦ Installation
From the PowerShell Gallery:
Install-PSResource -Name TestEnvironment
# Or, on a host that still only has PowerShellGet v2:
Install-Module -Name TestEnvironment -Scope CurrentUser
Requires Windows PowerShell 5.1 or PowerShell 7, and nothing else: RequiredModules is empty
and a contract test keeps it that way. The AD provider needs RSAT's ActiveDirectory and
GroupPolicy modules, which it imports at connect time and names clearly when they are absent.
Windows PowerShell 5.1 is kept because a freshly built domain controller has nothing else; the
REST providers are better served by PowerShell 7.4, and the module detects which it is running
on once, at import, and uses what that PowerShell can do. Get-TestEnvironmentRuntime shows the
decision.
The Entra, Okta, Authentik, FreeIPA, PingOne and OneLogin providers need nothing beyond a stock host, on any platform.
From a clone:
git clone https://github.com/fadwen/TestEnvironment.git
Import-Module .\TestEnvironment\TestEnvironment.psd1
π Quick Start
Every session is the same four steps, and only the connect line differs by provider. The first
run against a tenant or org bootstraps the credential the module uses from then on; each provider
README says how.
Import-Module TestEnvironment
Connect-TestEnvironment -Provider Entra -TenantId <tenant-guid> -CertificateThumbprint <thumbprint>
Connect-TestEnvironment -Provider AD # the caller's own identity
Connect-TestEnvironment -Provider Okta -OrgUrl https://<org>.okta.com -ServiceApp
Connect-TestEnvironment -Provider Authentik -BaseUrl https://<instance> -ServiceAccount
Connect-TestEnvironment -Provider FreeIPA -BaseUrl https://<server> -ServiceAccount
Connect-TestEnvironment -Provider PingOne -EnvironmentId <guid> -ClientId <guid> -UseStoredSecret
Connect-TestEnvironment -Provider OneLogin -Subdomain <account> -UseStoredCredential
# ...or, for any provider that has stored its credential, the one name they all answer to:
Connect-TestEnvironment -Provider <name> ... -UseStoredCredential
New-TestEnvironment -WhatIf # see what it would do
New-TestEnvironment -ShowProgress # do it
Get-TestEnvironmentReport # see what you got
Test-TestEnvironment # prove it matches the seed data, name by name
Repair-TestEnvironment # put back whatever that found missing
Remove-TestEnvironment -WhatIf # see what teardown would remove, then drop -WhatIf
Get-TestEnvironmentProvider lists the providers that were discovered and which one is active.
π Credentials
The Entra, Okta, Authentik and FreeIPA providers bootstrap a service identity once and connect as
it from then on. The record of what to connect with lives under ~/.testenvironment/, outside any
working tree, and never holds a private key: an Entra certificate goes to Cert:\CurrentUser\My by
default, or to a SecretStore vault with -UseSecretStore, which is the portable path off Windows.
A secret that has to be on disk, an Authentik token or a FreeIPA password, is DPAPI-protected
there on Windows and goes to the vault with the same switch elsewhere.
SecretStore is shared in two ways that are not obvious. Its configuration is per user, not per
vault, so a store that anything else has already configured keeps that password, and this
module's default will not open it: pass -VaultPassword with the existing one, and the module
says so when that is the problem rather than repeating SecretStore's own message. And two vault
names registered against the store are two names for one store, not two containers, so every
secret this module writes is namespaced. SecretManagement and SecretStore are never required;
they are installed on demand, to CurrentUser scope, only under the explicit -UseSecretStore.
π‘ Core functions
The provider-agnostic surface. Each of these reads the active connection and forwards to the
provider's own command, mirroring its parameters, so tab completion and binding errors come from
the real command rather than from a pass-through that accepts anything.
Connection
Connect-TestEnvironment β -Provider first, then whatever the provider's connect needs; reads the directory back rather than trusting the parameter, so a connection to the wrong one is visible immediately
Disconnect-TestEnvironment β clears the credential without unloading the module
Get-TestEnvironmentProvider β the providers discovered at import, and which is active
Get-TestAccessToken β the token in use and what it carries
New-TestServiceApp β bootstraps the identity the module authenticates as from then on, and hands over to it
Get-TestServiceApp β what is stored, and whether the credential still works
Environment
New-TestEnvironment β the orchestrator: every step in dependency order, each attempted, recorded and followed by the next
Remove-TestEnvironment β teardown, proving ownership before deleting
Get-TestEnvironmentReport β Console, JSON, CSV or HTML, with the same -OutputFormat, -OutputPath and -PassThru and the same report shape for every provider
Test-TestEnvironment β compares the directory with the seed data: every object present and found the way teardown finds it, nothing extra, every name equal by codepoint, every membership in place; one result object for every provider
Compare-TestEnvironment β compares the people two connected providers hold, by login key and then by name, and judges the one thing a hybrid identity match trips over: a name that differs by codepoint between two directories
Repair-TestEnvironment β re-runs only the seed steps that own what verification found missing, then verifies again; what the data does not describe is reported and left for teardown
Update-TestContainment β reconciles container membership where the provider has containers
Components
Each provider also exports the commands that build one object type at a time, so a single type
can be rebuilt without re-seeding everything: New-Entra*, New-ADTest*, New-Okta*,
New-Authentik*, New-FreeIPA*, New-PingOne* and New-OneLogin*. The provider READMEs list them, and Get-Help describes each.
π§Ή Teardown
Remove-TestEnvironment -WhatIf # always worth running first
Remove-TestEnvironment -Force
Remove-TestEnvironment -Keep Users, Groups -Force # rebuild everything above the directory
Teardown asks the container, then proves ownership. Entra enumerates the administrative
units it created, AD enumerates OU=TestData, Okta reads the seed tag, Authentik lists the
users under the seed path, FreeIPA filters on the tag in userclass and requires the marker in a
description, PingOne asks the populations it created before falling back to a custom attribute
carrying the tag, and OneLogin proves a person by the tag in a custom field and a role, group or
mapping by holding seeded people and nothing else. Nothing is deleted for merely matching a name, and the fallback paths
that run when a container is gone still refuse objects that are not ours.
Rights are judged before anything is prompted for. A layer the identity cannot delete is set
aside with one warning rather than confirmed object by object and refused object by object; the
Entra README describes how that judgement is made.
-WhatIf beats -Force. Somebody passing both is asking what would happen, not asking to be
spared the question. -Force defeating -WhatIf was the worst defect an earlier module ever
shipped, and every Remove suite pins it.
Each provider's README covers the order its directory forces and what happens after a delete.
π Command help
Get-Help on any exported command reads compiled help, and about_TestEnvironment covers what no
single command owns: the provider model, the prefix and seed tag, the safety properties with no
parameter, and how teardown proves ownership.
Get-Help New-TestEnvironment -Full
Get-Help about_TestEnvironment
Get-Help New-EntraGroup -Online # the same page on GitHub
The source is the Markdown under docs\TestEnvironment\; editing help means editing that and
running ./Build/Build-Help.ps1, which the project instructions describe.
π§ͺ Tests
More than 2,900 Pester tests, with every Graph call, RSAT cmdlet, Okta, Authentik, FreeIPA, OneLogin and
PingOne request mocked, so the suite reaches no tenant, no domain, no org, no instance and no realm, and
is safe to run on a workstation. It takes about a minute on a workstation, and about four minutes
on a GitHub-hosted runner.
Invoke-Pester -Path .\Tests
Tests/README.md