about summary refs log tree commit diff
path: root/pkgs/development/python-modules/pykcs11/tests.nix
blob: 00468733ae3093c7e0f5d6f549cdf81cd60ceb5a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{
  buildPythonPackage,
  asn1crypto,
  pykcs11,
  pytestCheckHook,
  softhsm,
}:

buildPythonPackage {
  pname = "pykcs11-tests";
  inherit (pykcs11) version;
  format = "other";

  src = pykcs11.testout;

  dontBuild = true;
  dontInstall = true;

  nativeCheckInputs = [
    asn1crypto
    pykcs11
    pytestCheckHook
  ];

  preCheck = ''
    export HOME=$(mktemp -d)
    export PYKCS11LIB=${softhsm}/lib/softhsm/libsofthsm2.so
    export SOFTHSM2_CONF=$HOME/softhsm2.conf
    echo "directories.tokendir = $HOME/tokens" > $HOME/softhsm2.conf
    mkdir $HOME/tokens
    ${softhsm}/bin/softhsm2-util --init-token --label "A token" --pin 1234 --so-pin 123456 --slot 0
  '';
}