Skip to content
konstantinvlasenkoPublic

About

Fitnesse Slim implementation in PowerShell. PowerSlim makes it possible to use PowerShell in the acceptance testing

Topics

Resources

Stars

48 stars

Watchers

22 watching

Forks

Repository files navigation

PowerSlim - An implementation of FitNesse Slim in PowerShell

CI

https://powerslim.slack.com

!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.

Symbols

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).

Aborting and ignoring

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.

Running the tests

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.

Remote agents

./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.

Supported Platforms

  • Windows: PowerShell 7+ or Windows PowerShell 5.1
  • Linux and macOS: PowerShell 7+

March 4, 2017

  • Now you can run PowerSlim on Linux or Ubuntu server! Thanks to @mikeplavsky

March 1, 2017

  • 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_PORT is no longer needed.

October 7, 2016

June 17, 2015

  • REST. New actions: get, post, patch and update.

May 1, 2015

August 25, 2014

February 26, 2013

December 19, 2012

November 14, 2012

About

Fitnesse Slim implementation in PowerShell. PowerSlim makes it possible to use PowerShell in the acceptance testing

Topics

Resources

Stars

48 stars

Watchers

22 watching

Forks

Releases

Packages

Used by

Contributors

Languages