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