30-test_defltfips.t 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #! /usr/bin/env perl
  2. # Copyright 2015-2021 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. use strict;
  9. use warnings;
  10. use OpenSSL::Test qw/:DEFAULT srctop_file srctop_dir bldtop_file bldtop_dir data_dir/;
  11. use OpenSSL::Test::Utils;
  12. use Cwd qw(abs_path);
  13. BEGIN {
  14. setup("test_defltfips");
  15. }
  16. use lib srctop_dir('Configurations');
  17. use lib bldtop_dir('.');
  18. my $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0);
  19. plan tests =>
  20. ($no_fips ? 1 : 5);
  21. unless ($no_fips) {
  22. $ENV{OPENSSL_CONF} = abs_path(srctop_file("test", "fips.cnf"));
  23. ok(run(test(["defltfips_test", "fips"])), "running defltfips_test fips");
  24. #Test an alternative way of configuring fips
  25. $ENV{OPENSSL_CONF} = abs_path(srctop_file("test", "fips-alt.cnf"));
  26. ok(run(test(["defltfips_test", "fips"])), "running defltfips_test fips");
  27. #Configured to run FIPS but the module-mac is bad
  28. $ENV{OPENSSL_CONF} = abs_path(srctop_file("test", "fips.cnf"));
  29. $ENV{OPENSSL_CONF_INCLUDE} = srctop_dir("test", "recipes", "30-test_defltfips");
  30. ok(run(test(["defltfips_test", "badfips"])), "running defltfips_test badfips");
  31. #Test an alternative way of configuring fips (but still with bad module-mac)
  32. $ENV{OPENSSL_CONF} = abs_path(srctop_file("test", "fips-alt.cnf"));
  33. ok(run(test(["defltfips_test", "badfips"])), "running defltfips_test badfips");
  34. }
  35. $ENV{OPENSSL_CONF} = abs_path(srctop_file("test", "default.cnf"));
  36. ok(run(test(["defltfips_test"])), "running defltfips_test");