This document is intended for developers who are interested in learning how to modify and test the Helix Authentication Extension.
Automated tests for this extension are written using JavaScript testing tools
(Chai and Mocha). To prepare and run the tests, you will need to install
Node.js LTS and run these commands in the directory
containing the package.json
file:
npm install
npm test
A container with a standalone instance of Helix Core is defined for use with
Docker and Docker
Compose. To build and start the container,
use docker-compose
like so:
docker-compose build p4d.doc
docker-compose up -d p4d.doc
This will set up an instance of Helix Core with several test users, as well as install the extension with a sensible configuration for testing with a test installation of the authentication service, as described in the next section.
The docker containers have names that are used internally to find each other. In order for the container host to resolve these names, it may be helpful to install dnsmasq. The easiest way to run dnsmasq is via Docker. If using a macOS system, the commands below will get dnsmasq and the host configured appropriately:
$ echo "address=/.doc/127.0.0.1" | sudo tee - /etc/dnsmasq.conf
$ sudo mkdir /etc/resolver
$ echo 'nameserver 127.0.0.1' | sudo tee /etc/resolver/doc
$ docker run --name dnsmasq -d -p 53:53/udp -p 5380:8080 \
-v /etc/dnsmasq.conf:/etc/dnsmasq.conf \
--log-opt 'max-size=1m' -e 'HTTP_USER=admin' -e 'HTTP_PASS=admin' \
--restart always jpillora/dnsmasq
The containers for the authentication service and test identity providers
(Shibboleth for SAML and IdentityServer for OIDC) are in a separate
repository and can
be installed using docker-compose
as described in the documentation for that
project.
In addition to a standalone container running a single instance of Helix Core, there are two containers that define a commit/edge server pair. They are configured in a similar fashion to the standalone instance, with the addition of one being a commit server and the other being an edge server. To bring these containers up and get them connected, use the following commands:
docker-compose up --build -d chicago.doc
docker-compose up --build -d tokyo.doc
docker-compose exec chicago.doc /setup/login.sh
The last exec
command is to perform the commit service user login to the edge
server instance, which cannot be done until both containers have been started
(hence it cannot be done during the build).
A container that installs the latest release of Swarm, configured to connect to
the Helix Server in the p4d.doc
container, is defined with the name
swarm.doc
, and can be built and started like so:
docker-compose up --build -d swarm.doc
This Swarm instance is pre-configured to use the authentication service instance
reachable via a web proxy at https://haproxy.doc/
, which is running in a
container defined in the Helix Authentication Service code base.
Setting P4USEBROWSER
to false
prevents the browser from opening when you
invoke p4 login
.
The configuration script (bin/configure-login-hook.sh
) uses the GNU getopt
utility to read the command line arguments. However, macOS does not ship with
GNU getopt installed. To run the script on macOS, first install GNU getopt via
Homebrew gnu-getopt
package, and then run the script with
the path to the GNU getopt directory:
$ PATH="/usr/local/opt/gnu-getopt/bin:$PATH" ./bin/configure-login-hook.sh