Latest update.
This commit is contained in:
@@ -304,89 +304,4 @@ sub _pairmap (&@) {
|
||||
map { $block->($_) } _pairs @_;
|
||||
}
|
||||
|
||||
######## UNIT TESTING
|
||||
|
||||
use Test::More;
|
||||
|
||||
sub TEST {
|
||||
# Order is important, so we make it a pairwise list
|
||||
my @predefined =
|
||||
(
|
||||
'pkcs' => '1.2.840.113549',
|
||||
'pkcs-1' => 'pkcs.1',
|
||||
);
|
||||
|
||||
my %good_cases =
|
||||
(
|
||||
' 1.2.840.113549.1.1 ' => [ 42, 134, 72, 134, 247, 13, 1, 1 ],
|
||||
'pkcs.1.1' => [ 42, 134, 72, 134, 247, 13, 1, 1 ],
|
||||
'pkcs-1.1' => [ 42, 134, 72, 134, 247, 13, 1, 1 ],
|
||||
' { iso (1) 2 840 113549 1 1 } ' => [ 42, 134, 72, 134, 247, 13, 1, 1 ],
|
||||
'{ pkcs 1 1 } ' => [ 42, 134, 72, 134, 247, 13, 1, 1 ],
|
||||
'{pkcs-1 1 }' => [ 42, 134, 72, 134, 247, 13, 1, 1 ],
|
||||
);
|
||||
my @bad_cases =
|
||||
(
|
||||
' { 1.2.840.113549.1.1 } ',
|
||||
);
|
||||
|
||||
plan tests =>
|
||||
scalar ( @predefined ) / 2
|
||||
+ scalar ( keys %good_cases )
|
||||
+ scalar @bad_cases;
|
||||
|
||||
note 'Predefine a few names OIDs';
|
||||
foreach my $pair ( _pairs @predefined ) {
|
||||
ok( defined eval { register_oid(@$pair) },
|
||||
"Registering $pair->[0] => $pair->[1]" );
|
||||
}
|
||||
|
||||
note 'Good cases';
|
||||
foreach ( keys %good_cases ) {
|
||||
subtest "Checking '$_'" => sub {
|
||||
my $oid = shift;
|
||||
|
||||
plan tests => 5;
|
||||
|
||||
my (@l, @e);
|
||||
|
||||
ok( scalar (@l = eval { parse_oid $oid }) > 0,
|
||||
"Parsing" );
|
||||
diag $@ unless @l;
|
||||
ok( scalar (@e = eval { encode_oid_nums @l }) > 0,
|
||||
"Encoding via encode_oid_nums()" );
|
||||
diag $@ unless @e;
|
||||
is_deeply(\@e, $good_cases{$oid}, "Checking encoding");
|
||||
note "'$oid' => ", join(', ', @e) if @e;
|
||||
|
||||
ok( scalar (@e = eval { encode_oid $oid }) > 0,
|
||||
"Encoding directly" );
|
||||
diag $@ unless @e;
|
||||
is_deeply(\@e, $good_cases{$oid}, "Checking encoding");
|
||||
note "'$oid' => ", join(', ', @e) if @e;
|
||||
},
|
||||
$_;
|
||||
}
|
||||
|
||||
note 'Bad cases';
|
||||
foreach ( @bad_cases ) {
|
||||
subtest "Checking '$_'" => sub {
|
||||
my $oid = shift;
|
||||
|
||||
plan tests => 2;
|
||||
|
||||
my (@l, @e);
|
||||
|
||||
ok( scalar (@l = eval { parse_oid $oid }) == 0,
|
||||
"Parsing '$oid'" );
|
||||
note $@ unless @l;
|
||||
ok( scalar (@e = eval { encode_oid_nums @l }) == 0,
|
||||
"Encoding '$oid'" );
|
||||
note $@ unless @e;
|
||||
note "'$oid' => ", join(', ', @e) if @e;
|
||||
},
|
||||
$_;
|
||||
}
|
||||
}
|
||||
|
||||
1; # End of OpenSSL::OID
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /usr/bin/env perl
|
||||
# Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
# Copyright 2018-2020 The OpenSSL Project Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
# this file except in compliance with the License. You can obtain a copy
|
||||
@@ -372,6 +372,28 @@ EOF
|
||||
{ regexp => qr/DEFINE_STACK_OF_CONST<<<\((.*)\)>>>/,
|
||||
massager => sub { return ("SKM_DEFINE_STACK_OF($1,const $1,$1)"); },
|
||||
},
|
||||
{ regexp => qr/DEFINE_STACK_OF_STRING<<<\((.*?)\)>>>/,
|
||||
massager => sub {
|
||||
return ("DEFINE_SPECIAL_STACK_OF(OPENSSL_STRING, char)");
|
||||
}
|
||||
},
|
||||
{ regexp => qr/DEFINE_STACK_OF_CSTRING<<<\((.*?)\)>>>/,
|
||||
massager => sub {
|
||||
return ("DEFINE_SPECIAL_STACK_OF_CONST(OPENSSL_CSTRING, char)");
|
||||
}
|
||||
},
|
||||
# DEFINE_OR_DECLARE macro calls must be interpretted as DEFINE macro
|
||||
# calls, because that's what they look like to the external apps.
|
||||
# (if that ever changes, we must change the substitutions to STACK_OF)
|
||||
{ regexp => qr/DEFINE_OR_DECLARE_STACK_OF<<<\((.*?)\)>>>/,
|
||||
massager => sub { return ("DEFINE_STACK_OF($1)"); }
|
||||
},
|
||||
{ regexp => qr/DEFINE_OR_DECLARE_STACK_OF_STRING<<<\(\)>>>/,
|
||||
massager => sub { return ("DEFINE_STACK_OF_STRING()"); },
|
||||
},
|
||||
{ regexp => qr/DEFINE_OR_DECLARE_STACK_OF_CSTRING<<<\(\)>>>/,
|
||||
massager => sub { return ("DEFINE_STACK_OF_CSTRING()"); },
|
||||
},
|
||||
|
||||
#####
|
||||
# ASN1 stuff
|
||||
|
||||
Reference in New Issue
Block a user