How BastionXP CA is tested¶
A certificate authority is trusted with the keys to your infrastructure. This page says how BastionXP CA is tested before a change is accepted.
Summary¶
- More than 500 test cases cover the 17 features of the test specification, from CA creation to revocation, ACME, SCEP and the logins.
- More test code than product code: about 1.3 lines of tests for every line of BastionXP CA.
- Over 80% statement coverage from the unit and integration tests alone: more than 80% of the statements in BastionXP CA run in those tests, before the end-to-end tests run.
- The real binary, checked by other software: the end-to-end tests run
bxpthe way you do and verify the results with openssl, OpenSSH, certbot, lego, acme.sh, Caddy, Go's autocert and micromdm's scepclient. - Every parser of untrusted input is fuzzed, weekly, each against an invariant such as "a forged token is never accepted".
- Refusals are tested as carefully as successes: every way a request can be refused, and the message the user sees.
- Every change passes the unit, integration and end-to-end tests and a test of the container image before it is accepted.
- The specification cannot drift from the tests: its case tables are generated from the tests, and a change that leaves them out of date fails.
Three levels¶
| Level | What it shows | Runs |
|---|---|---|
| Unit tests | Each part decides correctly on its own: policy, name checks, key handling, certificate contents. | every change |
| Integration tests | The parts work together: a real server on a loopback port with the CA, the database and the client, and stand-ins for identity providers, directories and ACME hosts. | every change |
| End-to-end tests | The real bxp binary, run as separate processes the way you run it, checked with software that is not BastionXP CA's. |
every change, on Linux |
Checked with other software¶
The end-to-end tests do not trust BastionXP CA to check itself. Every certificate is verified with software people use:
| Area | Checked with |
|---|---|
| TLS certificates and chains | openssl verify, openssl s_server and s_client, curl, Go's crypto/tls (mutual TLS too) |
| Revocation | openssl ocsp and openssl crl -verify |
| SSH certificates | ssh-keygen -L, a real sshd login with ssh, a real ssh-agent |
| ACME | certbot, lego and acme.sh: issue, renew (also through renewal information) and revoke, over http-01, tls-alpn-01 and dns-01; Caddy and Go's autocert: certificates for the sites they serve, over http-01 and tls-alpn-01 |
| SCEP | micromdm's scepclient |
| A CA under a company root | a two-level company PKI made with openssl |
| Kubernetes | cert-manager in a Kubernetes cluster, with BastionXP CA running there from its container image: a certificate, a wildcard, a refused name, weekly |
| Logins | Keycloak (OIDC) and a Samba Active Directory domain controller (LDAP), weekly |
The client versions are pinned and named on each client's page under ACME clients.
Security testing¶
- Fuzzing: every parser of input that anyone can send (ACME requests, SCEP messages, OCSP requests, certificate requests, tokens, renewal proofs, key files, LDAP filters) is fuzzed weekly, each against an invariant: a forged token is never accepted, a username never changes an LDAP filter, a request never causes a server error.
- No secrets in logs: an end-to-end test runs the server at its most detailed log level through tokens, logins, renewal and revocation, and checks that no token, passphrase or private key appears in the logs or in any command's output.
- Refusals: every way a request can be refused is tested, and that a refused request does not use up its one-time token.
- Concurrency: 150 certificates issued in parallel while revocations, listings and backups run on the same database: nothing lost, no process fails.
Platforms¶
| Platform | Tested |
|---|---|
| Linux (Ubuntu) | everything, on every change |
| macOS | unit and integration tests, and a smoke test of the binary |
| Windows | unit and integration tests, and a smoke test of the binary (the CA server itself is supported on Linux) |
| Container image | built and run as documented: init, serve, a certificate, a clean stop; also before every release |
| systemd units | checked with systemd-analyze verify |
Known limits¶
The specification lists what is not tested, feature by feature. The main ones: identity providers other than Keycloak (Entra ID, Okta, Google, AD FS), Windows Server Active Directory, device management systems, Traefik, and load testing.
The full specification¶
The test specification in the repository has every test case, feature by feature: its level, what it verifies, and where it is. It also says how to run the tests and what a change must pass before it is accepted.