diff options
Diffstat (limited to 't')
-rwxr-xr-x | t/01-unit.t | 12 | ||||
-rwxr-xr-x | t/02.2-unit-repo.t | 2 | ||||
-rwxr-xr-x | t/03-travis.t | 45 | ||||
-rwxr-xr-x | t/05-upgrade.t | 11 | ||||
-rwxr-xr-x | t/11-git.t | 3 | ||||
-rwxr-xr-x | t/15-usage.t | 3 | ||||
-rwxr-xr-x | t/17-find.t | 3 | ||||
-rwxr-xr-x | t/18-snap.t | 4 | ||||
-rwxr-xr-x | t/22-race.t | 12 | ||||
-rwxr-xr-x | t/27-race-sbofind.t | 3 | ||||
-rwxr-xr-x | t/Test/Execute.pm | 16 | ||||
-rw-r--r-- | t/Test/Sbotools.pm | 3 | ||||
-rw-r--r-- | t/sbotools.conf | 1 |
13 files changed, 90 insertions, 28 deletions
diff --git a/t/01-unit.t b/t/01-unit.t index d94fd9b..73f905c 100755 --- a/t/01-unit.t +++ b/t/01-unit.t @@ -11,7 +11,7 @@ use Capture::Tiny qw/ capture_merged /; use File::Temp 'tempdir'; use Cwd; -plan tests => 61; +plan tests => 62; # 1-2: test script_error(); { @@ -149,7 +149,7 @@ SKIP: { local $config{SLACKWARE_VERSION} = '14.1'; my $res; - my $out = capture_merged { $res = SBO::Lib::rsync_sbo_tree('/foo-bar'); }; + my $out = capture_merged { $res = SBO::Lib::rsync_sbo_tree('/foo-bar', ''); }; ok (!$res, q"rsync_sbo_tree('/foo-bar') returned false"); like ($out, qr!rsync: (.*)change_dir "/foo-bar" failed!, q"rsync_sbo_tree('/foo-bar') gave correct output"); @@ -161,7 +161,7 @@ SKIP: { system(qw! mkdir -p /usr/sbo/repo/.git !); my $res; - capture_merged { $res = SBO::Lib::git_sbo_tree(''); }; + capture_merged { $res = SBO::Lib::git_sbo_tree('', ''); }; is ($res, 0, q!git_sbo_tree('') returned 0!); system(qw! rm -r /usr/sbo/repo !) if -d '/usr/sbo/repo'; @@ -171,10 +171,10 @@ SKIP: { close $fh; undef $res; - capture_merged { $res = SBO::Lib::git_sbo_tree(''); }; + capture_merged { $res = SBO::Lib::git_sbo_tree('', ''); }; is ($res, 0, q!git_sbo_tree('') with .git/config returned 0 !); undef $res; - capture_merged { $res = SBO::Lib::git_sbo_tree('foo'); }; + capture_merged { $res = SBO::Lib::git_sbo_tree('foo', ''); }; is ($res, 0, q!git_sbo_tree('foo') returned 0!); system(qw! rm -r /usr/sbo/repo !) if -d '/usr/sbo/repo'; @@ -203,7 +203,7 @@ SKIP: { my $cwd = getcwd(); undef $res; - my $out = capture_merged { $res = SBO::Lib::git_sbo_tree(''); }; + my $out = capture_merged { $res = SBO::Lib::git_sbo_tree('', ''); }; is ($out, '', 'git_sbo_tree() no output'); is ($res, 0, 'git_sbo_tree() returned 0'); diff --git a/t/02.2-unit-repo.t b/t/02.2-unit-repo.t index e06fc82..a47dc7d 100755 --- a/t/02.2-unit-repo.t +++ b/t/02.2-unit-repo.t @@ -27,7 +27,7 @@ note "rsync $url:\n" . capture_merged { no warnings 'redefine'; local *SBO::Lib::Repo::get_slack_version = sub { '14.1' }; - $rsync_res = exit_code { rsync_sbo_tree($url); }; + $rsync_res = exit_code { rsync_sbo_tree($url, 'FALSE'); }; }; if (defined $rsync_res) { diff --git a/t/03-travis.t b/t/03-travis.t index 7b6c97f..cfe517e 100755 --- a/t/03-travis.t +++ b/t/03-travis.t @@ -11,7 +11,7 @@ use lib "$RealBin/../SBO-Lib/lib"; use Test::Sbotools qw/ sboconfig sbosnap sbofind sboinstall sboremove sbocheck sboupgrade /; if (defined $ENV{TRAVIS} and $ENV{TRAVIS} eq 'true') { - plan tests => 26; + plan tests => 41; } else { plan skip_all => 'Only run these tests under Travis CI (TRAVIS=true)'; } @@ -20,8 +20,11 @@ $ENV{TEST_ONLINE} //= 0; # Since this is only run under Travis CI, we can blow away the repo without consequence system(qw! rm -rf /usr/sbo !); +# Disable GPG verification +sboconfig qw/ --gpg-key FALSE /; + # 1-3: Test SLACKWARE_VERSION -sboconfig qw/ -V 14.1 /, { expected => "Setting SLACKWARE_VERSION to 14.1...\n" }; +sboconfig qw/ -V 15.0 /, { expected => "Setting SLACKWARE_VERSION to 15.0...\n" }; SKIP: { skip 'Not doing online tests without TEST_ONLINE=1', 2 if $ENV{TEST_ONLINE} ne '1'; @@ -118,6 +121,44 @@ sboupgrade qw/ -f -z nonexistentslackbuild4 /, { expected => qr/nonexistentslackbuild5 added to upgrade queue.*nonexistentslackbuild4 added to upgrade queue.*Upgrade queue: nonexistentslackbuild5 nonexistentslackbuild4\n/s }; +# 27-34: Test GPG verification +SKIP: { + skip 'Not doing online tests without TEST_ONLINE=1', 4 if $ENV{TEST_ONLINE} ne '1'; + + # Since this is only run under Travis CI, we can blow away the repo without consequence + system(qw! rm -rf /usr/sbo !); + system(qw! gpg --batch --yes --delete-key D3076BC3E783EE747F09B8B70368EF579C7BA3B6 2>&1 >/dev/null !); + + sboconfig qw/ --gpg-key D3076BC3E783EE747F09B8B70368EF579C7BA3B6 /; + sbosnap(("import-key", "https://slackbuilds.org/GPG-KEY"), { expected => qr!.*key imported.*! }); + + sboconfig qw! -r https://git.slackbuilds.org/slackbuilds !, { expected => "Setting REPO to https://git.slackbuilds.org/slackbuilds...\n", name => 'Official Git' }; + + sbosnap 'fetch', { expected => qr!Pulling SlackBuilds tree.*Cloning into '/usr/sbo/repo'.*Verifying.*!s }; + ok (-e "/usr/sbo/repo/SLACKBUILDS.TXT", "SLACKBUILDS.TXT exists (REPO)"); + ok (! -e "/usr/sbo/repo/SLACKBUILDS.TXT.gz", "SLACKBUILDS.TXT.gz doesn't exist (REPO)"); + sbofind 'sbotools', { expected => qr"SBo: sbotools .*\nPath: /usr/sbo/repo/system/sbotools\n\n" }; +} + +# 35-41 Test GPG verification +SKIP: { + skip 'Not doing online tests without TEST_ONLINE=1', 4 if $ENV{TEST_ONLINE} ne '1'; + + # Since this is only run under Travis CI, we can blow away the repo without consequence + system(qw! rm -rf /usr/sbo !); + system(qw! gpg --batch --yes --delete-key D3076BC3E783EE747F09B8B70368EF579C7BA3B6 2>&1 >/dev/null !); + + sboconfig qw/ --gpg-key D3076BC3E783EE747F09B8B70368EF579C7BA3B6 /; + sbosnap(("import-key", "https://slackbuilds.org/GPG-KEY"), { expected => qr!.*key imported.*! }); + + sboconfig qw! -r rsync://slackbuilds.org/slackbuilds/15.0/ !, { expected => "Setting REPO to rsync://slackbuilds.org/slackbuilds/15.0/...\n", name => 'Official Rsync' }; + + sbosnap 'fetch', { expected => qr!Pulling SlackBuilds tree.*Verifying CHECKSUMS.md5.*Verifying file integrity using CHECKSUMS.md5.*!s }; + ok (-e "/usr/sbo/repo/SLACKBUILDS.TXT", "SLACKBUILDS.TXT exists (REPO)"); + ok (-e "/usr/sbo/repo/SLACKBUILDS.TXT.gz", "SLACKBUILDS.TXT.gz exists (REPO)"); + sbofind 'sbotools', { expected => qr"SBo: sbotools .*\nPath: /usr/sbo/repo/system/sbotools\n\n" }; +} + # Cleanup capture_merged { system(qw!/sbin/removepkg nonexistentslackbuild!); diff --git a/t/05-upgrade.t b/t/05-upgrade.t index b976d8c..b34bcde 100755 --- a/t/05-upgrade.t +++ b/t/05-upgrade.t @@ -7,7 +7,7 @@ use Test::More; use Capture::Tiny qw/ capture_merged /; use FindBin '$RealBin'; use lib $RealBin; -use Test::Sbotools qw/ make_slackbuilds_txt set_lo sboconfig sboinstall sboupgrade restore_perf_dummy set_repo sbosnap /; +use Test::Sbotools qw/ make_slackbuilds_txt set_gpg_verify set_lo sboconfig sboinstall sboupgrade restore_perf_dummy set_repo sbosnap /; use File::Temp 'tempdir'; if ($ENV{TEST_INSTALL}) { @@ -70,6 +70,7 @@ sub cleanup { cleanup(); make_slackbuilds_txt(); +set_gpg_verify('FALSE'); set_lo("$RealBin/LO"); restore_perf_dummy(); @@ -119,7 +120,13 @@ sboupgrade qw/ -f nonexistentslackbuild4 /, { input => "y\ny\ny", expected => qr # 13-16: sbosnap + sboupgrade --all my $temp = tempdir(CLEANUP => 1); set_repo("file://$temp"); -capture_merged { system("cd $temp; git init;"); }; +capture_merged { system(<<"END"); }; +cd "$temp"; +git init; +echo hello > README.txt; +git add README.txt; +git commit -am init; +END sbosnap 'fetch', { expected => qr/Pulling SlackBuilds tree[.][.][.]/ }; install( 'LO2', 'nonexistentslackbuild' ); my @sbos = glob("/var/log/packages/*_SBo"); @@ -7,7 +7,7 @@ use Test::More; use Capture::Tiny qw/ capture_merged /; use FindBin '$RealBin'; use lib $RealBin; -use Test::Sbotools qw/ set_repo sbosnap /; +use Test::Sbotools qw/ set_gpg_verify set_repo sbosnap /; if ($ENV{TEST_INSTALL}) { plan tests => 5; @@ -65,6 +65,7 @@ git config --system --add safe.directory /tmp/gitrepo/.git END } +set_gpg_verify('FALSE'); set_repo("/tmp/gitrepo/"); # 1: sbosnap get initial repo diff --git a/t/15-usage.t b/t/15-usage.t index f14ef84..c528444 100755 --- a/t/15-usage.t +++ b/t/15-usage.t @@ -64,6 +64,8 @@ Config options (defaults shown): DISTCLEAN: if TRUE, DO clean distfiles by default after building. -j|--jobs FALSE: JOBS: numeric -j setting to feed to make for multicore systems. + -g|--gpg-key D3076BC3E783EE747F09B8B70368EF579C7BA3B6: + GPG_KEY GPG key ID for verification. -p|--pkg-dir FALSE: PKG_DIR: set a directory to store packages in. -s|--sbo-home /usr/sbo: @@ -172,6 +174,7 @@ Options: Commands: fetch: initialize a local copy of the slackbuilds.org tree. + import-key [path or url]: import GPG for verifying the slackbuilds.org tree. Defaults to the key shipped with sbotools2. update: update an existing local copy of the slackbuilds.org tree. (generally, you may prefer "sbocheck" over "sbosnap update") diff --git a/t/17-find.t b/t/17-find.t index c911d4c..149616c 100755 --- a/t/17-find.t +++ b/t/17-find.t @@ -7,12 +7,13 @@ use Test::More; use Capture::Tiny qw/ capture_merged /; use FindBin '$RealBin'; use lib $RealBin; -use Test::Sbotools qw/ make_slackbuilds_txt set_lo sbofind replace_tags_txt set_repo sbosnap /; +use Test::Sbotools qw/ make_slackbuilds_txt set_gpg_verify set_lo sbofind replace_tags_txt set_repo sbosnap /; use File::Temp 'tempdir'; plan tests => 10; make_slackbuilds_txt(); +set_gpg_verify('FALSE'); set_lo("$RealBin/LO"); # 1: basic sbofind testing diff --git a/t/18-snap.t b/t/18-snap.t index 0b2fdb1..2e028a1 100755 --- a/t/18-snap.t +++ b/t/18-snap.t @@ -7,7 +7,7 @@ use Test::More; use Capture::Tiny qw/ capture_merged /; use FindBin '$RealBin'; use lib $RealBin; -use Test::Sbotools qw/ sbosnap set_repo set_sbo_home /; +use Test::Sbotools qw/ sbosnap set_gpg_verify set_repo set_sbo_home /; use File::Temp 'tempdir'; plan tests => 4; @@ -23,6 +23,7 @@ Options: Commands: fetch: initialize a local copy of the slackbuilds.org tree. + import-key [path or url]: import GPG for verifying the slackbuilds.org tree. Defaults to the key shipped with sbotools2. update: update an existing local copy of the slackbuilds.org tree. (generally, you may prefer "sbocheck" over "sbosnap update") @@ -36,6 +37,7 @@ sbosnap 'invalid', { exit => 1, expected => $usage }; # 3: sbosnap update when /usr/sbo/repo is empty my $tmp = tempdir(CLEANUP => 1); +set_gpg_verify('FALSE'); set_repo("file://$tmp"); capture_merged { system <<"END"; }; cd $tmp diff --git a/t/22-race.t b/t/22-race.t index 8323a75..7ff39ca 100755 --- a/t/22-race.t +++ b/t/22-race.t @@ -58,13 +58,14 @@ SKIP: { my $tempdir = tempdir(CLEANUP => 1); my $repo = '/usr/sbo/repo'; + system('mkdir', '-p', $repo); system('mv', $repo, "$repo.bak"); capture_merged { system <<"GIT"; }; cd $tempdir git init - mkdir -p test/nonexistentslackbuild - cp "$RealBin/nonexistentslackbuild/*" test/nonexistentslackbuild + mkdir -p test + cp -R "$RealBin/LO/nonexistentslackbuild" test git add test git commit -m 'added test/nonexistentslackbuild' @@ -76,7 +77,8 @@ GIT *_race::cond = sub { system('rm', '-rf', $repo) if $_[0] eq '$repo_path can be deleted after -d check' }; my $res; - my $out = capture_merged { $res = SBO::Lib::git_sbo_tree("file://$tempdir"); }; + my $out = capture_merged { $res = SBO::Lib::git_sbo_tree("file://$tempdir", ''); }; + note($out); is ($out, '', 'git_sbo_tree() no output'); is ($res, 0, 'git_sbo_tree() returned 0'); @@ -91,10 +93,10 @@ GIT }; undef $res; - $out = capture_merged { $res = SBO::Lib::git_sbo_tree("file://$tempdir"); }; + $out = capture_merged { $res = SBO::Lib::git_sbo_tree("file://$tempdir", ''); }; - is ($res, 0, 'git_sbo_tree() returned 0'); is ($out, "fatal: not a git repository (or any of the parent directories): .git\n", 'git_sbo_tree() gave correct output'); + is ($res, 0, 'git_sbo_tree() returned 0'); chdir $cwd; system('rm', '-rf', $repo); diff --git a/t/27-race-sbofind.t b/t/27-race-sbofind.t index c4384e8..39ac51c 100755 --- a/t/27-race-sbofind.t +++ b/t/27-race-sbofind.t @@ -6,7 +6,7 @@ use Test::More; use Test::Exit; use FindBin '$RealBin'; use lib $RealBin; -use Test::Sbotools 'load'; +use Test::Sbotools qw/set_gpg_verify load/; use Capture::Tiny qw/ capture_merged /; use File::Temp 'tempdir'; use Cwd; @@ -14,6 +14,7 @@ use feature 'state'; plan tests => 9; +set_gpg_verify('FALSE'); load('sbofind'); my $tags_file = '/usr/sbo/repo/TAGS.txt'; diff --git a/t/Test/Execute.pm b/t/Test/Execute.pm index 0d4798f..e319c2e 100755 --- a/t/Test/Execute.pm +++ b/t/Test/Execute.pm @@ -70,14 +70,7 @@ sub run { subtest $name => sub { plan tests => 2; - # 1: Test exit value - if (not defined $exit) { - SKIP: { skip "Expected exit value undefined", 1 } - } else { - is ($return, $exit, "$name - exit value"); - } - - # 2: Test output + # 1: Test output if (not defined $expected) { SKIP: { skip "Expected output undefined", 1 } } elsif (ref $expected eq 'Regexp') { @@ -88,6 +81,13 @@ sub run { } else { is ($output, $expected, "$name - output"); } + + # 2: Test exit value + if (not defined $exit) { + SKIP: { skip "Expected exit value undefined", 1 } + } else { + is ($return, $exit, "$name - exit value"); + } }; } diff --git a/t/Test/Sbotools.pm b/t/Test/Sbotools.pm index 8be5536..6f181ea 100644 --- a/t/Test/Sbotools.pm +++ b/t/Test/Sbotools.pm @@ -25,6 +25,7 @@ our @EXPORT_OK = qw/ sboupgrade set_noclean set_distclean + set_gpg_verify set_jobs set_repo set_lo @@ -50,6 +51,7 @@ sub sboupgrade { script('sboupgrade', @_); } sub set_noclean { _set_config('NOCLEAN', @_); } sub set_distclean { _set_config('DISTCLEAN', @_); } +sub set_gpg_verify { _set_config('GPG_KEY', @_); } sub set_jobs { _set_config('JOBS', @_); } sub set_pkg_dir { _set_config('PKG_DIR', @_); } sub set_sbo_home { _set_config('SBO_HOME', @_); } @@ -73,6 +75,7 @@ sub set_repo { my %config; my %settings = ( DISTCLEAN => '-d', + GPG_KEY => '-g', JOBS => '-j', LOCAL_OVERRIDES => '-o', NOCLEAN => '-c', diff --git a/t/sbotools.conf b/t/sbotools.conf index 0f505dc..a3e3d1e 100644 --- a/t/sbotools.conf +++ b/t/sbotools.conf @@ -1,3 +1,4 @@ JOBS=2 SBO_HOME=/usr/sbo DISTCLEAN=FALSE +GPG_KEY=FALSE |