PowerSlim - An implementation of FitNesse Slim in PowerShell
!define TEST_SYSTEM {slim}
!define COMMAND_PATTERN (pwsh -NoProfile -NonInteractive -File ./slim.ps1)
Requires PowerShell 7+ (pwsh) on any platform, or Windows PowerShell 5.1 (use powershell instead of pwsh in COMMAND_PATTERN). PowerShell 2.0–5.0 are no longer supported.
PowerSlim implements SLIM protocol version 0.5. FitNesse talks to it over stdin/stdout by default, so no port is needed. Defining SLIM_PORT (e.g. !define SLIM_PORT (8090)) switches to a TCP port on 127.0.0.1, as before.
A symbol (|$name=|eval|...|) is also a PowerShell variable, so $name in code gets its value with its type, and the value is never pasted into the code. FitNesse's text rules still apply where PowerShell would not expand a variable: inside single-quoted strings ('$name'), for a name followed by more letters ("$name_suffix") and in command names (te$name).
throw 'StopTest' stops the page and throw 'StopSuite' the suite. throw 'IgnoreScriptTest' ignores the rest of the script table and throw 'IgnoreAllTests' the rest of the page.
Requires Java 11+ and Pester 5+.
./tests/Invoke-AcceptanceTests.ps1 # FitNesse suites (downloads the pinned FitNesse jar)
./tests/Invoke-AcceptanceTests.ps1 -Shell powershell # same, with Windows PowerShell 5.1 running slim.ps1
Invoke-Pester ./tests # unit tests for slim.ps1 and client.ps1
Invoke-ScriptAnalyzer -Path . -Recurse -Settings ./PSScriptAnalyzerSettings.psd1
CI runs all of these on Linux, macOS and Windows (PowerShell 7 and 5.1).
PowerSlim.SuiteWrongFailedException fails on purpose; it is checked from SuiteCommon.TestScenario.
./slim.ps1 <port> server starts a remote agent. An agent runs any PowerShell it receives, so it only talks TLS (1.2 or newer) with client certificates:
- the agent presents its certificate, and the runner checks that it was issued by your CA and names the target host;
- the runner presents its certificate, and the agent refuses any client without one issued by the same CA.
Certificates from other authorities, including those the system trusts, are rejected. Both sides read the same settings:
| Variable | Value |
|---|---|
POWERSLIM_TLS_CERTIFICATE |
PFX file with this machine's certificate and private key |
POWERSLIM_TLS_PASSWORD |
Password of that PFX file |
POWERSLIM_TLS_CA |
Certificate (PEM or DER) of the CA that issues agent and runner certificates |
Set them where FitNesse runs (the runner inherits them) and on each agent machine, or pass -Certificate and -CertificateAuthority to the agent. Agent certificates need the server authentication usage and the agent's host name or IP address. Runner certificates need client authentication. An agent without these settings does not start. Revocation is not checked, so keep certificates short-lived.
With OpenSSL, for example:
openssl req -x509 -newkey rsa:3072 -nodes -days 365 -subj "/CN=PowerSlim CA" -keyout ca.key -out ca.pem \
-addext basicConstraints=critical,CA:true -addext keyUsage=critical,keyCertSign,cRLSign
openssl req -newkey rsa:3072 -nodes -subj "/CN=agent1" -keyout agent1.key -out agent1.csr
openssl x509 -req -in agent1.csr -CA ca.pem -CAkey ca.key -CAcreateserial -days 30 -out agent1.pem \
-extfile <(printf "subjectAltName=DNS:agent1.example.com\nextendedKeyUsage=serverAuth")
openssl pkcs12 -export -in agent1.pem -inkey agent1.key -out agent1.pfx # asks for the PFX password
Make the runner certificate the same way, with extendedKeyUsage=clientAuth and no subjectAltName.
An agent listens on 127.0.0.1 by default. To reach it from other machines: ./slim.ps1 35 server -BindAddress 0.0.0.0. A runner listens on loopback only.
Targets without an explicit port (|script|Remote|myhost|) use port 35, or $env:POWERSLIM_REMOTE_PORT if set.
Examples are available in the acceptance tests FitNesseRoot/PowerSlim.
- Windows: PowerShell 7+ or Windows PowerShell 5.1
- Linux and macOS: PowerShell 7+
- Now you can run PowerSlim on Linux or Ubuntu server! Thanks to @mikeplavsky
- Fitnesse 20161106 introduced bracking change. FitNesse and Slim can now communicate over stdin/stdout. This removes the hassle with network ports 977
PowerSlim now supports stdin/stdout, so
SLIM_PORTis no longer needed.
- REST. New actions: get, post, patch and update.