-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path300spam.t
145 lines (136 loc) · 7.05 KB
/
300spam.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/perl -W
use Test::More tests => 6;
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}, 4, 1);
$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;
$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 => 1,
attach_array => [{type => $KNP::KNP_MAIL_PART_EXPLICIT,
encoding => '',
mime_type => '',
name => 'some.file.1',
payload => 'smallish payload'}],
pod_addr => '');
is($r->{ok}, 1, 'packaging with attachment');
$knp->close();
#
# Packaging the GTUBE.
#
$knp = KNP::new($config{kps_host}, $config{kps_port}, 4, 1);
$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;
$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 => 'XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X',
body_html => '',
nb_attach => 0,
pod_addr => '');
is($r->{ok}, 0, 'failed packaging of the GTUBE');
ok(defined($r->{fail_message}) && length($r->{fail_message}) > 0, "failure reason provided");
$knp->close();
#
# Packaging the GTUBE as an attachment.
#
$knp = KNP::new($config{kps_host}, $config{kps_port}, 4, 1);
$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;
$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 => 1,
attach_array => [{type => $KNP::KNP_MAIL_PART_EXPLICIT,
encoding => '',
mime_type => '',
name => 'some.file.1',
payload => 'XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X'}],
pod_addr => '');
is($r->{ok}, 0, 'failed packaging with attached GTUBE');
ok(defined($r->{fail_message}) && length($r->{fail_message}) > 0, "failure reason provided");
$knp->close();
#
# Packaging a binary attachment.
#
$knp = KNP::new($config{kps_host}, $config{kps_port}, 4, 1);
$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;
$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 => 1,
attach_array => [{type => $KNP::KNP_MAIL_PART_EXPLICIT,
encoding => '',
mime_type => '',
name => 'some.file.1',
payload => $knp->get_file_content('/bin/ls')}],
pod_addr => '');
is($r->{ok}, 1, 'packaging with a binary attachment');
$knp->close();