Welcome to mirror list, hosted at ThFree Co, Russian Federation.

t4.pl « ownCloud « tests - github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 57159fe071bab1efdc1932cbc934a9a39cca9640 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/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 Olivier Goffart <ogoffart@woboq.com>
#

use lib ".";

use Carp::Assert;
use File::Copy;
use ownCloud::Test;

use strict;

print "Hello, this is t4, a tester for A) files that cannot be stated and B) excluded files\n";
# stat error occours on windsows when the file is busy for example

initTesting();

printInfo( "Copy some files to the remote location" );
mkdir( localDir() . 'test_stat' );
system( "echo foobar > " . localDir() . 'test_stat/file.txt' );

# call csync, sync local t1 to remote t1
csync();

# Check if the files from toremote1 are now in t1/remoteToLocal1
# they should have taken the way via the ownCloud.
print "Assert the local file copy\n";
assertLocalAndRemoteDir( '', 0 );


printInfo( "Make a file not statable" );


system( "echo foobar2 >> " . localDir() . 'test_stat/file.txt' );
#make the file not statable by changing the directory right
system( "chmod 400 " . localDir() . 'test_stat' );


csync();

# TODO: some check here.



printInfo("Add a file in a read only directory");

system( "echo \"Hello World\" >> /tmp/kernelcrash.txt" );
put_to_dir( '/tmp/kernelcrash.txt', 'test_stat' );

csync();

assert( ! -e localDir().'test_stat/kernelcrash' );


printInfo("Restore the original rights");

system( "chmod 700 " . localDir() . 'test_stat' );
system( "echo foobar3 >> " . localDir() . 'test_stat/file.txt' );

csync();

print "Check if everything is still the same\n";

assertLocalAndRemoteDir( '', 0 );

# TODO: Check that the file content is fine on the server and that there was no conflict
assert( -e localDir().'test_stat/file.txt' );
assert( -e localDir().'test_stat/kernelcrash.txt' );

my $localMD5 = md5OfFile( localDir().'test_stat/kernelcrash.txt' );
my $realMD5 = md5OfFile( '/tmp/kernelcrash.txt' );
print "MD5 compare $localMD5 <-> $realMD5\n";
assert( $localMD5 eq $realMD5 );


printInfo("Added a file that is on the ignore list");
# (*.directory is in the ignored list that needs cleanup)
# (it is names with _conflict) because i want the conflicft detection of assertLocalAndRemoteDir to work
system( "echo dir >> " . localDir() . 'test_stat/file_conflict.directory' );
csync();
# The file_conflict.directory is seen as a conflict
assertLocalAndRemoteDir( '', 1 );
# TODO: check that the file_conflict.directory is indeed NOT on the server

printInfo("Remove a directory containing a local file\n");
remoteCleanup('test_stat');

#Add an executable file for next test
system( "echo echo hello >> " . localDir() . 'echo.sh' );
chmod 0751, localDir() . 'echo.sh';

csync();
assertLocalAndRemoteDir( '', 0 );

open(my $fh, "<", localDir() . 'echo.sh');
my $perm = (stat $fh)[2] & 07777;
assert( $perm eq 0751, "permissions not kept" );


printInfo("Modify a file in the remote and check its permission\n");
system( "echo \"echo bonjour\" > /tmp/echo.sh" );
put_to_dir( '/tmp/echo.sh', "" );
csync();
assertLocalAndRemoteDir( '', 0 );

open(my $fh, "<", localDir() . 'echo.sh');
my $perm = (stat $fh)[2] & 07777;
assert( $perm eq 0751, "permissions not kept" );


cleanup();

# --