You are here

function RestfulCsrfTokenTestCase::testCsrfTokenAnon in RESTful 7

Same name and namespace in other branches
  1. 7.2 tests/RestfulCsrfTokenTestCase.test \RestfulCsrfTokenTestCase::testCsrfTokenAnon()

Test the validation of a CSRF token for anonymous users.

File

tests/RestfulCsrfTokenTestCase.test, line 59
Contains RestfulCsrfTokenTestCase

Class

RestfulCsrfTokenTestCase
@file Contains RestfulCsrfTokenTestCase

Code

function testCsrfTokenAnon() {
  global $user;
  $user = drupal_anonymous_user();

  // Allow anonymous user to CRUD article content.
  $permissions = array(
    'create article content' => TRUE,
    'edit any article content' => TRUE,
    'delete any article content' => TRUE,
  );
  user_role_change_permissions(DRUPAL_ANONYMOUS_RID, $permissions);
  $write_operations = array(
    \RestfulInterface::POST,
    \RestfulInterface::PUT,
    \RestfulInterface::PATCH,
    \RestfulInterface::DELETE,
  );
  $this
    ->checkCsrfRequest($write_operations, FALSE, FALSE);
}