]> git.ipfire.org Git - thirdparty/openssl.git/blame - test/recipes/25-test_req.t
Fix return-value checks in OCSP_resp_get1_id()
[thirdparty/openssl.git] / test / recipes / 25-test_req.t
CommitLineData
596d6b7e
RS
1#! /usr/bin/env perl
2# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
3#
4# Licensed under the OpenSSL license (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
4650de3e
RL
9
10use strict;
11use warnings;
12
e2ec7332 13use OpenSSL::Test::Utils;
42e0ccdf 14use OpenSSL::Test qw/:DEFAULT srctop_file/;
4650de3e
RL
15
16setup("test_req");
17
e2ec7332 18plan tests => 4;
4650de3e 19
42e0ccdf 20require_ok(srctop_file('test','recipes','tconversion.pl'));
4650de3e 21
e2ec7332
RL
22open RND, ">>", ".rnd";
23print RND "string to make the random number generator think it has entropy";
24close RND;
25subtest "generating certificate requests" => sub {
26 my @req_new;
27 if (disabled("rsa")) {
28 @req_new = ("-newkey", "dsa:".srctop_file("apps", "dsa512.pem"));
29 } else {
30 @req_new = ("-new");
31 note("There should be a 2 sequences of .'s and some +'s.");
32 note("There should not be more that at most 80 per line");
33 }
34
35 plan tests => 2;
36
37 ok(run(app(["openssl", "req", "-config", srctop_file("test", "test.cnf"),
38 @req_new, "-out", "testreq.pem"])),
39 "Generating request");
40
41 ok(run(app(["openssl", "req", "-config", srctop_file("test", "test.cnf"),
42 "-verify", "-in", "testreq.pem", "-noout"])),
43 "Verifying signature on request");
44};
45
42e0ccdf 46my @openssl_args = ("req", "-config", srctop_file("apps", "openssl.cnf"));
4650de3e
RL
47
48run_conversion('req conversions',
49 "testreq.pem");
50run_conversion('req conversions -- testreq2',
e2ec7332
RL
51 srctop_file("test", "testreq2.pem"));
52
53unlink "testkey.pem", "testreq.pem";
4650de3e
RL
54
55sub run_conversion {
56 my $title = shift;
57 my $reqfile = shift;
58
59 subtest $title => sub {
60 run(app(["openssl", @openssl_args,
61 "-in", $reqfile, "-inform", "p",
62 "-noout", "-text"],
63 stderr => "req-check.err", stdout => undef));
64 open DATA, "req-check.err";
65 SKIP: {
66 plan skip_all => "skipping req conversion test for $reqfile"
85833408 67 if grep /Unknown Public Key/, map { s/\R//; } <DATA>;
4650de3e 68
e2ec7332 69 tconversion("req", $reqfile, @openssl_args);
4650de3e
RL
70 }
71 close DATA;
72 unlink "req-check.err";
73
74 done_testing();
75 };
76}