You are here

public function RestfulCsrfTokenTestCase::testCsrfToken in RESTful 7.2

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

Test the validation of a CSRF token for authenticated users.

File

tests/RestfulCsrfTokenTestCase.test, line 53
Contains RestfulCsrfTokenTestCase

Class

RestfulCsrfTokenTestCase

Code

public function testCsrfToken() {
  global $user;
  $permissions = array(
    'create article content',
    'edit any article content',
    'delete any article content',
  );
  $account = $this
    ->drupalCreateUser($permissions);
  $this
    ->drupalLogin($account);
  $user = $account;

  // Check CSRF is not checked for read operations.
  $this
    ->checkCsrfRequest(array(
    RequestInterface::METHOD_GET,
  ), FALSE);
  $this
    ->checkCsrfRequest($this->writeOperations, TRUE);
}