]> git.ipfire.org Git - thirdparty/openssl.git/blame - test/recipes/30-test_evp_fetch_prov.t
Update copyright year
[thirdparty/openssl.git] / test / recipes / 30-test_evp_fetch_prov.t
CommitLineData
7bb82f92 1#! /usr/bin/env perl
8020d79b 2# Copyright 2015-2021 The OpenSSL Project Authors. All Rights Reserved.
7bb82f92
SL
3#
4# Licensed under the Apache License 2.0 (the "License"). You may not use
5# this file except in compliance with the License. You can obtain a copy
6# in the file LICENSE in the source distribution or at
7# https://www.openssl.org/source/license.html
8
9use strict;
10use warnings;
11
12use OpenSSL::Test qw(:DEFAULT bldtop_dir srctop_file srctop_dir bldtop_file);
13use OpenSSL::Test::Utils;
14
15BEGIN {
16setup("test_evp_fetch_prov");
17}
18
19use lib srctop_dir('Configurations');
20use lib bldtop_dir('.');
7bb82f92 21
e0d952fc 22my $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0);
7bb82f92 23
e0d952fc 24my @types = ( "digest", "cipher" );
7bb82f92 25
e0d952fc
RL
26my @testdata = (
27 { config => srctop_file("test", "default.cnf"),
28 providers => [ 'default' ],
29 tests => [ { providers => [] },
30 { },
745fc918
MC
31 { args => [ '-property', 'provider=default' ],
32 message => 'using property "provider=default"' },
33 { args => [ '-property', 'provider!=fips' ],
34 message => 'using property "provider!=fips"' },
35 { args => [ '-property', 'provider!=default', '-fetchfail' ],
e0d952fc 36 message =>
745fc918
MC
37 'using property "provider!=default" is expected to fail' },
38 { args => [ '-property', 'provider=fips', '-fetchfail' ],
e0d952fc 39 message =>
745fc918 40 'using property "provider=fips" is expected to fail' } ] }
e0d952fc
RL
41);
42
43unless ($no_fips) {
e0d952fc
RL
44 push @testdata, (
45 { config => srctop_file("test", "fips.cnf"),
46 providers => [ 'fips' ],
47 tests => [
48 { args => [ '-property', '' ] },
745fc918
MC
49 { args => [ '-property', 'provider=fips' ],
50 message => 'using property "provider=fips"' },
51 { args => [ '-property', 'provider!=default' ],
52 message => 'using property "provider!=default"' },
53 { args => [ '-property', 'provider=default', '-fetchfail' ],
e0d952fc 54 message =>
745fc918
MC
55 'using property "provider=default" is expected to fail' },
56 { args => [ '-property', 'provider!=fips', '-fetchfail' ],
e0d952fc 57 message =>
745fc918
MC
58 'using property "provider!=fips" is expected to fail' },
59 { args => [ '-property', 'fips=yes' ],
60 message => 'using property "fips=yes"' },
61 { args => [ '-property', 'fips!=no' ],
62 message => 'using property "fips!=no"' },
63 { args => [ '-property', '-fips' ],
64 message => 'using property "-fips"' },
65 { args => [ '-property', 'fips=no', '-fetchfail' ],
66 message => 'using property "fips=no is expected to fail"' },
67 { args => [ '-property', 'fips!=yes', '-fetchfail' ],
68 message => 'using property "fips!=yes is expected to fail"' } ] },
e0d952fc
RL
69 { config => srctop_file("test", "default-and-fips.cnf"),
70 providers => [ 'default', 'fips' ],
71 tests => [
72 { args => [ '-property', '' ] },
745fc918
MC
73 { args => [ '-property', 'provider!=default' ],
74 message => 'using property "provider!=default"' },
75 { args => [ '-property', 'provider=default' ],
76 message => 'using property "provider=default"' },
77 { args => [ '-property', 'provider!=fips' ],
78 message => 'using property "provider!=fips"' },
79 { args => [ '-property', 'provider=fips' ],
80 message => 'using property "provider=fips"' },
81 { args => [ '-property', 'fips=yes' ],
82 message => 'using property "fips=yes"' },
83 { args => [ '-property', 'fips!=no' ],
84 message => 'using property "fips!=no"' },
85 { args => [ '-property', '-fips' ],
86 message => 'using property "-fips"' },
87 { args => [ '-property', 'fips=no' ],
88 message => 'using property "fips=no"' },
89 { args => [ '-property', 'fips!=yes' ],
90 message => 'using property "fips!=yes"' } ] },
e0d952fc
RL
91 );
92}
93
94my $testcount = 0;
95foreach (@testdata) {
96 $testcount += scalar @{$_->{tests}};
97}
98
e25b4db7 99plan tests => 1 + $testcount * scalar(@types);
7bb82f92 100
7bb82f92 101ok(run(test(["evp_fetch_prov_test", "-defaultctx"])),
e0d952fc
RL
102 "running evp_fetch_prov_test using the default libctx");
103
e0d952fc
RL
104foreach my $alg (@types) {
105 foreach my $testcase (@testdata) {
22e27978 106 $ENV{OPENSSL_CONF} = "";
e0d952fc
RL
107 foreach my $test (@{$testcase->{tests}}) {
108 my @testproviders =
109 @{ $test->{providers} // $testcase->{providers} };
110 my $testprovstr = @testproviders
111 ? ' and loaded providers ' . join(' & ',
112 map { "'$_'" } @testproviders)
113 : '';
114 my @testargs = @{ $test->{args} // [] };
115 my $testmsg =
116 defined $test->{message} ? ' '.$test->{message} : '';
117
118 my $message =
119 "running evp_fetch_prov_test with $alg$testprovstr$testmsg";
120
121 ok(run(test(["evp_fetch_prov_test", "-type", "$alg",
22e27978 122 "-config", "$testcase->{config}",
e0d952fc
RL
123 @testargs, @testproviders])),
124 $message);
125 }
126 }
127}