chiark / gitweb /
gnupg2 (2.1.17-3) unstable; urgency=medium
[gnupg2.git] / tests / pkits / inittests
1 #!/bin/sh
2 #       Copyright (C) 2004 Free Software Foundation, Inc.  -*- sh -*-
3 #
4 # This file is free software; as a special exception the author gives
5 # unlimited permission to copy and/or distribute it, with or without
6 # modifications, as long as this notice is preserved.
7 #
8 # This file is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
10 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
12 set -e
13
14
15 clean_files='
16 ReadMe.txt pkits.ldif pkits.schema
17 gpgsm.conf gpg-agent.conf trustlist.txt policies.txt pubring.kbx
18 msg msg.sig msg.unsig
19 '
20
21 [ -z "$srcdir" ] && srcdir=.
22 [ -z "$GPGSM" ] && GPGSM=../../sm/gpgsm
23
24 #if [ -f $srcdir/README ] \
25 #   && grep tests/pkits/README README >/dev/null 2>&1; then
26 # :
27 #else
28 #   # During make distclean the Makefile has already been removed,
29 #   # so we need this extra test.
30 #   if ! grep gnupg-test-pkits-directory testdir.stamp >/dev/null 2>&1; then
31 #      echo "inittests: please cd to the tests/pkits directory first" >&2
32 #      exit 1
33 #   fi
34 #fi
35
36 if [ "$1" = "--clean" ]; then
37     if [ -d private-keys-v1.d ]; then
38        rm private-keys-v1.d/* 2>/dev/null || true
39        rmdir private-keys-v1.d
40     fi
41     rm ${clean_files} testdir.stamp 2>/dev/null || true
42     for i in certs certpairs crls pkcs12 smime; do 
43         if [ -d $i ]; then
44             rm $i/* 2>/dev/null || true
45             rmdir $i
46         fi
47     done
48     exit 0
49 fi
50
51 if [ "$GNUPGHOME" != "`/bin/pwd`" ]; then
52     echo "inittests: please set GNUPGHOME to the tests/pkits directory" >&2
53     exit 1
54 fi
55
56 if [ -n "$GPG_AGENT_INFO" ]; then
57     echo "inittests: please unset GPG_AGENT_INFO" >&2
58     exit 1
59 fi
60
61 if test -f PKITS_data.tar.bz2; then
62   if ! bunzip2 -c PKITS_data.tar.bz2 | tar xf - ; then
63     echo "inittests: failed to untar the test data" >&2
64     exit 1
65   fi    
66 fi
67
68 # A stamp file used with --clean
69 echo gnupg-test-pkits-directory > testdir.stamp
70
71
72 # Create the configuration scripts
73 cat > gpgsm.conf <<EOF
74 no-secmem-warning
75 no-greeting
76 batch
77 disable-crl-checks
78 disable-dirmngr
79 agent-program ../../agent/gpg-agent
80 no-common-certs-import
81 EOF
82
83 # The set of NIST test policies which should be used if anyPolicy is
84 # not supported.
85 cat > policies.txt <<EOF
86 2.16.840.1.101.3.2.1.48.1
87 2.16.840.1.101.3.2.1.48.2
88 2.16.840.1.101.3.2.1.48.3
89 2.16.840.1.101.3.2.1.48.4
90 2.16.840.1.101.3.2.1.48.5
91 2.16.840.1.101.3.2.1.48.6
92 EOF
93
94 # Fixme: we need to write a dummy pinentry program
95 cat > gpg-agent.conf <<EOF
96 no-grab
97 EOF
98
99 # Mark the root CA trusted
100 cat > trustlist.txt <<EOF
101 # /CN=Trust Anchor/O=Test Certificates/C=US
102 66:8A:47:56:A2:DC:88:FF:DA:B8:95:E1:3C:63:37:55:5F:0A:F7:BF S
103 EOF
104
105 # Define the standard policies as NIST test-policy-1
106 #cat >policies.txt <<EOF
107 #2.16.840.1.101.3.2.1.48.1
108 #EOF