-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path100attch.t
117 lines (103 loc) · 4.11 KB
/
100attch.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/perl -W
use Data::Dumper;
use Test::More tests => 4;
use Teambox::KNP;
require 'config.pl';
my %pkg_cmd = (pkg_type => 1,
lang => 1,
to_field => $config{source_address},
cc_field => '',
nb_recipient => 0,
recipient_array => [],
nb_pwd => 1,
pwd_array => [{pwd => $config{target_password},
otut => ''}],
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 => 0,
pod_addr => '');
#
# One explicit attachment, small size
#
$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);
BAIL_OUT('login failed') unless $r->{ok} == 1;
$pkg_cmd{nb_attach} = 1;
$pkg_cmd{attach_array} = [{type => $KNP::KNP_MAIL_PART_EXPLICIT,
encoding => '',
mime_type => '',
name => '/etc/fstab',
payload => $knp->get_file_content('/etc/fstab')
}];
$r = $knp->KNP_CMD_PACKAGE_MAIL(%pkg_cmd);
is($r->{ok}, 1, 'single attachment, small size');
$knp->close();
#
# Several explicit attachments, small size
#
$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);
BAIL_OUT('login failed') unless $r->{ok} == 1;
$pkg_cmd{nb_attach} = 10;
$pkg_cmd{attach_array} = [];
for ($i = 0; $i < 10; $i++) {
$pkg_cmd{attach_array}[$i] = {type => $KNP::KNP_MAIL_PART_EXPLICIT,
encoding => '',
mime_type => '',
name => '/etc/fstab',
payload => $knp->get_file_content('/etc/fstab')
};
}
$r = $knp->KNP_CMD_PACKAGE_MAIL(%pkg_cmd);
is($r->{ok}, 1, 'several attachment, small size');
$knp->close();
#
# Hundreds explicit attachments, small size
#
$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);
BAIL_OUT('login failed') unless $r->{ok} == 1;
$pkg_cmd{nb_attach} = 100;
$pkg_cmd{attach_array} = [];
for ($i = 0; $i < 100; $i++) {
$pkg_cmd{attach_array}[$i] = {type => $KNP::KNP_MAIL_PART_EXPLICIT,
encoding => '',
mime_type => '',
name => '/etc/fstab',
payload => $knp->get_file_content('/etc/fstab')
};
}
$r = $knp->KNP_CMD_PACKAGE_MAIL(%pkg_cmd);
is($r->{ok}, 1, 'hundreds of attachments, small size');
$knp->close();
#
# Several attachments, medium size
#
$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);
BAIL_OUT('login failed') unless $r->{ok} == 1;
$pkg_cmd{nb_attach} = 10;
$pkg_cmd{attach_array} = [];
for ($i = 0; $i < 10; $i++) {
$pkg_cmd{attach_array}[$i] = {type => $KNP::KNP_MAIL_PART_EXPLICIT,
encoding => '',
mime_type => '',
name => '/etc/fstab',
payload => $knp->get_file_content('/etc/fstab')
};
}
$r = $knp->KNP_CMD_PACKAGE_MAIL(%pkg_cmd);
is($r->{ok}, 1, 'hundreds of attachments, small size');
$knp->close();