2015-11-25 14:46:45 +03:00
|
|
|
#!/usr/bin/perl
|
|
|
|
#
|
|
|
|
# Test script for the ownCloud module of csync.
|
|
|
|
# This script requires a running ownCloud instance accessible via HTTP.
|
|
|
|
# It does quite some fancy tests and asserts the results.
|
|
|
|
#
|
|
|
|
# Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this library; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
#
|
|
|
|
|
|
|
|
use lib ".";
|
|
|
|
|
|
|
|
use File::Copy;
|
|
|
|
use ownCloud::Test;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
print "Hello, this is t9, a tester for content checksums.\n";
|
|
|
|
|
|
|
|
initTesting();
|
|
|
|
|
|
|
|
printInfo( "Add some files to local");
|
|
|
|
my $locDir = localDir();
|
|
|
|
copy( "testfiles/test.txt", "$locDir/test.txt");
|
|
|
|
copy( "testfiles/test.txt", "$locDir/test.eml");
|
|
|
|
|
|
|
|
csync( );
|
|
|
|
print "\nAssert local and remote dirs.\n";
|
|
|
|
assertLocalAndRemoteDir( '', 0);
|
|
|
|
|
|
|
|
# Get file properties before syncing again
|
|
|
|
my $txtpropbefore = remoteFileProp("", "test.txt");
|
|
|
|
my $emlpropbefore = remoteFileProp("", "test.eml");
|
|
|
|
assert($txtpropbefore);
|
|
|
|
assert($emlpropbefore);
|
|
|
|
|
|
|
|
printInfo( "Touch local files");
|
2017-10-05 15:13:10 +03:00
|
|
|
system( "sleep 1" );
|
2015-11-25 14:46:45 +03:00
|
|
|
system( "touch $locDir/test.txt" );
|
|
|
|
system( "touch $locDir/test.eml" );
|
|
|
|
|
|
|
|
csync( );
|
|
|
|
|
|
|
|
# Get file properties afterwards
|
|
|
|
my $txtpropafter = remoteFileProp("", "test.txt");
|
|
|
|
my $emlpropafter = remoteFileProp("", "test.eml");
|
|
|
|
assert($txtpropafter);
|
|
|
|
assert($emlpropafter);
|
|
|
|
|
2016-04-28 13:43:06 +03:00
|
|
|
# The txt file is uploaded normally, etag and mtime differ
|
|
|
|
assert($txtpropafter->get_property( "getetag" ) ne
|
2015-11-25 14:46:45 +03:00
|
|
|
$txtpropbefore->get_property( "getetag" ));
|
2016-04-28 13:43:06 +03:00
|
|
|
assert($txtpropafter->get_property( "getlastmodified" ) ne
|
2015-11-25 14:46:45 +03:00
|
|
|
$txtpropbefore->get_property( "getlastmodified" ));
|
2016-04-28 13:43:06 +03:00
|
|
|
# The eml was not uploaded, nothing differs
|
2015-11-25 14:46:45 +03:00
|
|
|
assert($emlpropafter->get_property( "getetag" ) eq
|
|
|
|
$emlpropbefore->get_property( "getetag" ));
|
|
|
|
assert($emlpropafter->get_property( "getlastmodified" ) eq
|
|
|
|
$emlpropbefore->get_property( "getlastmodified" ));
|
|
|
|
|
|
|
|
printInfo( "Change content of eml file (but not size)");
|
2016-04-28 11:44:13 +03:00
|
|
|
system( "sleep 1 && sed -i -e 's/in/IN/' $locDir/test.eml" );
|
2015-11-25 14:46:45 +03:00
|
|
|
|
|
|
|
csync( );
|
|
|
|
|
|
|
|
# Get file properties afterwards
|
|
|
|
my $emlpropchanged = remoteFileProp("", "test.eml");
|
|
|
|
assert($emlpropchanged);
|
|
|
|
assert($emlpropafter->get_property( "getetag" ) ne
|
|
|
|
$emlpropchanged->get_property( "getetag" ));
|
|
|
|
assert($emlpropafter->get_property( "getlastmodified" ) ne
|
|
|
|
$emlpropchanged->get_property( "getlastmodified" ));
|
|
|
|
|
|
|
|
# ==================================================================
|
|
|
|
|
|
|
|
cleanup();
|
|
|
|
|
|
|
|
# --
|
|
|
|
|