File: crypt_cbc.t

package info (click to toggle)
libmessage-passing-perl 0.117-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 544 kB
  • sloc: perl: 2,742; makefile: 2; sh: 1
file content (46 lines) | stat: -rw-r--r-- 1,290 bytes parent folder | download | duplicates (4)
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
use strict;
use warnings;
use Test::More;
use Try::Tiny;

plan skip_all => "No Crypt::CBC or no Crypt::Blowfish"
    unless try {
        require Message::Passing::Filter::Decoder::Crypt::CBC;
        require Crypt::Blowfish;
};

use_ok 'Message::Passing::Filter::Decoder::Crypt::CBC';
use_ok 'Message::Passing::Filter::Encoder::Crypt::CBC';
use_ok 'Message::Passing::Output::Test';
use_ok 'Message::Passing::Input::Null';
use_ok 'Message::Passing::Output::Null';

my $cbct = Message::Passing::Output::Test->new;
my $cbc = Message::Passing::Input::Null->new(
    output_to => Message::Passing::Filter::Encoder::Crypt::CBC->new(
        encryption_cipher => 'Blowfish',
        encryption_key => 'test',
        output_to => Message::Passing::Filter::Decoder::Crypt::CBC->new(
            output_to => $cbct,
            encryption_cipher => 'Blowfish',
            encryption_key => 'test',
        ),
    ),
);

$cbc->output_to->consume('test');
is $cbct->message_count, 1;
is_deeply [$cbct->messages], ['test'];

# Simulate dropping a message!
{
    local $cbc->output_to->{output_to} = Message::Passing::Output::Null->new;
    $cbc->output_to->consume('fooo');
}

$cbc->output_to->consume('bar');
is $cbct->message_count, 2;
is_deeply [$cbct->messages], ['test', 'bar'];

done_testing;