Welcome to the Fabric-SDK-Node test readme.
There are two types of testing that are used to support Fabric-SDK-Node:
- Unit
- Scenario
Unit tests are located in a package/test
directory that mirrors the package/lib
directory and are Mocha based.
The scenario tests are written in typescript and use Cucumber, with the intention of providing high level test coverage from a scenario perspective. For more information, please refer to the README within the scenario directory.
Test certificates are set to expire a year after generation. Due to this the test suite generates new certificates as part of the build process, and is a manual requirement prior to running the tests locally. This process is orchestrated using test scripts that:
- Generate the crypto-material, matching channel blocks and fabric-ca certificates required by the docker-compose files and test suites
Use the npm task npm run installAndGenerateCerts
. This is only required to be performed upon initial project clone, and then yearly afterwards.
The folder structure is the following:
test
│ README.md
│
└───ts-fixtures
└───ts-scenario
ts-fixtures
holds all the configuration files used by the integration and scenario teststs-scenario
contains the typescripts scenario test suite
Below are the steps required to run Hardware Security Module (HSM) tests locally.
In order to run the tests in the absence of a real HSM, a software emulator of the PKCS#11 interface is required. For more information please refer to SoftHSM.
SoftHSM can either be installed using the package manager for your host system:
- Ubuntu:
apt-get install softhsm2
- macOS:
brew install softhsm
- Windows: unsupported
Or compiled and installed from source:
- install openssl 1.0.0+ or botan 1.10.0+
- download the source code from https://dist.opendnssec.org/source/softhsm-2.2.0.tar.gz
tar -xvf softhsm-2.2.0.tar.gz
cd softhsm-2.2.0
./configure --disable-gost
(would require additional libraries, turn it off unless you need gost algorithm support for the Russian market)make
sudo make install
export SOFTHSM2_CONF="./test/ts-fixtures/hsm/softhsm2.conf"
softhsm2-util --init-token --slot 0 --label "ForFabric" --pin 98765432 --so-pin 1234
The Security Officer PIN, specified with the --so-pin
flag, can be used to re-initialize the token,
and the user PIN (see below), specified with the --pin
flag, is used by applications to access the token for
generating and retrieving keys.
By default the tests run with SoftHSM using slot 0
and user PIN 98765432
. If your configuration is different, use
these environment variables to pass in the values:
- PKCS11_LIB - path to the SoftHSM2 library; if not specified, the tests search a list of common install locations
- PKCS11_PIN
- PKCS11_SLOT
To not run the HSM scenario tests, the npm script cucumberScenarioNoHSM
should be specified or use the 'testNoHSM' when running executing all tests.