You are here

function FileEntityAccessTestCase::getPrivateDownloadAccessCases in File Entity (fieldable files) 7.3

Same name and namespace in other branches
  1. 7.2 file_entity.test \FileEntityAccessTestCase::getPrivateDownloadAccessCases()

Helper for testFileEntityPrivateDownloadAccess() test.

Defines several cases for accesing private files.

Return value

array Array of associative arrays, each one having the next keys:

  • "message" string with the assertion message.
  • "permissions" array of permissions or NULL for anonymous user.
  • "expect" expected HTTP response code.
  • "owner" Optional boolean indicating if the user is a file owner.
1 call to FileEntityAccessTestCase::getPrivateDownloadAccessCases()
FileEntityAccessTestCase::testFileEntityPrivateDownloadAccess in ./file_entity.test
Test to see if we have access to download private files when granted the permissions.

File

./file_entity.test, line 1595
Test integration for the file_entity module.

Class

FileEntityAccessTestCase
Tests the file entity access API.

Code

function getPrivateDownloadAccessCases() {
  return array(
    array(
      'message' => "File owners cannot download their own files unless they are granted the 'view own private files' permission.",
      'permissions' => array(),
      'expect' => 403,
      'owner' => TRUE,
    ),
    array(
      'message' => "File owners can download their own files as they have been granted the 'view own private files' permission.",
      'permissions' => array(
        'view own private files',
      ),
      'expect' => 200,
      'owner' => TRUE,
    ),
    array(
      'message' => "Anonymous users cannot download private files.",
      'permissions' => NULL,
      'expect' => 403,
    ),
    array(
      'message' => "Authenticated users cannot download each other's private files.",
      'permissions' => array(),
      'expect' => 403,
    ),
    array(
      'message' => "Users who can view public files are not able to download private files.",
      'permissions' => array(
        'view files',
      ),
      'expect' => 403,
    ),
    array(
      'message' => "Users who bypass file access can download any file.",
      'permissions' => array(
        'bypass file access',
      ),
      'expect' => 200,
    ),
  );
}