2014-03-28 18:03:45 +04: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 ".";
|
|
|
|
|
2014-08-28 20:06:47 +04:00
|
|
|
|
2014-03-28 18:03:45 +04:00
|
|
|
use File::Copy;
|
|
|
|
use ownCloud::Test;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
print "Hello, this is t5, a tester for syncing of files in Shares\n";
|
|
|
|
|
|
|
|
initTesting();
|
|
|
|
|
2014-08-06 19:19:02 +04:00
|
|
|
# Create empty test dirs.
|
|
|
|
csync();
|
|
|
|
|
2014-03-28 18:03:45 +04:00
|
|
|
my $share_dir = "share_source";
|
2014-08-07 17:45:17 +04:00
|
|
|
my $sharee = { user => configValue('share_user'),
|
|
|
|
passwd => configValue('share_passwd'),
|
|
|
|
url => server() };
|
|
|
|
|
|
|
|
# first remove a possibly left over share dir.
|
|
|
|
printInfo( "Remove possibly left over share dir" );
|
|
|
|
removeRemoteDir( $share_dir, $sharee );
|
2014-03-28 18:03:45 +04:00
|
|
|
|
|
|
|
printInfo( "Create a share." );
|
2014-03-28 19:15:32 +04:00
|
|
|
my $shareId = createShare( $share_dir, 31 );
|
|
|
|
print "Created share with id <$shareId>\n";
|
|
|
|
|
|
|
|
assert( $shareId > 0 );
|
2014-03-28 18:03:45 +04:00
|
|
|
|
2014-10-29 16:24:36 +03:00
|
|
|
if( $ENV{SERVER_VERSION} eq "owncloud6" ) {
|
|
|
|
print "This test does not make more sense for ownCloud6, leaving for good!\n\n";
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2014-03-28 18:03:45 +04:00
|
|
|
# put a couple of files into the shared directory in the sharer account
|
2014-04-01 18:14:12 +04:00
|
|
|
glob_put( 'sharing/*', $share_dir, $sharee);
|
2014-03-28 18:03:45 +04:00
|
|
|
|
2014-08-06 19:19:02 +04:00
|
|
|
# Move the shared dir remotely into the test dir, otherwise the script
|
|
|
|
# has a hard time to find it.
|
|
|
|
moveRemoteFile( server() . $share_dir, localDir(), 1 );
|
2014-03-28 18:03:45 +04:00
|
|
|
|
|
|
|
# call csync, sync local t1 to remote t1
|
|
|
|
printInfo("Initial sync, sync stuff down.");
|
2014-08-06 19:19:02 +04:00
|
|
|
csync();
|
|
|
|
|
|
|
|
assertLocalAndRemoteDir( '', 0 );
|
2014-03-28 18:03:45 +04:00
|
|
|
|
2014-04-01 18:14:12 +04:00
|
|
|
# Local file to a read/write share should be synced up
|
2014-03-28 18:03:45 +04:00
|
|
|
printInfo("Put a file into the share.");
|
2014-08-06 19:19:02 +04:00
|
|
|
createLocalFile(localDir() . "$share_dir/foobar.txt", 8094 );
|
|
|
|
csync( );
|
|
|
|
assertLocalAndRemoteDir( '', 0 );
|
2014-03-28 18:03:45 +04:00
|
|
|
|
2014-08-07 14:13:40 +04:00
|
|
|
# now move the file locally and sync
|
|
|
|
printInfo("Move the file locally and sync.");
|
|
|
|
my $cmd = "mv " . localDir() . "$share_dir/foobar.txt ". localDir() . "$share_dir/moved_file.txt";
|
|
|
|
system( $cmd );
|
|
|
|
csync( );
|
|
|
|
assertLocalAndRemoteDir( '', 0 );
|
|
|
|
|
|
|
|
# now create aother directory and redo
|
|
|
|
printInfo("Create another directory and file");
|
|
|
|
my $cmd = "mkdir ". localDir() . "$share_dir/newDir";
|
|
|
|
system( $cmd );
|
|
|
|
createLocalFile( localDir() . "$share_dir/newDir/a_file.bin", 5321 );
|
|
|
|
csync( );
|
|
|
|
assertLocalAndRemoteDir( '', 0 );
|
|
|
|
|
|
|
|
# Remove the local file again
|
|
|
|
printInfo("Remove the local file again.");
|
|
|
|
unlink( localDir() . "$share_dir/newDir/a_file.bin" );
|
|
|
|
csync( );
|
|
|
|
assertLocalAndRemoteDir( '', 0 );
|
|
|
|
|
|
|
|
# Remove the local directory again
|
|
|
|
printInfo("Remove the local directory again.");
|
|
|
|
rmdir( localDir() . "$share_dir/newDir" );
|
|
|
|
csync( );
|
|
|
|
assertLocalAndRemoteDir( '', 0 );
|
|
|
|
|
|
|
|
|
2014-04-01 18:14:12 +04:00
|
|
|
|
2014-03-28 19:15:32 +04:00
|
|
|
printInfo("Remove a Share.");
|
|
|
|
removeShare($shareId, $share_dir);
|
2014-03-28 18:03:45 +04:00
|
|
|
cleanup();
|
|
|
|
|
|
|
|
# --
|