]> www.wagner.pp.ru Git - openssl-gost/engine.git/blob - test/00-provider.t
tcl_tests: ca.try: Ignore openssl crl exit status for 'corrupted CRL' test
[openssl-gost/engine.git] / test / 00-provider.t
1 #!/usr/bin/perl 
2 use Test2::V0;
3 skip_all('This test is only suitable for the provider')
4     unless $ARGV[0] eq 'provider';
5 plan(1);
6 use Cwd 'abs_path';
7
8 my $provider = 'gostprov';
9 my $provider_info = <<EOINF;
10 Providers:
11   gostprov
12     name: OpenSSL GOST Provider
13     status: active
14 EOINF
15
16 # Normally, this test recipe tests the default GOST provider.  However, it's
17 # also possible to test a different provider as well, possibly a custom build.
18 # In that case, use the environment variable PROVIDER_NAME to name it.  This
19 # overrides a few things:
20 #
21 # - if it exists, we get the text that 'openssl provider -c ${PROVIDER_NAME}'
22 #   should print from the file "${PROVIDER_NAME}.info".
23 # - we create an OpenSSL config file for that provider, and use that instead
24 #   of the default.  We do this by overriding the environment variable
25 #   OPENSSL_CONF
26 #
27 # If PROVIDER_NAME isn't set, we rely on an existing OPENSSL_CONF
28 #
29 if ($ENV{'PROVIDER_NAME'}) {
30     $provider=$ENV{'PROVIDER_NAME'};
31
32     if ( -f $provider . ".info") {
33         diag("Reading $provider.info");
34         open my $F, "<", $provider . ".info";
35         read $F,$provider_info,1024;
36         close $F;
37     }
38
39     open my $F,">","$provider.cnf";
40     print $F <<EOCFG;
41 openssl_conf = openssl_def
42 [openssl_def]
43 providers = providers
44 [providers]
45 ${provider}=gost_conf
46 [gost_conf]
47 default_algorithms = ALL
48 EOCFG
49     close $F;
50     $ENV{'OPENSSL_CONF'}=abs_path("$provider.cnf");
51 }
52
53 # Let's check that we can load the provider without config file
54 # Note that this still requires a properly defined OPENSSL_MODULES
55 {
56     local $ENV{'OPENSSL_CONF'}=abs_path("no_such_file.cfg");
57     my $cmd = "openssl list -provider $provider -providers";
58     unless (is(`$cmd`, $provider_info,
59                "load provider without any config")) {
60         diag("Command was: $cmd");
61     }
62 }