summaryrefslogtreecommitdiffstats
path: root/RPM4/t/06sign.t
blob: e5b8f83a18944571c74bc3805d8c892d7adb21c8 (plain)
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
#!/usr/bin/perl
# $Id$

use strict;
use Test::More;
use FindBin qw($Bin);
use File::Temp qw(tempdir);
use File::Copy;
use RPM4;

if (-e '/etc/debian_version' || `uname -a` =~ /BSD/i) {
    plan skip_all => "*BSD/Debian/Ubuntu do not have a system wide rpmdb";
} else {
    plan tests => 4;
}

my $passphrase = "RPM4";

my $testdir = tempdir(CLEANUP => 1);

RPM4::add_macro("_dbpath $testdir");

copy("$Bin/test-rpm-1.0-1mdk.noarch.rpm", $testdir);

RPM4::add_macro("_signature gpg");
RPM4::add_macro("_gpg_name RPM4 test key");
RPM4::add_macro("_gpg_path $Bin/gnupg");

#ok(RPM4::rpmresign($passphrase, "$testdir/test-rpm-1.0-1mdk.noarch.rpm") == 0, "can resign a rpm");

ok(my $db = RPM4::newdb(1), "Open a new database");

#ok($db->checkrpm("$testdir/test-rpm-1.0-1mdk.noarch.rpm") != 0, "checking a rpm, key is missing");
ok($db->checkrpm("$testdir/test-rpm-1.0-1mdk.noarch.rpm", [ "NOSIGNATURES" ]) == 0, "checking a rpm, no checking the key");

ok($db->importpubkey("$Bin/gnupg/test-key.gpg") == 0, "Importing a public key");

ok($db->checkrpm("$testdir/test-rpm-1.0-1mdk.noarch.rpm") == 0, "checking a rpm file");

$db = undef;