From ecbbaac10568675952373a1d722d6ed03ffd6aba Mon Sep 17 00:00:00 2001
From: Claudiu Cristea <clau.cristea@gmail.com>
Date: Sat, 3 Nov 2012 12:47:12 +0200
Subject: [PATCH] Issue #1420812 by Bevan, claudiu.cristea: Fixed Files from
 private stream cannot be downloaded.

---
 tests/file_entity.test |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/tests/file_entity.test b/tests/file_entity.test
index 52da7b6..9f89f27 100644
--- a/tests/file_entity.test
+++ b/tests/file_entity.test
@@ -418,4 +418,29 @@ class FileEntityAccessTestCase extends FileEntityTestHelper {
     $this->drupalGet("file/{$file->fid}/delete");
     $this->assertResponse(200, 'Users with access can access the file add page');
   }
+
+  /**
+   * Test download access.
+   */
+  function testFileEntityPrivateDownloadAccess() {
+
+    // User able to download his own files.
+    $regular_user = $this->drupalCreateUser(array('view own private files'));
+    $this->drupalLogin($regular_user);
+
+    // Create a file owned by user in private stream.
+    $file = reset($this->files['image']);
+    $file->status = FILE_STATUS_PERMANENT;
+    $file->uid = $regular_user->uid;
+    file_save($file);
+    $file = file_move($file, 'private://');
+
+    // Check if the physical file is there.
+    $this->assertTrue(is_file($file->uri), t('The private file physically exists.'));
+
+    // User can download his file.
+    $url = file_create_url($file->uri);
+    $this->drupalGet($url);  
+    $this->assertResponse(200, 'User can download his file.');
+  }
 }
-- 
1.7.9.6 (Apple Git-31.1)

