]> git.ipfire.org Git - thirdparty/openssl.git/blob - test/recipes/20-test_provider.t
Update openssl list to support new provider objects.
[thirdparty/openssl.git] / test / recipes / 20-test_provider.t
1 #! /usr/bin/env perl
2 # Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
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
9
10 use strict;
11 use warnings;
12
13 use OpenSSL::Test;
14
15 setup("test_provider");
16
17 plan tests => 9;
18
19 SKIP: {
20 skip "No default provider?", 6
21 unless ok(run(app([qw(openssl provider default)])),
22 "try running 'openssl provider default'");
23
24 my $prev = 2; # The amount of lines from -v
25 my @checks = qw( -v -vv -vvv );
26 my %op = ( -v => '==',
27 -vv => '>',
28 -vvv => '>' );
29 my $i = 0;
30
31 foreach (@checks) {
32 my @cmd = ('openssl', 'provider', $_, 'default');
33 my @lines = ( map { (my $x = $_) =~ s|\R$||; $x }
34 run(app([@cmd]), capture => 1) );
35
36 my $curr = scalar @lines;
37 my $cmp = "$curr $op{$_} $prev";
38
39 ok(eval $cmp,
40 "'openssl provider $_ default' line count $op{$_} $prev");
41 ok($lines[0] eq '[ default ]',
42 "'openssl provider -v default' first line is '[ default ]'");
43
44 $prev = $curr;
45 }
46 }
47
48 SKIP: {
49 skip "No null provider?", 1
50 unless ok(run(app([qw(openssl provider null)])),
51 "try running 'openssl provider null'");
52
53 my @cmd = ('openssl', 'provider', '-vvv', 'null');
54 my @lines = ( map { (my $x = $_) =~ s|\R$||; $x }
55 run(app([@cmd]), capture => 1) );
56
57 my $curr = scalar @lines;
58 my $cmp = "$curr == 1";
59 ok(eval $cmp,
60 "'openssl provider $_ default' line count == 1");
61 }
62