[Pkg-owncloud-commits] [owncloud-client] 303/333: Use curl to get the file back, fix the LWP based download later.

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu Apr 17 23:17:07 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 5aeee6d1f292a84df7971bd8844c54b480283cb1
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Fri Apr 4 17:00:20 2014 +0200

    Use curl to get the file back, fix the LWP based download later.
---
 csync/tests/ownCloud/ownCloud/Test.pm | 32 +++++++++++++++++++++++---------
 csync/tests/ownCloud/t6.pl            |  3 ++-
 2 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/csync/tests/ownCloud/ownCloud/Test.pm b/csync/tests/ownCloud/ownCloud/Test.pm
index 84e509d..aa6de41 100644
--- a/csync/tests/ownCloud/ownCloud/Test.pm
+++ b/csync/tests/ownCloud/ownCloud/Test.pm
@@ -65,7 +65,7 @@ our %config;
                   putToDirLWP localDir remoteDir localCleanup createLocalFile md5OfFile
                   remoteCleanup server initLocalDir initRemoteDir moveRemoteFile
                   printInfo remoteFileId createShare removeShare
-                  configValue testDirUrl getToFileLWP);
+                  configValue testDirUrl getToFileLWP getToFileCurl);
 
 sub server
 {
@@ -531,6 +531,19 @@ sub putToDirLWP($$)
 }
 
 # does a simple GET of a file in the testdir to a local file.
+
+sub getToFileCurl( $$ )
+{
+    my ($file, $localFile) = @_;
+    my $geturl = testDirUrl() . $file;
+    print "GETting $geturl to $localFile\n";
+
+    my @args = ("curl", "-u", "$user:$passwd", "$geturl", "-o", "$localFile");
+    system( @args );
+}
+
+# FIXME: This does not work because I can not get an authenticated GET request
+# that writes its content to a file. Strange.
 sub getToFileLWP( $$ )
 {
     my ($file, $localFile) = @_;
@@ -539,15 +552,16 @@ sub getToFileLWP( $$ )
 
     my $ua  = LWP::UserAgent->new();
     $ua->agent( "ownCloudTest_$localDir");
-    # my $req = $ua->get($geturl, ":content_file" => $localFile);
-    my $req = HTTP::Request->new( GET => $geturl );
-    $req->authorization_basic("$user", "$passwd");
-    my $response = $ua->request($req);
-
-    if ($response->is_success()) {
-      print "OK: ", $response->content;
+    $ua->credentials( server(), "foo", $user, $passwd);
+    my $req = $ua->get($geturl, ":content_file" => $localFile);
+    # my $req = HTTP::Request->new( GET => $geturl, ':content_file' => $localFile);
+    # $req->authorization_basic("$user", "$passwd");
+    # my $response = $ua->request($req);
+
+    if ($req->is_success()) {
+      print "OK: ", $req->content;
     } else {
-      die( "HTTP GET failed: " . $response->as_string );
+      die( "HTTP GET failed: " . $req->as_string );
     }
 }
 
diff --git a/csync/tests/ownCloud/t6.pl b/csync/tests/ownCloud/t6.pl
index 73e9e1b..90e5e8f 100755
--- a/csync/tests/ownCloud/t6.pl
+++ b/csync/tests/ownCloud/t6.pl
@@ -45,7 +45,7 @@ assert( $newMd5 eq $bigMd5 );
 
 # download
 my $ctrlFile = "/tmp/file.download";
-getToFileLWP( 'BIG.file', $ctrlFile );
+getToFileCurl( 'BIG.file', $ctrlFile );
 
 assert( -e $ctrlFile, "File does not exist!" );
 
@@ -53,6 +53,7 @@ assert( -e $ctrlFile, "File does not exist!" );
 my $dlMd5 = md5OfFile( $ctrlFile );
 assert( $dlMd5 eq $newMd5 );
 
+unlink( $ctrlFile );
 
 # ==================================================================
 

-- 
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