3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program. If not, see <https://www.gnu.org/licenses/>.
19
use Test::More tests => 22;
23
use_ok('Dpkg::Control');
24
use_ok('Dpkg::Control::Info');
27
my $srcdir = $ENV{srcdir} || '.';
28
my $datadir = $srcdir . '/t/700_Dpkg_Control';
33
my $dsc = Dpkg::Control->new(type => CTRL_PKG_SRC);
42
my $c = Dpkg::Control::Info->new("$datadir/control-1");
44
my $io = IO::String->new();
46
my $value = ${$io->string_ref()};
47
my $expected = 'Source: mysource
48
My-Field-One: myvalue1
49
My-Field-Two: myvalue2
69
Description: short one
73
is($value, $expected, "Dump of $datadir/control-1");
75
my $src = $c->get_source();
76
is($src, $c->[0], 'array representation of Dpkg::Control::Info 1/2');
77
is($src->{'my-field-one'}, 'myvalue1', 'Access field through badly capitalized field name');
78
is($src->{'long-field'},
84
line 4', 'Get multi-line field');
85
is($src->{'Empty-field'}, '', 'Get empty field');
87
my $pkg = $c->get_pkg_by_idx(1);
88
is($pkg, $c->[1], 'array representation of Dpkg::Control::Info 2/2');
89
is($pkg->{package}, 'mypackage1', 'Name of first package');
91
$pkg = $c->get_pkg_by_name('mypackage3');
92
is($pkg->{package}, 'mypackage3', 'Name of third package');
93
is($pkg->{Depends}, 'hello', 'Name of third package');
95
$pkg = $c->get_pkg_by_idx(2);
96
$io = IO::String->new();
99
is(${$io->string_ref()},
103
', "Dump of second binary package of $datadir/control-1");
105
# Check OpenPGP armored signatures in source control files
109
$dsc = parse_dsc("$datadir/bogus-unsigned.dsc");
110
is($dsc, undef, 'Unsigned .dsc w/ OpenPGP armor');
112
$dsc = parse_dsc("$datadir/bogus-armor-no-sig.dsc");
113
is($dsc, undef, 'Signed .dsc w/ OpenPGP armor missing signature');
115
$dsc = parse_dsc("$datadir/bogus-armor-trail.dsc");
116
is($dsc, undef, 'Signed .dsc w/ bogus OpenPGP armor trailer');
118
$dsc = parse_dsc("$datadir/bogus-armor-inline.dsc");
119
is($dsc, undef, 'Signed .dsc w/ bogus OpenPGP inline armor');
121
$dsc = parse_dsc("$datadir/bogus-armor-double.dsc");
122
ok(defined $dsc, 'Signed .dsc w/ two OpenPGP armor signatures');
123
is($dsc->{Source}, 'pass', 'Signed spaced .dsc package name');
125
$dsc = parse_dsc("$datadir/bogus-armor-spaces.dsc");
126
ok(defined $dsc, 'Signed .dsc w/ spaced OpenPGP armor');
127
is($dsc->{Source}, 'pass', 'Signed spaced .dsc package name');
129
$dsc = parse_dsc("$datadir/bogus-armor-nested.dsc");
130
ok(defined $dsc, 'Signed .dsc w/ nested OpenPGP armor');
131
is($dsc->{Source}, 'pass', 'Signed nested .dsc package name');