Verified Commit 53ba4986 authored by Luc Didry's avatar Luc Didry

Fix #76 Add .zip file check in the tests

This commit is dedicated to Nartagnan, who is supporting me with Ğ1.
Many thanks :-)
parent 0955757b
Pipeline #64030 passed with stages
in 4 minutes and 17 seconds
......@@ -15,6 +15,7 @@ Revision history for Lutim
- Add CLI command to print informations about images
- Add CLI command to remove images
- Add CLI command to search images based on the uploader's IP address
- Add .zip file check in the tests
0.10.4 2018-05-07
- Fix bug in cache system that would allow someone to view an image with an incorrect decryption key
......
......@@ -9,6 +9,7 @@ use Test::Mojo;
use FindBin qw($Bin);
use Digest::file qw(digest_file_hex);
use IO::Uncompress::Unzip qw($UnzipError);
my ($m, $cfile);
......@@ -108,6 +109,26 @@ $t->get_ok('/'.$short)
$t->get_ok('/'.$short)
->status_is(302);
# Get zip file and test it
$t->get_ok('/zip?i='.$short)
->status_is(200)
->header_is('Content-Disposition' => 'attachment;filename=images.zip');
my $zip = $t->ua->get('/zip?i='.$short)->res->body;
my $u = new IO::Uncompress::Unzip \$zip
or die "Cannot open zip file: $UnzipError";
my $status;
my @files = qw(hosted_with_lutim.png images/ images/Lutim.png.txt);
for ($status = 1; $status > 0; $status = $u->nextStream()) {
my $name = $u->getHeaderInfo()->{Name};
is($name, shift(@files));
my $buff;
while (($status = $u->read($buff)) > 0) {
}
last if $status < 0;
}
# Delete image with token
$raw = $t->ua->post('/' => form => { file => { file => $image }, format => 'json' })->res;
my $rshort = $raw->json('/msg/real_short');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment