File: 005_split_pem_chain.t

package info (click to toggle)
libcrypt-format-perl 0.10-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 124 kB
  • sloc: perl: 42; makefile: 2
file content (57 lines) | stat: -rw-r--r-- 1,240 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use Test::More;
use Test::FailWarnings;

use Crypt::Format;

plan tests => 5;

my $pem1 = "-----BEGIN SOMETHING-----\n123123123\n-----END SOMETHING-----";
my $pem2 = "-----BEGIN SOMETHING-----\n234234234\n-----END SOMETHING-----";

my @split = Crypt::Format::split_pem_chain("$pem1\x0a$pem2");

is_deeply(
    \@split,
    [ $pem1, $pem2 ],
    'split w/ LF as separator',
);

#----------------------------------------------------------------------

@split = Crypt::Format::split_pem_chain("$pem1\x0d$pem2");

is_deeply(
    \@split,
    [ $pem1, $pem2 ],
    'split w/ CR as separator',
);

#----------------------------------------------------------------------

@split = Crypt::Format::split_pem_chain("$pem1\x0a\x0d$pem2");

is_deeply(
    \@split,
    [ $pem1, $pem2 ],
    'split w/ CRLF as separator',
);

#----------------------------------------------------------------------

@split = Crypt::Format::split_pem_chain($pem1);

is_deeply(
    \@split,
    [ $pem1 ],
    'split w/ single PEM',
);

#----------------------------------------------------------------------

@split = Crypt::Format::split_pem_chain("$pem1\x0a\x0d$pem2\x0a$pem1");

is_deeply(
    \@split,
    [ $pem1, $pem2, $pem1 ],
    'split w/ mixed separators',
);