[Pkg-owncloud-commits] [owncloud-client] 269/333: Proper cleanup of the shared directory.

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu Apr 17 23:17:03 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit ab439f8f0f33542513959830c3a9ef700b2c5f52
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Fri Mar 28 16:15:32 2014 +0100

    Proper cleanup of the shared directory.
---
 csync/tests/ownCloud/ownCloud/Test.pm | 47 +++++++++++++++++++++++++++++++++--
 csync/tests/ownCloud/t5.pl            |  7 +++++-
 2 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/csync/tests/ownCloud/ownCloud/Test.pm b/csync/tests/ownCloud/ownCloud/Test.pm
index b97312a..ba0bb40 100644
--- a/csync/tests/ownCloud/ownCloud/Test.pm
+++ b/csync/tests/ownCloud/ownCloud/Test.pm
@@ -31,7 +31,7 @@ use Carp::Assert;
 use Digest::MD5;
 use Unicode::Normalize;
 use LWP::UserAgent;
-use HTTP::Request::Common;
+use HTTP::Request::Common qw( POST  DELETE );
 use File::Basename;
 
 use Encode qw(from_to);
@@ -63,7 +63,7 @@ our %config;
                   assertLocalDirs assertLocalAndRemoteDir glob_put put_to_dir 
                   putToDirLWP localDir remoteDir localCleanup createLocalFile md5OfFile
                   remoteCleanup server initLocalDir initRemoteDir moveRemoteFile
-                  printInfo remoteFileId createShare
+                  printInfo remoteFileId createShare removeShare
                   configValue testDirUrl);
 
 sub server
@@ -634,11 +634,54 @@ sub createShare($$)
     $req->authorization_basic($share_user, $share_passwd);
     my $response = $ua->request($req);
 
+    my $id = 0;
     if ($response->is_success()) {
       # print "OK: ", $response->content;
+	print $response->decoded_content;
+	if( $response->decoded_content =~ /<id>(\d+)<\/id>/m) {
+	    $id = $1;
+	}
     } else {
       die( "Create sharing failed: " . $response->as_string );
     }
+    return $id;
+}
+
+sub removeShare($$)
+{
+    my ($shareId, $dir) = @_;
+
+    my $dd = HTTP::DAV->new();
+
+    $dd->credentials( -url  => $owncloud, -realm=>"ownCloud",
+	              -user => $share_user,
+		      -pass => $share_passwd );
+    $dd->open( $owncloud);
+
+    my $ua  = LWP::UserAgent->new();
+    $ua->agent( "ownCloudTest_sharing");
+    # http://localhost/ocm/ocs/v1.php/apps/files_sharing/api/v1/shares
+    my $url = $ocs_url . "apps/files_sharing/api/v1/shares/" . $shareId;
+
+    my $req = DELETE $url;
+    $req->authorization_basic($share_user, $share_passwd);
+    my $response = $ua->request($req);
+
+    if ($response->is_success()) {
+      # print "OK: ", $response->content;
+	print $response->decoded_content;
+	if( $response->decoded_content =~ /<status_code>(\d+)<\/status_code>/m) {
+	    my $code = $1;
+	    assert( $code == 100 );
+	}
+    } else {
+      die( "Create sharing failed: " . $response->as_string );
+    }
+
+    # remove the share dir
+    my $req = DELETE $owncloud . $dir;
+    $req->authorization_basic($share_user, $share_passwd);
+    my $response = $ua->request($req);
 }
 
 #
diff --git a/csync/tests/ownCloud/t5.pl b/csync/tests/ownCloud/t5.pl
index 8bd87ca..f7a32bf 100755
--- a/csync/tests/ownCloud/t5.pl
+++ b/csync/tests/ownCloud/t5.pl
@@ -37,7 +37,10 @@ initTesting();
 my $share_dir = "share_source";
 
 printInfo( "Create a share." );
-createShare( $share_dir, 31 );
+my $shareId = createShare( $share_dir, 31 );
+print "Created share with id <$shareId>\n";
+
+assert( $shareId > 0 );
 
 # put a couple of files into the shared directory in the sharer account
 glob_put( 'sharing/*', $share_dir, { user => configValue('share_user'),
@@ -56,6 +59,8 @@ createLocalFile( localDir(). $share_dir . "/foobar.txt", 8094 );
 csync( server()."Shared" );
 assertLocalAndRemoteDir( 'Shared', 0, server() );
 
+printInfo("Remove a Share.");
+removeShare($shareId, $share_dir);
 cleanup();
 
 # --

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list