-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path014pkg5.t
98 lines (92 loc) · 4.91 KB
/
014pkg5.t
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/perl -W
use Test::More tests => 10;
use Teambox::KNP;
require 'config.pl';
#
# Fetch the timestamping key data for the source address.
#
$knp = KNP::new($config{iks_host}, $config{iks_port});
$r = $knp->KNP_CMD_GET_SIGN_KEY(key_id => $config{source_mid});
$tm_key_data = $r->{tm_key_data};
$knp->close();
#
# Packaging a single attachment with signature.
#
$knp = KNP::new($config{kps_host}, $config{kps_port});
$r = $knp->KNP_CMD_LOGIN_USER(username => $config{source_username},
password => $config{source_password},
is_password => 1);
ok($r->{ok} == 1, 'successful login');
$r = $knp->KNP_CMD_PACKAGE_MAIL(pkg_type => 0,
lang => 1,
to_field => $config{source_address},
cc_field => '',
nb_recipient => 0,
tm_key_data => $tm_key_data,
recipient_array => [],
nb_pwd => 0,
pwd_array => [],
from_name => $config{source_name},
from_addr => $config{source_address},
subject => 'this is a fake message',
body_type => $KNP::KNP_PKG_BODY_TEXT,
body_text => 'this is a fake body',
body_html => '',
nb_attach => 3,
attach_array => [{type => $KNP::KNP_MAIL_PART_EXPLICIT,
encoding => '',
mime_type => '',
name => 'some.file.1',
payload => 'smallish payload'},
{type => $KNP::KNP_MAIL_PART_EXPLICIT,
encoding => '',
mime_type => '',
name => 'some.file.2',
payload => 'smallish payload for attachment in the middle.'},
{type => $KNP::KNP_MAIL_PART_EXPLICIT,
encoding => '',
mime_type => '',
name => 'some.file.3',
payload => 'smallish payload'}],
pod_addr => '');
is($r->{ok}, 1, 'succesful packaging');
ok(length($r->{pkg_output}) > 0, 'presence of result text');
ok(length($r->{ksn}) > 0, 'presence of KSN');
ok(length($r->{sym_key}) == 0, 'absence of symmetric key');
$knp->close();
#
# Packaging a big attachment with signature.
#
$knp = KNP::new($config{kps_host}, $config{kps_port});
$r = $knp->KNP_CMD_LOGIN_USER(username => $config{source_username},
password => $config{source_password},
is_password => 1);
is($r->{ok}, 1, 'successful login');
$r = $knp->KNP_CMD_PACKAGE_MAIL(pkg_type => 0,
lang => 1,
to_field => $config{source_address},
cc_field => '',
tm_key_data => $tm_key_data,
nb_recipient => 0,
recipient_array => [],
nb_pwd => 0,
pwd_array => [],
from_name => $config{source_name},
from_addr => $config{source_address},
subject => 'this is a fake message',
body_type => $KNP::KNP_PKG_BODY_TEXT,
body_text => 'this is a fake body',
body_html => '',
nb_attach => 1,
attach_array => [{type => $KNP::KNP_MAIL_PART_EXPLICIT,
encoding => '',
mime_type => '',
name => '/usr/bin/emacs',
payload => $knp->get_file_content('/usr/bin/emacs')
}],
pod_addr => '');
is($r->{ok}, 1, 'succesful packaging');
ok(length($r->{pkg_output}) > 0, 'presence of result text (' . length($r->{pkg_output}) . ')');
ok(length($r->{ksn}) > 0, 'presence of KSN (' . length($r->{ksn}) . ')');
ok(length($r->{sym_key}) == 0, 'absence of symmetric key');
$knp->close();