xref: /freebsd/crypto/openssl/test/recipes/80-test_policy_tree.t (revision e0c4386e7e71d93b0edc0c8fa156263fc4a8b0b6)
1#! /usr/bin/env perl
2# Copyright 2023 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
10use strict;
11use warnings;
12
13use POSIX;
14use OpenSSL::Test qw/:DEFAULT srctop_file with data_file/;
15
16use OpenSSL::Test::Utils;
17use OpenSSL::Glob;
18
19setup("test_policy_tree");
20
21plan skip_all => "No EC support" if disabled("ec");
22
23plan tests => 2;
24
25# The small pathological tree is expected to work
26my $small_chain = srctop_file("test", "recipes", "80-test_policy_tree_data",
27                              "small_policy_tree.pem");
28my $small_leaf = srctop_file("test", "recipes", "80-test_policy_tree_data",
29                             "small_leaf.pem");
30
31ok(run(app(["openssl", "verify", "-CAfile", $small_chain,
32            "-policy_check", $small_leaf])),
33   "test small policy tree");
34
35# The large pathological tree is expected to fail
36my $large_chain = srctop_file("test", "recipes", "80-test_policy_tree_data",
37                              "large_policy_tree.pem");
38my $large_leaf = srctop_file("test", "recipes", "80-test_policy_tree_data",
39                             "large_leaf.pem");
40
41ok(!run(app(["openssl", "verify", "-CAfile", $large_chain,
42             "-policy_check", $large_leaf])),
43   "test large policy tree");
44